To in EIP-4844 transactions must be non-nil (#8047)

See https://github.com/ethereum/EIPs/pull/7100
This commit is contained in:
Andrew Ashikhmin 2023-08-21 18:00:11 +02:00 committed by GitHub
parent 6bc0ca9e85
commit 64d483e23a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -150,18 +150,12 @@ func (stx BlobTx) encodePayload(w io.Writer, b []byte, payloadSize, nonceLen, ga
return err return err
} }
// encode To // encode To
if stx.To == nil { b[0] = 128 + 20
b[0] = 128
} else {
b[0] = 128 + 20
}
if _, err := w.Write(b[:1]); err != nil { if _, err := w.Write(b[:1]); err != nil {
return err return err
} }
if stx.To != nil { if _, err := w.Write(stx.To.Bytes()); err != nil {
if _, err := w.Write(stx.To.Bytes()); err != nil { return err
return err
}
} }
// encode Value // encode Value
if err := stx.Value.EncodeRLP(w); err != nil { if err := stx.Value.EncodeRLP(w); err != nil {
@ -276,13 +270,11 @@ func (stx *BlobTx) DecodeRLP(s *rlp.Stream) error {
if b, err = s.Bytes(); err != nil { if b, err = s.Bytes(); err != nil {
return err return err
} }
if len(b) > 0 && len(b) != 20 { if len(b) != 20 {
return fmt.Errorf("wrong size for To: %d", len(b)) return fmt.Errorf("wrong size for To: %d", len(b))
} }
if len(b) > 0 { stx.To = &libcommon.Address{}
stx.To = &libcommon.Address{} copy((*stx.To)[:], b)
copy((*stx.To)[:], b)
}
if b, err = s.Uint256Bytes(); err != nil { if b, err = s.Uint256Bytes(); err != nil {
return err return err