Skip to content

Commit 770e0b1

Browse files
feat: add monitor metrics (#262)
Co-authored-by: colinlyguo <[email protected]> Co-authored-by: maskpp <[email protected]> Co-authored-by: HAOYUatHZ <[email protected]> Co-authored-by: Péter Garamvölgyi <[email protected]> refactor(bridge): remove layer1 client in in layer1 relayer constructor (#274) Co-authored-by: vincent <[email protected]> Co-authored-by: HAOYUatHZ <[email protected]> fix: add gas multiplier (#275) feat(libzkp): use dylib instead of staticlib (#266) Co-authored-by: maskpp <[email protected]> Co-authored-by: HAOYUatHZ <[email protected]> Co-authored-by: colin <[email protected]> Co-authored-by: colinlyguo <[email protected]> Revert "fix: add gas multiplier (#275)" (#279) build: add nightly-2022-12-10 rust-related builder image (#282) fix(bridge): compatible with DynamicFeeTxType not supported chain (#280) Co-authored-by: colinlyguo <[email protected]> feat(contract): enable whitelist relayer (#272) Co-authored-by: Péter Garamvölgyi <[email protected]> Co-authored-by: HAOYUatHZ <[email protected]> perf(bridge): execute relayer loops independently (#258) Co-authored-by: colin <[email protected]> Co-authored-by: HAOYUatHZ <[email protected]> feat(bridge): confirm block based on "safe" and "finalized" tags (#265) feat: allow to override L2 deployment when address is provided (#293) feat(contracts): Add fee vault (#223) feat(confirmations): Upgrade confirm (#291) feat(coordinator): Enable set ws compression level. (#292) feat(roller&coordinator): upgrade lizkp to zkevm-0215 version (#281) Co-authored-by: HAOYUatHZ <[email protected]> Co-authored-by: HAOYUatHZ <[email protected]> Co-authored-by: xinran chen <[email protected]> Co-authored-by: Ubuntu <[email protected]> build: update version to `alpha-v1.0` (#301) feat: import genesis batch during startup (#299) Co-authored-by: HAOYUatHZ <[email protected]> feat(contracts): new bridge contracts (#288) Co-authored-by: Haichen Shen <[email protected]> Co-authored-by: Thegaram <[email protected]> Co-authored-by: colin <[email protected]> chore: upgrade l2geth dependency for trace type (#304) feat(bridge): update the watcher and relayer based on the new contract (#305) Co-authored-by: colinlyguo <[email protected]> Co-authored-by: zimpha <[email protected]> Co-authored-by: HAOYUatHZ <[email protected]> Co-authored-by: HAOYUatHZ <[email protected]> fix incorrect block order during batch recovery (#311) fix(bridge): fix batch proposer (#312) Co-authored-by: HAOYUatHZ <[email protected]> Co-authored-by: Péter Garamvölgyi <[email protected]> fix: Flush buffered writer (#314) fix(config): fix typos (#315) feat(bridge): only update gas price oracle for exceeding diff threshold (#319) fix(bridge): fix typos (#321) feat(batch proposer): add time limit to commit batches (#323) fix(db): fix `SetMaxOpenConns` (#328) Fix(zkevm): fix zkevm bug for goerli. (#334) fix(build): jenkinsfile tag job optimized and fix (#331) Co-authored-by: vincent <[email protected]> Co-authored-by: HAOYUatHZ <[email protected]> fix: reduce finalize batch tx frequency (#332) alpha inegration with multibin fix makefile fix lint fix lint try fix commit op fix lint goimports trigger ci bugfix(libzkp): fix difficulty (#343) fix(contract): forbid to call message queue and l2 messenger from l1 (#341) Co-authored-by: HAOYUatHZ <[email protected]> fix(roller): fix stack bug (#320) Co-authored-by: HAOYUatHZ <[email protected]>
1 parent c9c148c commit 770e0b1

File tree

132 files changed

+5594
-3452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+5594
-3452
lines changed

.github/workflows/bridge.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ on:
55
branches:
66
- main
77
- staging
8+
- alpha
89
paths:
910
- 'bridge/**'
1011
- '.github/workflows/bridge.yml'
1112
pull_request:
1213
branches:
1314
- main
1415
- staging
16+
- alpha
1517
paths:
1618
- 'bridge/**'
1719
- '.github/workflows/bridge.yml'

.github/workflows/common.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ on:
55
branches:
66
- main
77
- staging
8+
- alpha
89
paths:
910
- 'common/**'
1011
- '.github/workflows/common.yml'
1112
pull_request:
1213
branches:
1314
- main
1415
- staging
16+
- alpha
1517
paths:
1618
- 'common/**'
1719
- '.github/workflows/common.yml'

.github/workflows/contracts.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- prod
99
- release/*
1010
- staging
11+
- alpha
1112
paths:
1213
- 'contracts/**'
1314
- '.github/workflows/contracts.yaml'
@@ -18,6 +19,7 @@ on:
1819
- prod
1920
- release/*
2021
- staging
22+
- alpha
2123
paths:
2224
- 'contracts/**'
2325
- '.github/workflows/contracts.yaml'

.github/workflows/coordinator.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ on:
55
branches:
66
- main
77
- staging
8+
- alpha
89
paths:
910
- 'coordinator/**'
1011
- '.github/workflows/coordinator.yml'
1112
pull_request:
1213
branches:
1314
- main
1415
- staging
16+
- alpha
1517
paths:
1618
- 'coordinator/**'
1719
- '.github/workflows/coordinator.yml'

.github/workflows/database.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ on:
55
branches:
66
- main
77
- staging
8+
- alpha
89
paths:
910
- 'database/**'
1011
- '.github/workflows/database.yml'
1112
pull_request:
1213
branches:
1314
- main
1415
- staging
16+
- alpha
1517
paths:
1618
- 'database/**'
1719
- '.github/workflows/database.yml'

.github/workflows/roller.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ on:
55
branches:
66
- main
77
- staging
8+
- alpha
89
paths:
910
- 'roller/**'
1011
- '.github/workflows/roller.yml'
1112
pull_request:
1213
branches:
1314
- main
1415
- staging
16+
- alpha
1517
paths:
1618
- 'roller/**'
1719
- '.github/workflows/roller.yml'

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pipeline {
2828
}
2929
stage('Check Bridge Compilation') {
3030
steps {
31-
sh 'make -C bridge bridge'
31+
sh 'make -C bridge bridge_bins'
3232
}
3333
}
3434
stage('Check Coordinator Compilation') {

bridge/Makefile

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,23 @@ mock_abi:
88
go run github.com/scroll-tech/go-ethereum/cmd/abigen --sol mock_bridge/MockBridgeL1.sol --pkg mock_bridge --out mock_bridge/MockBridgeL1.go
99
go run github.com/scroll-tech/go-ethereum/cmd/abigen --sol mock_bridge/MockBridgeL2.sol --pkg mock_bridge --out mock_bridge/MockBridgeL2.go
1010

11-
bridge: ## Builds the Bridge instance.
12-
go build -o $(PWD)/build/bin/bridge ./cmd
11+
bridge_bins: ## Builds the Bridge bins.
12+
go build -o $(PWD)/build/bin/event_watcher ./cmd/event_watcher/
13+
go build -o $(PWD)/build/bin/batch_proposer ./cmd/batch_proposer/
14+
go build -o $(PWD)/build/bin/message_relayer ./cmd/msg_relayer/
15+
go build -o $(PWD)/build/bin/rollup_relayer ./cmd/rollup_relayer/
16+
17+
event_watcher: ## Builds the event_watcher bin
18+
go build -o $(PWD)/build/bin/event_watcher ./cmd/event_watcher/
19+
20+
batch_proposer: ## Builds the batch_proposer bin
21+
go build -o $(PWD)/build/bin/batch_proposer ./cmd/batch_proposer/
22+
23+
message_relayer: ## Builds the message_relayer bin
24+
go build -o $(PWD)/build/bin/message_relayer ./cmd/msg_relayer/
25+
26+
rollup_relayer: ## Builds the rollup_relayer bin
27+
go build -o $(PWD)/build/bin/rollup_relayer ./cmd/rollup_relayer/
1328

1429
test:
1530
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 $(PWD)/...
@@ -21,7 +36,7 @@ clean: ## Empty out the bin folder
2136
@rm -rf build/bin
2237

2338
docker:
24-
DOCKER_BUILDKIT=1 docker build -t scrolltech/${IMAGE_NAME}:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/bridge.Dockerfile
25-
26-
docker_push:
27-
docker push scrolltech/${IMAGE_NAME}:${IMAGE_VERSION}
39+
DOCKER_BUILDKIT=1 docker build -t scrolltech/batch_proposer:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/batch_proposer.Dockerfile
40+
DOCKER_BUILDKIT=1 docker build -t scrolltech/event_watcher:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/event_watcher.Dockerfile
41+
DOCKER_BUILDKIT=1 docker build -t scrolltech/rollup_relayer:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/rollup_relayer.Dockerfile
42+
DOCKER_BUILDKIT=1 docker build -t scrolltech/msg_relayer:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/msg_relayer.Dockerfile

bridge/abi/bridge_abi.go

Lines changed: 206 additions & 73 deletions
Large diffs are not rendered by default.

bridge/abi/bridge_abi_test.go

Lines changed: 77 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,69 +10,74 @@ import (
1010
bridge_abi "scroll-tech/bridge/abi"
1111
)
1212

13-
func TestPackRelayMessageWithProof(t *testing.T) {
13+
func TestEventSignature(t *testing.T) {
1414
assert := assert.New(t)
1515

16-
l1MessengerABI, err := bridge_abi.L1MessengerMetaData.GetAbi()
16+
assert.Equal(bridge_abi.L1SentMessageEventSignature, common.HexToHash("104371f3b442861a2a7b82a070afbbaab748bb13757bf47769e170e37809ec1e"))
17+
assert.Equal(bridge_abi.L1RelayedMessageEventSignature, common.HexToHash("4641df4a962071e12719d8c8c8e5ac7fc4d97b927346a3d7a335b1f7517e133c"))
18+
assert.Equal(bridge_abi.L1FailedRelayedMessageEventSignature, common.HexToHash("99d0e048484baa1b1540b1367cb128acd7ab2946d1ed91ec10e3c85e4bf51b8f"))
19+
20+
assert.Equal(bridge_abi.L1CommitBatchEventSignature, common.HexToHash("2cdc615c74452778c0fb6184735e014c13aad2b62774fe0b09bd1dcc2cc14a62"))
21+
assert.Equal(bridge_abi.L1FinalizeBatchEventSignature, common.HexToHash("6be443154c959a7a1645b4392b6fa97d8e8ab6e8fd853d7085e8867083737d79"))
22+
23+
assert.Equal(bridge_abi.L1QueueTransactionEventSignature, common.HexToHash("bdcc7517f8fe3db6506dfd910942d0bbecaf3d6a506dadea65b0d988e75b9439"))
24+
25+
assert.Equal(bridge_abi.L2SentMessageEventSignature, common.HexToHash("104371f3b442861a2a7b82a070afbbaab748bb13757bf47769e170e37809ec1e"))
26+
assert.Equal(bridge_abi.L2RelayedMessageEventSignature, common.HexToHash("4641df4a962071e12719d8c8c8e5ac7fc4d97b927346a3d7a335b1f7517e133c"))
27+
assert.Equal(bridge_abi.L2FailedRelayedMessageEventSignature, common.HexToHash("99d0e048484baa1b1540b1367cb128acd7ab2946d1ed91ec10e3c85e4bf51b8f"))
28+
29+
assert.Equal(bridge_abi.L2ImportBlockEventSignature, common.HexToHash("a7823f45e1ee21f9530b77959b57507ad515a14fa9fa24d262ee80e79b2b5745"))
30+
31+
assert.Equal(bridge_abi.L2AppendMessageEventSignature, common.HexToHash("faa617c2d8ce12c62637dbce76efcc18dae60574aa95709bdcedce7e76071693"))
32+
}
33+
34+
func TestPackRelayL2MessageWithProof(t *testing.T) {
35+
assert := assert.New(t)
36+
l1MessengerABI, err := bridge_abi.L1ScrollMessengerMetaData.GetAbi()
1737
assert.NoError(err)
1838

1939
proof := bridge_abi.IL1ScrollMessengerL2MessageProof{
20-
BlockHeight: big.NewInt(0),
21-
BatchIndex: big.NewInt(0),
40+
BatchHash: common.Hash{},
2241
MerkleProof: make([]byte, 0),
2342
}
24-
_, err = l1MessengerABI.Pack("relayMessageWithProof", common.Address{}, common.Address{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), make([]byte, 0), proof)
43+
_, err = l1MessengerABI.Pack("relayMessageWithProof", common.Address{}, common.Address{}, big.NewInt(0), big.NewInt(0), make([]byte, 0), proof)
2544
assert.NoError(err)
2645
}
2746

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

31-
l1RollupABI, err := bridge_abi.RollupMetaData.GetAbi()
50+
scrollChainABI, err := bridge_abi.ScrollChainMetaData.GetAbi()
3251
assert.NoError(err)
3352

34-
txns := make([]bridge_abi.IZKRollupLayer2Transaction, 5)
35-
for i := 0; i < 5; i++ {
36-
txns[i] = bridge_abi.IZKRollupLayer2Transaction{
37-
Caller: common.Address{},
38-
Target: common.Address{},
39-
Nonce: 0,
40-
Gas: 0,
41-
GasPrice: big.NewInt(0),
42-
Value: big.NewInt(0),
43-
Data: make([]byte, 0),
44-
R: big.NewInt(0),
45-
S: big.NewInt(0),
46-
V: 0,
47-
}
53+
header := bridge_abi.IScrollChainBlockContext{
54+
BlockHash: common.Hash{},
55+
ParentHash: common.Hash{},
56+
BlockNumber: 0,
57+
Timestamp: 0,
58+
BaseFee: big.NewInt(0),
59+
GasLimit: 0,
60+
NumTransactions: 0,
61+
NumL1Messages: 0,
4862
}
4963

50-
header := bridge_abi.IZKRollupLayer2BlockHeader{
51-
BlockHash: common.Hash{},
52-
ParentHash: common.Hash{},
53-
BaseFee: big.NewInt(0),
54-
StateRoot: common.Hash{},
55-
BlockHeight: 0,
56-
GasUsed: 0,
57-
Timestamp: 0,
58-
ExtraData: make([]byte, 0),
59-
Txs: txns,
64+
batch := bridge_abi.IScrollChainBatch{
65+
Blocks: []bridge_abi.IScrollChainBlockContext{header},
66+
PrevStateRoot: common.Hash{},
67+
NewStateRoot: common.Hash{},
68+
WithdrawTrieRoot: common.Hash{},
69+
BatchIndex: 0,
70+
L2Transactions: make([]byte, 0),
6071
}
6172

62-
batch := bridge_abi.IZKRollupLayer2Batch{
63-
BatchIndex: 0,
64-
ParentHash: common.Hash{},
65-
Blocks: []bridge_abi.IZKRollupLayer2BlockHeader{header},
66-
}
67-
68-
_, err = l1RollupABI.Pack("commitBatch", batch)
73+
_, err = scrollChainABI.Pack("commitBatch", batch)
6974
assert.NoError(err)
7075
}
7176

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

75-
l1RollupABI, err := bridge_abi.RollupMetaData.GetAbi()
80+
l1RollupABI, err := bridge_abi.ScrollChainMetaData.GetAbi()
7681
assert.NoError(err)
7782

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

89-
func TestPackRelayMessage(t *testing.T) {
94+
func TestPackRelayL1Message(t *testing.T) {
95+
assert := assert.New(t)
96+
97+
l2MessengerABI, err := bridge_abi.L2ScrollMessengerMetaData.GetAbi()
98+
assert.NoError(err)
99+
100+
_, err = l2MessengerABI.Pack("relayMessage", common.Address{}, common.Address{}, big.NewInt(0), big.NewInt(0), make([]byte, 0))
101+
assert.NoError(err)
102+
}
103+
104+
func TestPackSetL1BaseFee(t *testing.T) {
90105
assert := assert.New(t)
91106

92-
l2MessengerABI, err := bridge_abi.L2MessengerMetaData.GetAbi()
107+
l1GasOracleABI, err := bridge_abi.L1GasPriceOracleMetaData.GetAbi()
108+
assert.NoError(err)
109+
110+
baseFee := big.NewInt(2333)
111+
_, err = l1GasOracleABI.Pack("setL1BaseFee", baseFee)
93112
assert.NoError(err)
113+
}
114+
115+
func TestPackSetL2BaseFee(t *testing.T) {
116+
assert := assert.New(t)
117+
118+
l2GasOracleABI, err := bridge_abi.L2GasPriceOracleMetaData.GetAbi()
119+
assert.NoError(err)
120+
121+
baseFee := big.NewInt(2333)
122+
_, err = l2GasOracleABI.Pack("setL2BaseFee", baseFee)
123+
assert.NoError(err)
124+
}
125+
126+
func TestPackImportBlock(t *testing.T) {
127+
assert := assert.New(t)
128+
129+
l1BlockContainerABI := bridge_abi.L1BlockContainerABI
94130

95-
_, err = l2MessengerABI.Pack("relayMessage", common.Address{}, common.Address{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), make([]byte, 0))
131+
_, err := l1BlockContainerABI.Pack("importBlockHeader", common.Hash{}, make([]byte, 0), false)
96132
assert.NoError(err)
97133
}

0 commit comments

Comments
 (0)