Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(relayer): catch relayer message processing up to latest protocol changes #13746

Merged
merged 2 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 3 additions & 58 deletions packages/relayer/encoding/signal_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
78 changes: 4 additions & 74 deletions packages/relayer/encoding/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/relayer/proof/encoded_signal_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (p *Prover) EncodedSignalProof(
}

signalProof := encoding.SignalProof{
Header: blockHeader,
Height: blockHeader.Height,
Proof: encodedStorageProof,
}

Expand Down