Skip to content

Commit a6e1e93

Browse files
Matthieu Rioumatthieu
authored andcommitted
Revert 'core/types: add MarshalBinary, UnmarshalBinary for Receipt (ethereum#22806)
1 parent b7fe580 commit a6e1e93

File tree

3 files changed

+4
-37
lines changed

3 files changed

+4
-37
lines changed

core/types/receipt.go

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -128,29 +128,13 @@ func (r *Receipt) EncodeRLP(w io.Writer) error {
128128
buf := encodeBufferPool.Get().(*bytes.Buffer)
129129
defer encodeBufferPool.Put(buf)
130130
buf.Reset()
131-
if err := r.encodeTyped(data, buf); err != nil {
131+
buf.WriteByte(r.Type)
132+
if err := rlp.Encode(buf, data); err != nil {
132133
return err
133134
}
134135
return rlp.Encode(w, buf.Bytes())
135136
}
136137

137-
// encodeTyped writes the canonical encoding of a typed receipt to w.
138-
func (r *Receipt) encodeTyped(data *receiptRLP, w *bytes.Buffer) error {
139-
w.WriteByte(r.Type)
140-
return rlp.Encode(w, data)
141-
}
142-
143-
// MarshalBinary returns the consensus encoding of the receipt.
144-
func (r *Receipt) MarshalBinary() ([]byte, error) {
145-
if r.Type == LegacyTxType {
146-
return rlp.EncodeToBytes(r)
147-
}
148-
data := &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs}
149-
var buf bytes.Buffer
150-
err := r.encodeTyped(data, &buf)
151-
return buf.Bytes(), err
152-
}
153-
154138
// DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt
155139
// from an RLP stream.
156140
func (r *Receipt) DecodeRLP(s *rlp.Stream) error {
@@ -182,23 +166,6 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error {
182166
}
183167
}
184168

185-
// UnmarshalBinary decodes the consensus encoding of receipts.
186-
// It supports legacy RLP receipts and EIP-2718 typed receipts.
187-
func (r *Receipt) UnmarshalBinary(b []byte) error {
188-
if len(b) > 0 && b[0] > 0x7f {
189-
// It's a legacy receipt decode the RLP
190-
var data receiptRLP
191-
err := rlp.DecodeBytes(b, &data)
192-
if err != nil {
193-
return err
194-
}
195-
r.Type = LegacyTxType
196-
return r.setFromRLP(data)
197-
}
198-
// It's an EIP2718 typed transaction envelope.
199-
return r.decodeTyped(b)
200-
}
201-
202169
// decodeTyped decodes a typed receipt from the canonical format.
203170
func (r *Receipt) decodeTyped(b []byte) error {
204171
if len(b) <= 1 {

graphql/graphql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ func (t *Transaction) RawReceipt(ctx context.Context) (hexutil.Bytes, error) {
645645
if err != nil || receipt == nil {
646646
return hexutil.Bytes{}, err
647647
}
648-
return receipt.MarshalBinary()
648+
return rlp.EncodeToBytes(receipt)
649649
}
650650

651651
type BlockType int

internal/ethapi/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.Block
19901990
}
19911991
result := make([]hexutil.Bytes, len(receipts))
19921992
for i, receipt := range receipts {
1993-
b, err := receipt.MarshalBinary()
1993+
b, err := rlp.EncodeToBytes(receipt)
19941994
if err != nil {
19951995
return nil, err
19961996
}

0 commit comments

Comments
 (0)