mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
Make empty but non-nil Withdrawals arrays decode as empty but non-nil. (#6291)
This commit is contained in:
parent
863e1ed07b
commit
cf6173d042
@ -728,6 +728,7 @@ func (rb *RawBody) DecodeRLP(s *rlp.Stream) error {
|
||||
}
|
||||
return fmt.Errorf("read Withdrawals: %w", err)
|
||||
}
|
||||
rb.Withdrawals = []*Withdrawal{}
|
||||
for err == nil {
|
||||
var withdrawal Withdrawal
|
||||
if err = withdrawal.DecodeRLP(s); err != nil {
|
||||
@ -909,6 +910,7 @@ func (bb *Body) DecodeRLP(s *rlp.Stream) error {
|
||||
}
|
||||
return fmt.Errorf("read Withdrawals: %w", err)
|
||||
}
|
||||
bb.Withdrawals = []*Withdrawal{}
|
||||
for err == nil {
|
||||
var withdrawal Withdrawal
|
||||
if err = withdrawal.DecodeRLP(s); err != nil {
|
||||
@ -1083,6 +1085,7 @@ func (bb *Block) DecodeRLP(s *rlp.Stream) error {
|
||||
}
|
||||
return fmt.Errorf("read Withdrawals: %w", err)
|
||||
}
|
||||
bb.withdrawals = []*Withdrawal{}
|
||||
for err == nil {
|
||||
var withdrawal Withdrawal
|
||||
if err = withdrawal.DecodeRLP(s); err != nil {
|
||||
|
@ -425,4 +425,16 @@ func TestWithdrawalsEncoding(t *testing.T) {
|
||||
require.NoError(t, rlp.DecodeBytes(encoded, &decoded))
|
||||
|
||||
assert.Equal(t, block, &decoded)
|
||||
|
||||
// Now test with empty withdrawals
|
||||
block2 := NewBlock(&header, nil, nil, nil, []*Withdrawal{})
|
||||
_ = block2.Size()
|
||||
|
||||
encoded2, err := rlp.EncodeToBytes(block2)
|
||||
require.NoError(t, err)
|
||||
|
||||
var decoded2 Block
|
||||
require.NoError(t, rlp.DecodeBytes(encoded2, &decoded2))
|
||||
|
||||
assert.Equal(t, block2, &decoded2)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user