Skip to content
This repository was archived by the owner on May 11, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 66b631a

Browse files
authoredOct 21, 2022
[driver] check throwaway blocks builder's balance when starting (#17)
* [driver] check throwaway blocks builder's balance when starting * test: fix workflow errors * chore: update go.mod
1 parent a159c03 commit 66b631a

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed
 

‎driver/driver.go

+12
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ package driver
22

33
import (
44
"context"
5+
"fmt"
56
"sync"
67
"time"
78

89
"github.com/cenkalti/backoff/v4"
10+
"github.com/ethereum/go-ethereum/common"
911
"github.com/ethereum/go-ethereum/core/types"
12+
"github.com/ethereum/go-ethereum/crypto"
1013
"github.com/ethereum/go-ethereum/event"
1114
"github.com/ethereum/go-ethereum/log"
1215
"github.com/taikochain/taiko-client/pkg/rpc"
@@ -70,6 +73,15 @@ func initFromConfig(d *Driver, cfg *Config) (err error) {
7073
return err
7174
}
7275

76+
balance, err := d.rpc.L2.BalanceAt(d.ctx, crypto.PubkeyToAddress(cfg.ThrowawayBlocksBuilderPrivKey.PublicKey), nil)
77+
if err != nil {
78+
return fmt.Errorf("failed to get throwaway blocks builder balance: %w", err)
79+
}
80+
81+
if balance.Cmp(common.Big0) == 0 {
82+
return fmt.Errorf("throwaway blocks builder has no fund")
83+
}
84+
7385
if d.l2ChainInserter, err = NewL2ChainInserter(
7486
d.ctx,
7587
d.rpc,

‎driver/driver_test.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"testing"
77

88
"github.com/ethereum/go-ethereum/common"
9+
"github.com/ethereum/go-ethereum/crypto"
910
"github.com/ethereum/go-ethereum/log"
1011
"github.com/stretchr/testify/require"
1112
"github.com/taikochain/taiko-client/pkg/jwt"
@@ -26,14 +27,20 @@ func newTestDriver(t *testing.T) *Driver {
2627
require.Nil(t, err)
2728
require.NotEmpty(t, jwtSecret)
2829

30+
throwawayBlocksBuilderPrivKey, err := crypto.ToECDSA(
31+
common.Hex2Bytes(os.Getenv("THROWAWAY_BLOCKS_BUILDER_PRIV_KEY")),
32+
)
33+
require.Nil(t, err)
34+
2935
d := new(Driver)
3036

3137
require.Nil(t, initFromConfig(d, &Config{
32-
L1Endpoint: os.Getenv("L1_NODE_ENDPOINT"),
33-
L2Endpoint: os.Getenv("L2_NODE_ENDPOINT"),
34-
L2EngineEndpoint: os.Getenv("L2_NODE_ENGINE_ENDPOINT"),
35-
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
36-
JwtSecret: string(jwtSecret),
38+
L1Endpoint: os.Getenv("L1_NODE_ENDPOINT"),
39+
L2Endpoint: os.Getenv("L2_NODE_ENDPOINT"),
40+
L2EngineEndpoint: os.Getenv("L2_NODE_ENGINE_ENDPOINT"),
41+
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
42+
ThrowawayBlocksBuilderPrivKey: throwawayBlocksBuilderPrivKey,
43+
JwtSecret: string(jwtSecret),
3744
}))
3845

3946
return d

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ require (
5757
gopkg.in/yaml.v3 v3.0.1 // indirect
5858
)
5959

60-
replace github.com/ethereum/go-ethereum v1.10.25 => github.com/taikochain/taiko-geth v0.0.0-20221019033350-df3ec74ee5ab
60+
replace github.com/ethereum/go-ethereum v1.10.25 => github.com/taikochain/taiko-geth v0.0.0-20221021074701-4c4eb85222e2

‎go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK
173173
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
174174
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI=
175175
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
176-
github.com/taikochain/taiko-geth v0.0.0-20221019033350-df3ec74ee5ab h1:FlXVshOHKNE7Otj0FmvJCIcKoeHsFDIFpQ4SgCPtIe0=
177-
github.com/taikochain/taiko-geth v0.0.0-20221019033350-df3ec74ee5ab/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
176+
github.com/taikochain/taiko-geth v0.0.0-20221021074701-4c4eb85222e2 h1:EnwckffcSsTIeFZgOCR2ZHRCnOr1kfEjsjHYU9SLiD0=
177+
github.com/taikochain/taiko-geth v0.0.0-20221021074701-4c4eb85222e2/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
178178
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e h1:cR8/SYRgyQCt5cNCMniB/ZScMkhI9nk8U5C7SbISXjo=
179179
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e/go.mod h1:Tu4lItkATkonrYuvtVjG0/rhy15qrNGNTjPdaphtZ/8=
180180
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=

‎integration_test/entrypoint.sh

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ if [ "$RUN_TESTS" == "true" ]; then
4444
L1_PROPOSER_PRIVATE_KEY=2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200 \
4545
L2_SUGGESTED_FEE_RECIPIENT=0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39 \
4646
L1_PROVER_PRIVATE_KEY=2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200 \
47+
THROWAWAY_BLOCKS_BUILDER_PRIV_KEY=2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200 \
4748
JWT_SECRET=$DIR/testnet/jwt.hex \
4849
go test -v ./...
4950
else

0 commit comments

Comments
 (0)
This repository has been archived.