Skip to content

Commit

Permalink
Merge pull request #6286 from onflow/ramtin/evm-patch-block-loading-bug
Browse files Browse the repository at this point in the history
[Flow EVM] patch backoff block loading
  • Loading branch information
sideninja authored Aug 2, 2024
2 parents 09712a4 + 5d5c2d8 commit dd9faee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fvm/evm/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ func decodeBlockBreakingChanges(encoded []byte) *Block {
b6 := &blockV6{}
if err := gethRLP.DecodeBytes(encoded, b6); err == nil {
return &Block{
ParentBlockHash: b5.ParentBlockHash,
Height: b5.Height,
Timestamp: b5.Timestamp,
TotalSupply: b5.TotalSupply,
ReceiptRoot: b5.ReceiptRoot,
ParentBlockHash: b6.ParentBlockHash,
Height: b6.Height,
Timestamp: b6.Timestamp,
TotalSupply: b6.TotalSupply,
ReceiptRoot: b6.ReceiptRoot,
}
}

Expand Down
20 changes: 20 additions & 0 deletions fvm/evm/types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,24 @@ func Test_DecodeBlocks(t *testing.T) {
require.Equal(t, b.Height, bv5.Height)
require.Equal(t, b.ParentBlockHash, bv5.ParentBlockHash)
require.Empty(t, b.TotalGasUsed)

bv6 := blockV6{
ParentBlockHash: GenesisBlockHash,
Height: 1,
TotalSupply: big.NewInt(2),
ReceiptRoot: gethCommon.Hash{0x02},
TransactionHashes: []gethCommon.Hash{{0x04}},
Timestamp: 100,
}

b6, err := gethRLP.EncodeToBytes(bv6)
require.NoError(t, err)

b = decodeBlockBreakingChanges(b6)

require.Equal(t, b.Timestamp, bv6.Timestamp)
require.Equal(t, b.TotalSupply, bv6.TotalSupply)
require.Equal(t, b.Height, bv6.Height)
require.Equal(t, b.ParentBlockHash, bv6.ParentBlockHash)
require.Empty(t, b.TotalGasUsed)
}

0 comments on commit dd9faee

Please sign in to comment.