From 6948bd70e50829dc1584c52667413724a14eaf82 Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Wed, 28 Apr 2021 15:18:10 -0500 Subject: [PATCH] fix error caused by 2718 by using MarshalBinary instead of EncodeRLP methods --- statediff/indexer/ipfs/ipld/eth_receipt.go | 11 +++++------ statediff/indexer/ipfs/ipld/eth_tx.go | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/statediff/indexer/ipfs/ipld/eth_receipt.go b/statediff/indexer/ipfs/ipld/eth_receipt.go index cfa46b36e..ae1a43465 100644 --- a/statediff/indexer/ipfs/ipld/eth_receipt.go +++ b/statediff/indexer/ipfs/ipld/eth_receipt.go @@ -22,7 +22,6 @@ import ( "strconv" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/rlp" "github.com/ipfs/go-cid" node "github.com/ipfs/go-ipld-format" mh "github.com/multiformats/go-multihash" @@ -44,18 +43,18 @@ var _ node.Node = (*EthReceipt)(nil) // NewReceipt converts a types.ReceiptForStorage to an EthReceipt IPLD node func NewReceipt(receipt *types.Receipt) (*EthReceipt, error) { - receiptRLP, err := rlp.EncodeToBytes(receipt) + rctRaw, err := receipt.MarshalBinary() if err != nil { return nil, err } - c, err := RawdataToCid(MEthTxReceipt, receiptRLP, mh.KECCAK_256) + c, err := RawdataToCid(MEthTxReceipt, rctRaw, mh.KECCAK_256) if err != nil { return nil, err } return &EthReceipt{ Receipt: receipt, cid: c, - rawdata: receiptRLP, + rawdata: rctRaw, }, nil } @@ -66,8 +65,8 @@ func NewReceipt(receipt *types.Receipt) (*EthReceipt, error) { // DecodeEthReceipt takes a cid and its raw binary data // from IPFS and returns an EthTx object for further processing. func DecodeEthReceipt(c cid.Cid, b []byte) (*EthReceipt, error) { - var r *types.Receipt - if err := rlp.DecodeBytes(b, r); err != nil { + r := new(types.Receipt) + if err := r.UnmarshalBinary(b); err != nil { return nil, err } return &EthReceipt{ diff --git a/statediff/indexer/ipfs/ipld/eth_tx.go b/statediff/indexer/ipfs/ipld/eth_tx.go index 4fc4d20a6..7a6c9f236 100644 --- a/statediff/indexer/ipfs/ipld/eth_tx.go +++ b/statediff/indexer/ipfs/ipld/eth_tx.go @@ -23,7 +23,6 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/rlp" "github.com/ipfs/go-cid" node "github.com/ipfs/go-ipld-format" mh "github.com/multiformats/go-multihash" @@ -46,18 +45,18 @@ var _ node.Node = (*EthTx)(nil) // NewEthTx converts a *types.Transaction to an EthTx IPLD node func NewEthTx(tx *types.Transaction) (*EthTx, error) { - txRLP, err := rlp.EncodeToBytes(tx) + txRaw, err := tx.MarshalBinary() if err != nil { return nil, err } - c, err := RawdataToCid(MEthTx, txRLP, mh.KECCAK_256) + c, err := RawdataToCid(MEthTx, txRaw, mh.KECCAK_256) if err != nil { return nil, err } return &EthTx{ Transaction: tx, cid: c, - rawdata: txRLP, + rawdata: txRaw, }, nil } @@ -68,8 +67,8 @@ func NewEthTx(tx *types.Transaction) (*EthTx, error) { // DecodeEthTx takes a cid and its raw binary data // from IPFS and returns an EthTx object for further processing. func DecodeEthTx(c cid.Cid, b []byte) (*EthTx, error) { - var t *types.Transaction - if err := rlp.DecodeBytes(b, t); err != nil { + t := new(types.Transaction) + if err := t.UnmarshalBinary(b); err != nil { return nil, err } return &EthTx{