Handle all breaking changes for the patch

The major change to integrate the patch has been:

* Updating the arguments for `rlp.EncodeToBytes`. This function accepts interfaces, but since the last update, it is better to pass in a pointer to the function.
* From the Ethereum Release Notes: "
Compatibility note about `core/types`: For optimization purposes, `types.Header` and other types in this package now implement the `rlp.Encoder` interface. This change can cause incompatibilities because the new method is implemented with pointer receiver. Attempting to RLP-encode unadressable (i.e. non-pointer) values of type `Header` does not work anymore and will result in an error."
* Instead of just updating all the headers. I have updated all parameters for the `rlp.EncodeToBytes` to be pointers instead of values.

__Please take a close look at the updates__. The functions won't fail if a non-pointer is passed (in most cases), but we could be unexpected behaviors.
This commit is contained in:
Abdul Rabbani 2022-04-06 10:57:57 -04:00
parent 3fab9cf7a8
commit c55f7d3098
5 changed files with 19 additions and 19 deletions

View File

@ -702,7 +702,7 @@ func TestBuilder(t *testing.T) {
if err != nil {
t.Error(err)
}
expectedStateDiffRlp, err := rlp.EncodeToBytes(test.expected)
expectedStateDiffRlp, err := rlp.EncodeToBytes(&test.expected)
if err != nil {
t.Error(err)
}
@ -965,7 +965,7 @@ func TestBuilderWithIntermediateNodes(t *testing.T) {
if err != nil {
t.Error(err)
}
expectedStateDiffRlp, err := rlp.EncodeToBytes(test.expected)
expectedStateDiffRlp, err := rlp.EncodeToBytes(&test.expected)
if err != nil {
t.Error(err)
}
@ -1155,7 +1155,7 @@ func TestBuilderWithWatchedAddressList(t *testing.T) {
if err != nil {
t.Error(err)
}
expectedStateDiffRlp, err := rlp.EncodeToBytes(test.expected)
expectedStateDiffRlp, err := rlp.EncodeToBytes(&test.expected)
if err != nil {
t.Error(err)
}
@ -1385,7 +1385,7 @@ func TestBuilderWithRemovedAccountAndStorage(t *testing.T) {
if err != nil {
t.Error(err)
}
expectedStateDiffRlp, err := rlp.EncodeToBytes(test.expected)
expectedStateDiffRlp, err := rlp.EncodeToBytes(&test.expected)
if err != nil {
t.Error(err)
}
@ -1871,7 +1871,7 @@ func TestBuilderWithRemovedWatchedAccount(t *testing.T) {
t.Error(err)
}
expectedStateDiffRlp, err := rlp.EncodeToBytes(test.expected)
expectedStateDiffRlp, err := rlp.EncodeToBytes(&test.expected)
if err != nil {
t.Error(err)
}
@ -1984,12 +1984,12 @@ func TestBuilderWithRemovedNonWatchedAccount(t *testing.T) {
if err != nil {
t.Error(err)
}
receivedStateDiffRlp, err := rlp.EncodeToBytes(diff)
receivedStateDiffRlp, err := rlp.EncodeToBytes(&diff)
if err != nil {
t.Error(err)
}
expectedStateDiffRlp, err := rlp.EncodeToBytes(test.expected)
expectedStateDiffRlp, err := rlp.EncodeToBytes(&test.expected)
if err != nil {
t.Error(err)
}
@ -2154,12 +2154,12 @@ func TestBuilderWithRemovedWatchedAccount(t *testing.T) {
if err != nil {
t.Error(err)
}
receivedStateDiffRlp, err := rlp.EncodeToBytes(diff)
receivedStateDiffRlp, err := rlp.EncodeToBytes(&diff)
if err != nil {
t.Error(err)
}
expectedStateDiffRlp, err := rlp.EncodeToBytes(test.expected)
expectedStateDiffRlp, err := rlp.EncodeToBytes(&test.expected)
if err != nil {
t.Error(err)
}
@ -2391,7 +2391,7 @@ func TestBuilderWithMovedAccount(t *testing.T) {
if err != nil {
t.Error(err)
}
expectedStateDiffRlp, err := rlp.EncodeToBytes(test.expected)
expectedStateDiffRlp, err := rlp.EncodeToBytes(&test.expected)
if err != nil {
t.Error(err)
}
@ -2527,7 +2527,7 @@ func TestBuilderWithMovedAccountOnlyLeafs(t *testing.T) {
if err != nil {
t.Error(err)
}
expectedStateDiffRlp, err := rlp.EncodeToBytes(test.expected)
expectedStateDiffRlp, err := rlp.EncodeToBytes(&test.expected)
if err != nil {
t.Error(err)
}
@ -2758,7 +2758,7 @@ func TestBuildStateTrie(t *testing.T) {
if err != nil {
t.Error(err)
}
expectedStateTrieRlp, err := rlp.EncodeToBytes(test.expected)
expectedStateTrieRlp, err := rlp.EncodeToBytes(&test.expected)
if err != nil {
t.Error(err)
}

View File

@ -46,7 +46,7 @@ var _ node.Node = (*EthHeader)(nil)
// NewEthHeader converts a *types.Header into an EthHeader IPLD node
func NewEthHeader(header *types.Header) (*EthHeader, error) {
headerRLP, err := rlp.EncodeToBytes(header)
headerRLP, err := rlp.EncodeToBytes(&header)
if err != nil {
return nil, err
}

View File

@ -420,7 +420,7 @@ func init() {
}
db = rawdb.NewMemoryDatabase()
genesisBlock = core.DefaultGenesisBlock().MustCommit(db)
genBy, err := rlp.EncodeToBytes(genesisBlock)
genBy, err := rlp.EncodeToBytes(&genesisBlock)
if err != nil {
log.Fatal(err)
}
@ -671,7 +671,7 @@ func TestBuilderOnMainnetBlocks(t *testing.T) {
if err != nil {
t.Error(err)
}
receivedStateDiffRlp, err := rlp.EncodeToBytes(diff)
receivedStateDiffRlp, err := rlp.EncodeToBytes(&diff)
if err != nil {
t.Error(err)
}

View File

@ -235,7 +235,7 @@ func testErrorInStateDiffAt(t *testing.T) {
if err != nil {
t.Error(err)
}
expectedBlockRlp, err := rlp.EncodeToBytes(testBlock1)
expectedBlockRlp, err := rlp.EncodeToBytes(&testBlock1)
if err != nil {
t.Error(err)
}
@ -269,7 +269,7 @@ func testErrorInStateDiffAt(t *testing.T) {
if err != nil {
t.Error(err)
}
stateDiffPayloadRlp, err := rlp.EncodeToBytes(stateDiffPayload)
stateDiffPayloadRlp, err := rlp.EncodeToBytes(&stateDiffPayload)
if err != nil {
t.Error(err)
}

View File

@ -97,7 +97,7 @@ func testSubscriptionAPI(t *testing.T) {
defer chain.Stop()
block0 = test_helpers.Genesis
block1 = blocks[0]
expectedBlockRlp, _ := rlp.EncodeToBytes(block1)
expectedBlockRlp, _ := rlp.EncodeToBytes(&block1)
mockReceipt := &types.Receipt{
BlockNumber: block1.Number(),
BlockHash: block1.Hash(),
@ -189,7 +189,7 @@ func testHTTPAPI(t *testing.T) {
defer chain.Stop()
block0 = test_helpers.Genesis
block1 = blocks[0]
expectedBlockRlp, _ := rlp.EncodeToBytes(block1)
expectedBlockRlp, _ := rlp.EncodeToBytes(&block1)
mockReceipt := &types.Receipt{
BlockNumber: block1.Number(),
BlockHash: block1.Hash(),