Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
ebcf120
apply all relayer changes to latest alpha branch
icemelon Feb 20, 2023
30a5b6a
trigger ci
colinlyguo Feb 21, 2023
35cf194
update txID hash
colinlyguo Feb 21, 2023
d494369
refine the batch proposer send tx
icemelon Feb 21, 2023
86e9026
trigger ci
colinlyguo Feb 21, 2023
0d40671
update event watcher
colinlyguo Feb 21, 2023
b0b0920
fix event watcher
colinlyguo Feb 21, 2023
d663d05
fix typo
colinlyguo Feb 21, 2023
2ea2175
recover docker build test
colinlyguo Feb 21, 2023
62c9104
trigger ci
colinlyguo Feb 21, 2023
7985f2d
add more functions/events to mock bridge contracts
zimpha Feb 21, 2023
6465d1d
update GetBatchCalldataLengt
colinlyguo Feb 21, 2023
eeff892
handle nil basefee case
icemelon Feb 21, 2023
7b70ae7
simplify the genesis batch creation
icemelon Feb 21, 2023
7045b4f
add message hash computation; refactor abi and watcher
zimpha Feb 21, 2023
033af1f
fix rollup test
zimpha Feb 21, 2023
9d97d05
update GetBatchCalldataLength
colinlyguo Feb 21, 2023
cd110fb
tweak header
colinlyguo Feb 21, 2023
fc3a4e3
tweak
colinlyguo Feb 21, 2023
1314f14
add unit tests for relay l2 message and gas price
zimpha Feb 21, 2023
9b12942
tweak
colinlyguo Feb 21, 2023
d8c63de
upgrade Dockerfile geth version
colinlyguo Feb 21, 2023
66ebbe5
fix testImportL1GasPrice
zimpha Feb 21, 2023
a5d86bb
chore: go work sync && go lint && go import
colinlyguo Feb 21, 2023
1f148f6
recover TestComputeMessageHash
colinlyguo Feb 21, 2023
5b1ba43
comment out Check Coordinator Compilation
colinlyguo Feb 21, 2023
b55dfe1
comment out Coordinator Docker Build
colinlyguo Feb 21, 2023
5d90009
add testBatchProposer
colinlyguo Feb 21, 2023
00d2572
temporarily comment out coordinator tests
colinlyguo Feb 21, 2023
ff2edca
comment out more
colinlyguo Feb 21, 2023
3668af3
fix coordinator build (#309)
0xmountaintop Feb 21, 2023
e494d05
fixes
colinlyguo Feb 21, 2023
d38627c
fix CI
colinlyguo Feb 21, 2023
5273713
add testBatchProposerGracefulRestart
colinlyguo Feb 21, 2023
12def8f
add extra checks in the batch proposer graceful restart
icemelon Feb 21, 2023
089d343
change id to hash
colinlyguo Feb 21, 2023
95d0355
tweak
icemelon Feb 21, 2023
2f4596f
change id to hash
colinlyguo Feb 21, 2023
da77ac1
remove some comments
colinlyguo Feb 21, 2023
cd1a8fc
fix goimport
colinlyguo Feb 21, 2023
81b09cb
tweak proposeBatch
colinlyguo Feb 21, 2023
4709664
remove obsolete map from L2relayer
icemelon Feb 21, 2023
62639e6
add genesis batch hash test
icemelon Feb 21, 2023
343e747
update the configs
icemelon Feb 21, 2023
83d9b0c
address comments
icemelon Feb 21, 2023
144572b
update db API names and fix comments
icemelon Feb 22, 2023
8d23a8f
make block proposer a standalone client
icemelon Feb 22, 2023
1167b20
fix some test case
icemelon Feb 22, 2023
0737362
SetBatchHashForL2Blocks in bridge tests
zimpha Feb 22, 2023
63db0ab
fix testL2RelayerProcessSaveEvents
colinlyguo Feb 22, 2023
5f3c8dc
try test other unit tests
colinlyguo Feb 22, 2023
e7a3b51
trigger ci
colinlyguo Feb 22, 2023
d670574
remove unused defer stop
zimpha Feb 22, 2023
8f0b308
trigger CI
colinlyguo Feb 22, 2023
3d0cb59
trigger CI for alpha
0xmountaintop Feb 22, 2023
aa8e87d
fix CI
colinlyguo Feb 22, 2023
85e26c0
add todos and parallelize l1 relayer ProcessSavedEvents & ProcessGasP…
colinlyguo Feb 22, 2023
cf40468
trigger ci
colinlyguo Feb 22, 2023
f8e52d7
add batchDataBufferSizeLimit
colinlyguo Feb 22, 2023
44f1d0b
fix assume in fuzzing tests
colinlyguo Feb 22, 2023
eaf1e84
bump version && decrease loop time && parallelize l1 watcher event
colinlyguo Feb 22, 2023
219bb82
trigger ci
colinlyguo Feb 22, 2023
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
2 changes: 2 additions & 0 deletions .github/workflows/bridge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ on:
branches:
- main
- staging
- alpha
paths:
- 'bridge/**'
- '.github/workflows/bridge.yml'
pull_request:
branches:
- main
- staging
- alpha
paths:
- 'bridge/**'
- '.github/workflows/bridge.yml'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ on:
branches:
- main
- staging
- alpha
paths:
- 'common/**'
- '.github/workflows/common.yml'
pull_request:
branches:
- main
- staging
- alpha
paths:
- 'common/**'
- '.github/workflows/common.yml'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- prod
- release/*
- staging
- alpha
paths:
- 'contracts/**'
- '.github/workflows/contracts.yaml'
Expand All @@ -18,6 +19,7 @@ on:
- prod
- release/*
- staging
- alpha
paths:
- 'contracts/**'
- '.github/workflows/contracts.yaml'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/coordinator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ on:
branches:
- main
- staging
- alpha
paths:
- 'coordinator/**'
- '.github/workflows/coordinator.yml'
pull_request:
branches:
- main
- staging
- alpha
paths:
- 'coordinator/**'
- '.github/workflows/coordinator.yml'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ on:
branches:
- main
- staging
- alpha
paths:
- 'database/**'
- '.github/workflows/database.yml'
pull_request:
branches:
- main
- staging
- alpha
paths:
- 'database/**'
- '.github/workflows/database.yml'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/roller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ on:
branches:
- main
- staging
- alpha
paths:
- 'roller/**'
- '.github/workflows/roller.yml'
pull_request:
branches:
- main
- staging
- alpha
paths:
- 'roller/**'
- '.github/workflows/roller.yml'
Expand Down
279 changes: 206 additions & 73 deletions bridge/abi/bridge_abi.go

Large diffs are not rendered by default.

118 changes: 77 additions & 41 deletions bridge/abi/bridge_abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,74 @@ import (
bridge_abi "scroll-tech/bridge/abi"
)

func TestPackRelayMessageWithProof(t *testing.T) {
func TestEventSignature(t *testing.T) {
assert := assert.New(t)

l1MessengerABI, err := bridge_abi.L1MessengerMetaData.GetAbi()
assert.Equal(bridge_abi.L1SentMessageEventSignature, common.HexToHash("104371f3b442861a2a7b82a070afbbaab748bb13757bf47769e170e37809ec1e"))
assert.Equal(bridge_abi.L1RelayedMessageEventSignature, common.HexToHash("4641df4a962071e12719d8c8c8e5ac7fc4d97b927346a3d7a335b1f7517e133c"))
assert.Equal(bridge_abi.L1FailedRelayedMessageEventSignature, common.HexToHash("99d0e048484baa1b1540b1367cb128acd7ab2946d1ed91ec10e3c85e4bf51b8f"))

assert.Equal(bridge_abi.L1CommitBatchEventSignature, common.HexToHash("2cdc615c74452778c0fb6184735e014c13aad2b62774fe0b09bd1dcc2cc14a62"))
assert.Equal(bridge_abi.L1FinalizeBatchEventSignature, common.HexToHash("6be443154c959a7a1645b4392b6fa97d8e8ab6e8fd853d7085e8867083737d79"))

assert.Equal(bridge_abi.L1QueueTransactionEventSignature, common.HexToHash("bdcc7517f8fe3db6506dfd910942d0bbecaf3d6a506dadea65b0d988e75b9439"))

assert.Equal(bridge_abi.L2SentMessageEventSignature, common.HexToHash("104371f3b442861a2a7b82a070afbbaab748bb13757bf47769e170e37809ec1e"))
assert.Equal(bridge_abi.L2RelayedMessageEventSignature, common.HexToHash("4641df4a962071e12719d8c8c8e5ac7fc4d97b927346a3d7a335b1f7517e133c"))
assert.Equal(bridge_abi.L2FailedRelayedMessageEventSignature, common.HexToHash("99d0e048484baa1b1540b1367cb128acd7ab2946d1ed91ec10e3c85e4bf51b8f"))

assert.Equal(bridge_abi.L2ImportBlockEventSignature, common.HexToHash("a7823f45e1ee21f9530b77959b57507ad515a14fa9fa24d262ee80e79b2b5745"))

assert.Equal(bridge_abi.L2AppendMessageEventSignature, common.HexToHash("faa617c2d8ce12c62637dbce76efcc18dae60574aa95709bdcedce7e76071693"))
}

func TestPackRelayL2MessageWithProof(t *testing.T) {
assert := assert.New(t)
l1MessengerABI, err := bridge_abi.L1ScrollMessengerMetaData.GetAbi()
assert.NoError(err)

proof := bridge_abi.IL1ScrollMessengerL2MessageProof{
BlockHeight: big.NewInt(0),
BatchIndex: big.NewInt(0),
BatchHash: common.Hash{},
MerkleProof: make([]byte, 0),
}
_, err = l1MessengerABI.Pack("relayMessageWithProof", common.Address{}, common.Address{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), make([]byte, 0), proof)
_, err = l1MessengerABI.Pack("relayMessageWithProof", common.Address{}, common.Address{}, big.NewInt(0), big.NewInt(0), make([]byte, 0), proof)
assert.NoError(err)
}

func TestPackCommitBatch(t *testing.T) {
assert := assert.New(t)

l1RollupABI, err := bridge_abi.RollupMetaData.GetAbi()
scrollChainABI, err := bridge_abi.ScrollChainMetaData.GetAbi()
assert.NoError(err)

txns := make([]bridge_abi.IZKRollupLayer2Transaction, 5)
for i := 0; i < 5; i++ {
txns[i] = bridge_abi.IZKRollupLayer2Transaction{
Caller: common.Address{},
Target: common.Address{},
Nonce: 0,
Gas: 0,
GasPrice: big.NewInt(0),
Value: big.NewInt(0),
Data: make([]byte, 0),
R: big.NewInt(0),
S: big.NewInt(0),
V: 0,
}
header := bridge_abi.IScrollChainBlockContext{
BlockHash: common.Hash{},
ParentHash: common.Hash{},
BlockNumber: 0,
Timestamp: 0,
BaseFee: big.NewInt(0),
GasLimit: 0,
NumTransactions: 0,
NumL1Messages: 0,
}

header := bridge_abi.IZKRollupLayer2BlockHeader{
BlockHash: common.Hash{},
ParentHash: common.Hash{},
BaseFee: big.NewInt(0),
StateRoot: common.Hash{},
BlockHeight: 0,
GasUsed: 0,
Timestamp: 0,
ExtraData: make([]byte, 0),
Txs: txns,
batch := bridge_abi.IScrollChainBatch{
Blocks: []bridge_abi.IScrollChainBlockContext{header},
PrevStateRoot: common.Hash{},
NewStateRoot: common.Hash{},
WithdrawTrieRoot: common.Hash{},
BatchIndex: 0,
L2Transactions: make([]byte, 0),
}

batch := bridge_abi.IZKRollupLayer2Batch{
BatchIndex: 0,
ParentHash: common.Hash{},
Blocks: []bridge_abi.IZKRollupLayer2BlockHeader{header},
}

_, err = l1RollupABI.Pack("commitBatch", batch)
_, err = scrollChainABI.Pack("commitBatch", batch)
assert.NoError(err)
}

func TestPackFinalizeBatchWithProof(t *testing.T) {
assert := assert.New(t)

l1RollupABI, err := bridge_abi.RollupMetaData.GetAbi()
l1RollupABI, err := bridge_abi.ScrollChainMetaData.GetAbi()
assert.NoError(err)

proof := make([]*big.Int, 10)
Expand All @@ -86,12 +91,43 @@ func TestPackFinalizeBatchWithProof(t *testing.T) {
assert.NoError(err)
}

func TestPackRelayMessage(t *testing.T) {
func TestPackRelayL1Message(t *testing.T) {
assert := assert.New(t)

l2MessengerABI, err := bridge_abi.L2ScrollMessengerMetaData.GetAbi()
assert.NoError(err)

_, err = l2MessengerABI.Pack("relayMessage", common.Address{}, common.Address{}, big.NewInt(0), big.NewInt(0), make([]byte, 0))
assert.NoError(err)
}

func TestPackSetL1BaseFee(t *testing.T) {
assert := assert.New(t)

l2MessengerABI, err := bridge_abi.L2MessengerMetaData.GetAbi()
l1GasOracleABI, err := bridge_abi.L1GasPriceOracleMetaData.GetAbi()
assert.NoError(err)

baseFee := big.NewInt(2333)
_, err = l1GasOracleABI.Pack("setL1BaseFee", baseFee)
assert.NoError(err)
}

func TestPackSetL2BaseFee(t *testing.T) {
assert := assert.New(t)

l2GasOracleABI, err := bridge_abi.L2GasPriceOracleMetaData.GetAbi()
assert.NoError(err)

baseFee := big.NewInt(2333)
_, err = l2GasOracleABI.Pack("setL2BaseFee", baseFee)
assert.NoError(err)
}

func TestPackImportBlock(t *testing.T) {
assert := assert.New(t)

l1BlockContainerABI := bridge_abi.L1BlockContainerABI

_, err = l2MessengerABI.Pack("relayMessage", common.Address{}, common.Address{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), make([]byte, 0))
_, err := l1BlockContainerABI.Pack("importBlockHeader", common.Hash{}, make([]byte, 0), false)
assert.NoError(err)
}
27 changes: 19 additions & 8 deletions bridge/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
"confirmations": "0x6",
"endpoint": "https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",
"l1_messenger_address": "0x0000000000000000000000000000000000000000",
"rollup_contract_address": "0x0000000000000000000000000000000000000000",
"l1_message_queue_address": "0x0000000000000000000000000000000000000000",
"scroll_chain_address": "0x0000000000000000000000000000000000000000",
"start_height": 0,
"relayer_config": {
"messenger_contract_address": "0x0000000000000000000000000000000000000000",
"gas_price_oracle_address": "0x0000000000000000000000000000000000000000",
"sender_config": {
"endpoint": "/var/lib/jenkins/workspace/SequencerPipeline/MyPrivateNetwork/geth.ipc",
"check_pending_time": 3,
"check_pending_time": 2,
"escalate_blocks": 100,
"confirmations": "0x1",
"escalate_multiple_num": 11,
Expand All @@ -20,16 +22,21 @@
},
"message_sender_private_keys": [
"1212121212121212121212121212121212121212121212121212121212121212"
],
"gas_oracle_sender_private_keys": [
"1212121212121212121212121212121212121212121212121212121212121212"
]
}
},
"l2_config": {
"confirmations": "0x1",
"endpoint": "/var/lib/jenkins/workspace/SequencerPipeline/MyPrivateNetwork/geth.ipc",
"l2_messenger_address": "0x0000000000000000000000000000000000000000",
"l2_message_queue_address": "0x0000000000000000000000000000000000000000",
"relayer_config": {
"rollup_contract_address": "0x0000000000000000000000000000000000000000",
"messenger_contract_address": "0x0000000000000000000000000000000000000000",
"gas_price_oracle_address": "0x0000000000000000000000000000000000000000",
"sender_config": {
"endpoint": "https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",
"check_pending_time": 10,
Expand All @@ -44,24 +51,28 @@
"message_sender_private_keys": [
"1212121212121212121212121212121212121212121212121212121212121212"
],
"gas_oracle_sender_private_keys": [
"1212121212121212121212121212121212121212121212121212121212121212"
],
"rollup_sender_private_keys": [
"1212121212121212121212121212121212121212121212121212121212121212"
]
},
"batch_proposer_config": {
"proof_generation_freq": 1,
"batch_gas_threshold": 3000000,
"batch_tx_num_threshold": 135,
"batch_tx_num_threshold": 44,
"batch_time_sec": 300,
"batch_blocks_limit": 100,
"skipped_opcodes": [
"CREATE2",
"DELEGATECALL"
]
"commit_tx_calldata_size_limit": 200000,
"public_input_config": {
"max_tx_num": 44,
"padding_tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
}
},
"db_config": {
"driver_name": "postgres",
"dsn": "postgres://admin:123456@localhost/test?sslmode=disable"
}
}
}
8 changes: 3 additions & 5 deletions bridge/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ func TestConfig(t *testing.T) {
cfg, err := config.NewConfig("../config.json")
assert.True(t, assert.NoError(t, err), "failed to load config")

assert.True(t, len(cfg.L2Config.BatchProposerConfig.SkippedOpcodes) > 0)

assert.True(t, len(cfg.L1Config.RelayerConfig.MessageSenderPrivateKeys) > 0)
assert.True(t, len(cfg.L2Config.RelayerConfig.MessageSenderPrivateKeys) > 0)
assert.True(t, len(cfg.L2Config.RelayerConfig.RollupSenderPrivateKeys) > 0)
assert.Equal(t, 1, len(cfg.L1Config.RelayerConfig.MessageSenderPrivateKeys))
assert.Equal(t, 1, len(cfg.L2Config.RelayerConfig.MessageSenderPrivateKeys))
assert.Equal(t, 1, len(cfg.L2Config.RelayerConfig.RollupSenderPrivateKeys))

data, err := json.Marshal(cfg)
assert.NoError(t, err)
Expand Down
8 changes: 5 additions & 3 deletions bridge/config/l1_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ type L1Config struct {
Endpoint string `json:"endpoint"`
// The start height to sync event from layer 1
StartHeight uint64 `json:"start_height"`
// The messenger contract address deployed on layer 1 chain.
// The L1ScrollMessenger contract address deployed on layer 1 chain.
L1MessengerAddress common.Address `json:"l1_messenger_address"`
// The rollup contract address deployed on layer 1 chain.
RollupContractAddress common.Address `json:"rollup_contract_address"`
// The L1MessageQueue contract address deployed on layer 1 chain.
L1MessageQueueAddress common.Address `json:"l1_message_queue_address"`
// The ScrollChain contract address deployed on layer 1 chain.
ScrollChainContractAddress common.Address `json:"scroll_chain_address"`
// The relayer config
RelayerConfig *RelayerConfig `json:"relayer_config"`
}
Loading