Skip to content

Commit

Permalink
Use NewBytes, since it wraps NewCopyBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed May 15, 2023
1 parent e7bead7 commit c780fad
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions types/rlp_marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ func (h *Header) MarshalRLPTo(dst []byte) []byte {
func (h *Header) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value {
vv := arena.NewArray()

vv.Set(arena.NewCopyBytes(h.ParentHash.Bytes()))
vv.Set(arena.NewCopyBytes(h.Sha3Uncles.Bytes()))
vv.Set(arena.NewCopyBytes(h.Miner[:]))
vv.Set(arena.NewCopyBytes(h.StateRoot.Bytes()))
vv.Set(arena.NewCopyBytes(h.TxRoot.Bytes()))
vv.Set(arena.NewCopyBytes(h.ReceiptsRoot.Bytes()))
vv.Set(arena.NewCopyBytes(h.LogsBloom[:]))
vv.Set(arena.NewBytes(h.ParentHash.Bytes()))
vv.Set(arena.NewBytes(h.Sha3Uncles.Bytes()))
vv.Set(arena.NewBytes(h.Miner[:]))
vv.Set(arena.NewBytes(h.StateRoot.Bytes()))
vv.Set(arena.NewBytes(h.TxRoot.Bytes()))
vv.Set(arena.NewBytes(h.ReceiptsRoot.Bytes()))
vv.Set(arena.NewBytes(h.LogsBloom[:]))

vv.Set(arena.NewUint(h.Difficulty))
vv.Set(arena.NewUint(h.Number))
vv.Set(arena.NewUint(h.GasLimit))
vv.Set(arena.NewUint(h.GasUsed))
vv.Set(arena.NewUint(h.Timestamp))

vv.Set(arena.NewCopyBytes(h.ExtraData))
vv.Set(arena.NewCopyBytes(h.MixHash.Bytes()))
vv.Set(arena.NewCopyBytes(h.Nonce[:]))
vv.Set(arena.NewBytes(h.ExtraData))
vv.Set(arena.NewBytes(h.MixHash.Bytes()))
vv.Set(arena.NewBytes(h.Nonce[:]))

vv.Set(arena.NewUint(h.BaseFee))

Expand Down Expand Up @@ -135,11 +135,11 @@ func (r *Receipt) MarshalRLPWith(a *fastrlp.Arena) *fastrlp.Value {
if r.Status != nil {
vv.Set(a.NewUint(uint64(*r.Status)))
} else {
vv.Set(a.NewCopyBytes(r.Root[:]))
vv.Set(a.NewBytes(r.Root[:]))
}

vv.Set(a.NewUint(r.CumulativeGasUsed))
vv.Set(a.NewCopyBytes(r.LogsBloom[:]))
vv.Set(a.NewBytes(r.LogsBloom[:]))
vv.Set(r.MarshalLogsWith(a))

return vv
Expand All @@ -163,15 +163,15 @@ func (r *Receipt) MarshalLogsWith(a *fastrlp.Arena) *fastrlp.Value {

func (l *Log) MarshalRLPWith(a *fastrlp.Arena) *fastrlp.Value {
v := a.NewArray()
v.Set(a.NewCopyBytes(l.Address.Bytes()))
v.Set(a.NewBytes(l.Address.Bytes()))

topics := a.NewArray()
for _, t := range l.Topics {
topics.Set(a.NewCopyBytes(t.Bytes()))
topics.Set(a.NewBytes(t.Bytes()))
}

v.Set(topics)
v.Set(a.NewCopyBytes(l.Data))
v.Set(a.NewBytes(l.Data))

return v
}
Expand Down Expand Up @@ -215,13 +215,13 @@ func (t *Transaction) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value {

// Address may be empty
if t.To != nil {
vv.Set(arena.NewCopyBytes(t.To.Bytes()))
vv.Set(arena.NewBytes(t.To.Bytes()))
} else {
vv.Set(arena.NewNull())
}

vv.Set(arena.NewBigInt(t.Value))
vv.Set(arena.NewCopyBytes(t.Input))
vv.Set(arena.NewBytes(t.Input))

// Specify access list as per spec.
// This is needed to have the same format as other EVM chains do.
Expand All @@ -237,7 +237,7 @@ func (t *Transaction) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value {
vv.Set(arena.NewBigInt(t.S))

if t.Type == StateTx {
vv.Set(arena.NewCopyBytes(t.From.Bytes()))
vv.Set(arena.NewBytes(t.From.Bytes()))
}

return vv
Expand Down

0 comments on commit c780fad

Please sign in to comment.