From e3746ee1980dade609ac190d27183a6a5b94f4df Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Fri, 12 May 2023 11:15:58 -0700 Subject: [PATCH] fix(relayer): catch relayer message processing up to latest protocol changes (#13746) --- .../relayer/encoding/signal_proof_test.go | 61 +-------------- packages/relayer/encoding/types.go | 78 +------------------ .../relayer/proof/encoded_signal_proof.go | 2 +- .../proof/encoded_signal_proof_test.go | 2 +- 4 files changed, 9 insertions(+), 134 deletions(-) diff --git a/packages/relayer/encoding/signal_proof_test.go b/packages/relayer/encoding/signal_proof_test.go index f0d3561a87d..40107b425f1 100644 --- a/packages/relayer/encoding/signal_proof_test.go +++ b/packages/relayer/encoding/signal_proof_test.go @@ -4,77 +4,22 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" "gopkg.in/go-playground/assert.v1" ) func Test_EncodeSignalProof(t *testing.T) { - header := &types.Header{ - ParentHash: common.HexToHash("0x3a537c89809712367218bb171b3b1c46aa95df3dee7200ae9dc78f4052024068"), - UncleHash: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"), - Root: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - TxHash: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - ReceiptHash: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - Bloom: types.Bloom{}, - Difficulty: new(big.Int).SetInt64(2), - Number: new(big.Int).SetInt64(1), - GasLimit: 100000, - GasUsed: 2000, - Time: 1234, - Extra: []byte{0x7f}, - MixDigest: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - Nonce: types.BlockNonce{0x13}, - } - - // nolint: lll - storageProof := "0x00edb9377a94f02e691ea208a80a7bd13dcb51dfae3a389d3001a55c5fdf3f3ae70807df1d8ffcaeefa5dc56875a03dae3494d93bbf3074018fea52137a098433d9795f455fcfaf89b6456b970605bd0f70bec98418ef322fa5bba9874ab2277225a38c19f99275cd6d25d9cd4259c366c02b750056a6b71810034f95d34ae12c1298a95e6ba03de90dbbfacc5c8edbeb6ed93a0e01c08f3435b1ca944e9229a176804445432795c14dc315925fe2480084d6b0729c30fb1c2e50e481df5d7daa25769a0c74baf362ff02f2a934538cd11bf939f64377489255aa60a12628b130f4bddd30664d6b5f91d17cc110bee38a7ce5c629585e57d777bfbb2eaf09e15" - - s := SignalProof{ - Header: BlockToBlockHeader(types.NewBlockWithHeader(header)), - Proof: hexutil.MustDecode(storageProof), - } - - // nolint: lll - want := "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003803a537c89809712367218bb171b3b1c46aa95df3dee7200ae9dc78f40520240681dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934700000000000000000000000000000000000000000000000000000000000000001dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493471dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493471dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000007d000000000000000000000000000000000000000000000000000000000000004d200000000000000000000000000000000000000000000000000000000000003001dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934700000000000000000000000000000000000000000000000013000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000edb9377a94f02e691ea208a80a7bd13dcb51dfae3a389d3001a55c5fdf3f3ae70807df1d8ffcaeefa5dc56875a03dae3494d93bbf3074018fea52137a098433d9795f455fcfaf89b6456b970605bd0f70bec98418ef322fa5bba9874ab2277225a38c19f99275cd6d25d9cd4259c366c02b750056a6b71810034f95d34ae12c1298a95e6ba03de90dbbfacc5c8edbeb6ed93a0e01c08f3435b1ca944e9229a176804445432795c14dc315925fe2480084d6b0729c30fb1c2e50e481df5d7daa25769a0c74baf362ff02f2a934538cd11bf939f64377489255aa60a12628b130f4bddd30664d6b5f91d17cc110bee38a7ce5c629585e57d777bfbb2eaf09e15" - proof, err := EncodeSignalProof(s) - assert.Equal(t, nil, err) - assert.Equal(t, hexutil.Encode(proof), want) -} - -func Test_EncodeSignalProof_Shanghai(t *testing.T) { - wRoot := common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347") - header := &types.Header{ - ParentHash: common.HexToHash("0x3a537c89809712367218bb171b3b1c46aa95df3dee7200ae9dc78f4052024068"), - UncleHash: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"), - Root: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - TxHash: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - ReceiptHash: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - Bloom: types.Bloom{}, - Difficulty: new(big.Int).SetInt64(2), - Number: new(big.Int).SetInt64(1), - GasLimit: 100000, - GasUsed: 2000, - Time: 1234, - Extra: []byte{0x7f}, - MixDigest: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"), - Nonce: types.BlockNonce{0x13}, - WithdrawalsHash: &wRoot, - } - + height := new(big.Int).SetInt64(1) // nolint: lll storageProof := "0x00edb9377a94f02e691ea208a80a7bd13dcb51dfae3a389d3001a55c5fdf3f3ae70807df1d8ffcaeefa5dc56875a03dae3494d93bbf3074018fea52137a098433d9795f455fcfaf89b6456b970605bd0f70bec98418ef322fa5bba9874ab2277225a38c19f99275cd6d25d9cd4259c366c02b750056a6b71810034f95d34ae12c1298a95e6ba03de90dbbfacc5c8edbeb6ed93a0e01c08f3435b1ca944e9229a176804445432795c14dc315925fe2480084d6b0729c30fb1c2e50e481df5d7daa25769a0c74baf362ff02f2a934538cd11bf939f64377489255aa60a12628b130f4bddd30664d6b5f91d17cc110bee38a7ce5c629585e57d777bfbb2eaf09e15" s := SignalProof{ - Header: BlockToBlockHeader(types.NewBlockWithHeader(header)), + Height: height, Proof: hexutil.MustDecode(storageProof), } // nolint: lll - want := "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003803a537c89809712367218bb171b3b1c46aa95df3dee7200ae9dc78f40520240681dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934700000000000000000000000000000000000000000000000000000000000000001dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493471dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493471dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000007d000000000000000000000000000000000000000000000000000000000000004d200000000000000000000000000000000000000000000000000000000000003001dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347000000000000000000000000000000000000000000000000130000000000000000000000000000000000000000000000000000000000000000000000000000001dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934700000000000000000000000000000000000000000000000000000000000000017f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000edb9377a94f02e691ea208a80a7bd13dcb51dfae3a389d3001a55c5fdf3f3ae70807df1d8ffcaeefa5dc56875a03dae3494d93bbf3074018fea52137a098433d9795f455fcfaf89b6456b970605bd0f70bec98418ef322fa5bba9874ab2277225a38c19f99275cd6d25d9cd4259c366c02b750056a6b71810034f95d34ae12c1298a95e6ba03de90dbbfacc5c8edbeb6ed93a0e01c08f3435b1ca944e9229a176804445432795c14dc315925fe2480084d6b0729c30fb1c2e50e481df5d7daa25769a0c74baf362ff02f2a934538cd11bf939f64377489255aa60a12628b130f4bddd30664d6b5f91d17cc110bee38a7ce5c629585e57d777bfbb2eaf09e15" + want := "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000edb9377a94f02e691ea208a80a7bd13dcb51dfae3a389d3001a55c5fdf3f3ae70807df1d8ffcaeefa5dc56875a03dae3494d93bbf3074018fea52137a098433d9795f455fcfaf89b6456b970605bd0f70bec98418ef322fa5bba9874ab2277225a38c19f99275cd6d25d9cd4259c366c02b750056a6b71810034f95d34ae12c1298a95e6ba03de90dbbfacc5c8edbeb6ed93a0e01c08f3435b1ca944e9229a176804445432795c14dc315925fe2480084d6b0729c30fb1c2e50e481df5d7daa25769a0c74baf362ff02f2a934538cd11bf939f64377489255aa60a12628b130f4bddd30664d6b5f91d17cc110bee38a7ce5c629585e57d777bfbb2eaf09e15" proof, err := EncodeSignalProof(s) assert.Equal(t, nil, err) assert.Equal(t, hexutil.Encode(proof), want) diff --git a/packages/relayer/encoding/types.go b/packages/relayer/encoding/types.go index 7b8ed26c921..806b2500e14 100644 --- a/packages/relayer/encoding/types.go +++ b/packages/relayer/encoding/types.go @@ -33,84 +33,14 @@ type BlockHeader struct { } type SignalProof struct { - Header BlockHeader `abi:"header"` - Proof []byte `abi:"proof"` + Height *big.Int `abi:"height"` + Proof []byte `abi:"proof"` } var signalProofT, _ = abi.NewType("tuple", "", []abi.ArgumentMarshaling{ { - Name: "header", - Type: "tuple", - Components: []abi.ArgumentMarshaling{ - { - Name: "parentHash", - Type: "bytes32", - }, - { - Name: "ommersHash", - Type: "bytes32", - }, - { - Name: "beneficiary", - Type: "address", - }, - { - Name: "stateRoot", - Type: "bytes32", - }, - { - Name: "transactionsRoot", - Type: "bytes32", - }, - { - Name: "receiptsRoot", - Type: "bytes32", - }, - { - Name: "logsBloom", - Type: "bytes32[8]", - }, - { - Name: "difficulty", - Type: "uint256", - }, - { - Name: "height", - Type: "uint128", - }, - { - Name: "gasLimit", - Type: "uint64", - }, - { - Name: "gasUsed", - Type: "uint64", - }, - { - Name: "timestamp", - Type: "uint64", - }, - { - Name: "extraData", - Type: "bytes", - }, - { - Name: "mixHash", - Type: "bytes32", - }, - { - Name: "nonce", - Type: "uint64", - }, - { - Name: "baseFeePerGas", - Type: "uint256", - }, - { - Name: "withdrawalsRoot", - Type: "bytes32", - }, - }, + Name: "height", + Type: "uint256", }, { Name: "proof", diff --git a/packages/relayer/proof/encoded_signal_proof.go b/packages/relayer/proof/encoded_signal_proof.go index 83aaf4af3a7..1d34d6980f5 100644 --- a/packages/relayer/proof/encoded_signal_proof.go +++ b/packages/relayer/proof/encoded_signal_proof.go @@ -34,7 +34,7 @@ func (p *Prover) EncodedSignalProof( } signalProof := encoding.SignalProof{ - Header: blockHeader, + Height: blockHeader.Height, Proof: encodedStorageProof, } diff --git a/packages/relayer/proof/encoded_signal_proof_test.go b/packages/relayer/proof/encoded_signal_proof_test.go index f1845faa48e..3d700cbfbe7 100644 --- a/packages/relayer/proof/encoded_signal_proof_test.go +++ b/packages/relayer/proof/encoded_signal_proof_test.go @@ -12,7 +12,7 @@ import ( var ( // nolint: lll - wantEncoded = "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003803a537c89809712367218bb171b3b1c46aa95df3dee7200ae9dc78f40520240681dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934700000000000000000000000000000000000000000000000000000000000000001dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493471dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493471dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000007d000000000000000000000000000000000000000000000000000000000000004d200000000000000000000000000000000000000000000000000000000000003001dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934700000000000000000000000000000000000000000000000013000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000" + wantEncoded = "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000" ) func Test_EncodedSignalProof(t *testing.T) {