Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

feat(prover): Pos impl #292

Merged
merged 46 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8d1262c
PoS wip
cyberhorsey Jun 16, 2023
b8345d3
comment out testlines that cant pass until protocol is impl
cyberhorsey Jun 16, 2023
a3539e6
rm errNeedsWaiting
cyberhorsey Jun 16, 2023
89ba90a
update bindings
cyberhorsey Jun 16, 2023
9b4b2a3
test changs, add taiko prover pool / taiko token addresses, taiko tok…
cyberhorsey Jun 19, 2023
6096a5f
lint
cyberhorsey Jun 19, 2023
6bbf493
Merge branch 'main' into pos_impl
cyberhorsey Jun 19, 2023
a309a09
Merge branch 'main' into pos_impl
cyberhorsey Jun 26, 2023
57e127b
merge main, + update implementation to alpha-4-base branch, + valid p…
cyberhorsey Jun 26, 2023
67d181f
Merge branch 'pos_impl' of github.com:taikochain/taiko-client into po…
cyberhorsey Jun 26, 2023
e9ea294
zero address means its proveable
cyberhorsey Jun 26, 2023
4dbaa85
regenerate bindings with proofWindow, plus have a watcher for blockId…
cyberhorsey Jun 27, 2023
941e026
rm test log
cyberhorsey Jun 27, 2023
ad73506
Merge branch 'main' into pos_impl
cyberhorsey Jun 27, 2023
6f3cc2b
lint
cyberhorsey Jun 27, 2023
de2f960
Merge branch 'pos_impl' of github.com:taikochain/taiko-client into po…
cyberhorsey Jun 27, 2023
b0482b4
base branch
cyberhorsey Jun 27, 2023
6dedef4
slice instead of map
cyberhorsey Jun 27, 2023
cec0e02
Merge branch 'main' into pos_impl
cyberhorsey Jun 28, 2023
71b037a
git ref update
cyberhorsey Jun 28, 2023
5d31285
Merge branch 'pos_impl' of github.com:taikochain/taiko-client into po…
cyberhorsey Jun 28, 2023
f4954b8
catch up to prover pool1 changes
cyberhorsey Jun 28, 2023
9ea0a45
account for tko amoutn switch
cyberhorsey Jun 29, 2023
f1e861d
test fix
cyberhorsey Jun 29, 2023
7cfa09a
watch slashed event
cyberhorsey Jun 30, 2023
ef2ad5d
use git ref thats buildable
cyberhorsey Jun 30, 2023
b8011c0
dummy proof must be 32 bytes now as protocol relies on that
cyberhorsey Jun 30, 2023
ce83688
merge main, plus remove some other fields
cyberhorsey Jun 30, 2023
fbbece5
refh ead
cyberhorsey Jun 30, 2023
bf8640d
expectedreward
cyberhorsey Jun 30, 2023
a4a780d
dont need to check neednewproof
cyberhorsey Jun 30, 2023
cda9c82
chore: update ci
davidtaikocha Jul 1, 2023
85a530c
taiko1laddress in proposer is unused now due to PoS impl change
cyberhorsey Jul 1, 2023
2e3e8c7
taikoTokenL1 uses premint in deployonl1 script now
cyberhorsey Jul 1, 2023
79b8410
premint amts
cyberhorsey Jul 1, 2023
63fd38c
Merge branch 'pos_impl' of github.com:taikochain/taiko-client into po…
cyberhorsey Jul 1, 2023
f8ffffd
interval to check profo window is a flag
cyberhorsey Jul 1, 2023
0dc06f8
test
cyberhorsey Jul 1, 2023
2f47261
test
cyberhorsey Jul 1, 2023
0007fea
remove bindigns for ttko
cyberhorsey Jul 1, 2023
9bc0706
lints
cyberhorsey Jul 1, 2023
ed8db96
rm taikoTokenl1 from config in proposer now
cyberhorsey Jul 1, 2023
12d82b1
test
cyberhorsey Jul 1, 2023
2ee922a
feat: update `OracleProverAddress`
davidtaikocha Jul 2, 2023
c31995e
feat: update ci
davidtaikocha Jul 2, 2023
561087b
chore: update ci
davidtaikocha Jul 3, 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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
with:
repository: taikoxyz/taiko-mono
path: ${{ env.TAIKO_MONO_DIR }}
ref: alpha-4

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9d7bc39c282c6ceb0e62146aa6271d5ceaee7633
c133bdd2bee6192bab2531f8463100c778c71820
1 change: 0 additions & 1 deletion bindings/encoding/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

var (
OracleProverAddress = common.HexToAddress("0x0000000000000000000000000000000000000000")
SystemProverAddress = common.HexToAddress("0x0000000000000000000000000000000000000001")
)

type BlockHeader struct {
Expand Down
440 changes: 195 additions & 245 deletions bindings/gen_taiko_l1.go

Large diffs are not rendered by default.

1,982 changes: 1,982 additions & 0 deletions bindings/gen_taiko_prover_pool_l1.go

Large diffs are not rendered by default.

2,946 changes: 2,946 additions & 0 deletions bindings/gen_taiko_token_l1.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ var (
Required: true,
Category: proposerCategory,
}
L1TaikoTokenAddress = &cli.StringFlag{
cyberhorsey marked this conversation as resolved.
Show resolved Hide resolved
Name: "l1.taikoTokenAddress",
Usage: "Address of the taiko token L1 contract",
Required: true,
Category: proposerCategory,
}
)

// Optional flags used by proposer.
Expand Down
24 changes: 6 additions & 18 deletions cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,22 @@ var (
Usage: "Set whether prover should use oracle prover or not",
Category: proverCategory,
}
SystemProver = &cli.BoolFlag{
Name: "systemProver",
Usage: "Set whether prover should use system prover or not",
Category: proverCategory,
}
OracleProverPrivateKey = &cli.StringFlag{
Name: "oracleProverPrivateKey",
Usage: "Private key of oracle prover",
Category: proverCategory,
}
SystemProverPrivateKey = &cli.StringFlag{
Name: "systemProverPrivateKey",
Usage: "Private key of system prover",
Category: proverCategory,
}
Graffiti = &cli.StringFlag{
Name: "graffiti",
Usage: "When string is passed, adds additional graffiti info to proof evidence",
Category: proverCategory,
Value: "",
}
ExpectedReward = &cli.Uint64Flag{
Name: "expectedReward",
Usage: "The expected prover reward for each block",
Category: proverCategory,
Value: 100_000_000,
TaikoProverPoolL1Address = &cli.StringFlag{
Name: "taikoProverPoolL1",
Usage: "TaikoProverPoolL1 contract address",
Required: true,
Category: commonCategory,
}
)

Expand All @@ -100,9 +90,7 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
Dummy,
RandomDummyProofDelay,
OracleProver,
SystemProver,
OracleProverPrivateKey,
SystemProverPrivateKey,
Graffiti,
ExpectedReward,
TaikoProverPoolL1Address,
})
7 changes: 3 additions & 4 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ func NewSyncer(
progressTracker: progressTracker,
anchorConstructor: constructor,
txListValidator: txListValidator.NewTxListValidator(
configs.BlockMaxGasLimit,
configs.MaxTransactionsPerBlock,
configs.MaxBytesPerTxList,
uint64(configs.BlockMaxGasLimit),
configs.BlockMaxTransactions,
configs.BlockMaxTxListBytes,
rpc.L2ChainID,
),
}, nil
Expand Down Expand Up @@ -176,7 +176,6 @@ func (s *Syncer) onBlockProposed(
"L1Height", event.Raw.BlockNumber,
"L1Hash", event.Raw.BlockHash,
"BlockID", event.Id,
"BlockFee", event.BlockFee,
"Removed", event.Raw.Removed,
)

Expand Down
1 change: 1 addition & 0 deletions driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (s *CalldataSyncerTestSuite) SetupTest() {
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
TaikoTokenL1Address: common.HexToAddress(os.Getenv("TAIKO_TOKEN_L1_ADDRESS")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval,
Expand Down
2 changes: 1 addition & 1 deletion driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (d *Driver) reportProtocolStatus() {
return err
}

maxNumBlocks = configs.MaxNumProposedBlocks.Uint64()
maxNumBlocks = configs.BlockMaxProposals.Uint64()
return nil
},
backoff.NewConstantBackOff(d.backOffRetryInterval),
Expand Down
1 change: 1 addition & 0 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (s *DriverTestSuite) SetupTest() {
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
TaikoTokenL1Address: common.HexToAddress(os.Getenv("TAIKO_TOKEN_L1_ADDRESS")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval, // No need to periodically propose transactions list in unit tests
Expand Down
2 changes: 1 addition & 1 deletion driver/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (s *State) startSubscriptions(ctx context.Context) {
case e := <-s.blockProposedCh:
s.setHeadBlockID(e.Id)
case e := <-s.blockProvenCh:
if e.Prover != encoding.SystemProverAddress && e.Prover != encoding.OracleProverAddress {
if e.Prover != encoding.OracleProverAddress {
log.Info("✅ Block proven", "blockID", e.Id, "hash", common.Hash(e.BlockHash), "prover", e.Prover)
}
case e := <-s.blockVerifiedCh:
Expand Down
4 changes: 4 additions & 0 deletions integration_test/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ $DIR/nodes/init.sh

DEPLOYMENT_JSON=$(cat $TAIKO_MONO_DIR/packages/protocol/deployments/deploy_l1.json)
TAIKO_L1_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.taiko' | sed 's/\"//g')
TAIKO_PROVER_POOL_L1_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.prover_pool' | sed 's/\"//g')
TAIKO_TOKEN_L1_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.taiko_token' | sed 's/\"//g')
L1_SIGNAL_SERVICE_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.signal_service' | sed 's/\"//g')

trap "docker compose -f $TESTNET_CONFIG down -v" EXIT INT KILL ERR
Expand All @@ -44,6 +46,8 @@ if [ "$RUN_TESTS" == "true" ]; then
L2_EXECUTION_ENGINE_WS_ENDPOINT=ws://localhost:28546 \
L2_EXECUTION_ENGINE_AUTH_ENDPOINT=http://localhost:28551 \
TAIKO_L1_ADDRESS=$TAIKO_L1_CONTRACT_ADDRESS \
TAIKO_PROVER_POOL_L1_ADDRESS=$TAIKO_PROVER_POOL_L1_CONTRACT_ADDRESS \
TAIKO_TOKEN_L1_ADDRESS=$TAIKO_TOKEN_L1_CONTRACT_ADDRESS \
TAIKO_L2_ADDRESS=0x1000777700000000000000000000000000000001 \
L1_SIGNAL_SERVICE_CONTRACT_ADDRESS=$L1_SIGNAL_SERVICE_CONTRACT_ADDRESS \
L1_CONTRACT_OWNER_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
Expand Down
3 changes: 0 additions & 3 deletions integration_test/nodes/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,17 @@ L2_GENESIS_HASH=$(
# Deploy Taiko protocol.
cd $TAIKO_MONO_DIR/packages/protocol &&
PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
SYSTEM_PROVER=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 \
ORACLE_PROVER=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 \
SOLO_PROPOSER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
OWNER=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC \
TREASURY=0xdf09A0afD09a63fb04ab3573922437e1e637dE8b \
INITIAL_PROOF_TIME_TARGET=101 \
TAIKO_L2_ADDRESS=0x1000777700000000000000000000000000000001 \
L2_SIGNAL_SERVICE=0x1000777700000000000000000000000000000007 \
SHARED_SIGNAL_SERVICE=0x0000000000000000000000000000000000000000 \
TAIKO_TOKEN_PREMINT_RECIPIENT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
TAIKO_TOKEN_PREMINT_AMOUNT=18446744073709551614 \
L2_GENESIS_HASH=$L2_GENESIS_HASH \
L2_CHAIN_ID=167001 \
ADJUSTMENT_QUOTIENT=32000 \
forge script script/DeployOnL1.s.sol:DeployOnL1 \
--fork-url http://localhost:18545 \
--broadcast \
Expand Down
66 changes: 44 additions & 22 deletions pkg/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ type Client struct {
// Geth Engine API clients
L2Engine *EngineClient
// Protocol contracts clients
TaikoL1 *bindings.TaikoL1Client
TaikoL2 *bindings.TaikoL2Client
TaikoL1 *bindings.TaikoL1Client
TaikoL2 *bindings.TaikoL2Client
TaikoProverPoolL1 *bindings.TaikoL1ProverPool
TaikoTokenL1 *bindings.TaikoToken
// Chain IDs
L1ChainID *big.Int
L2ChainID *big.Int
Expand All @@ -38,14 +40,16 @@ type Client struct {
// RPC client. If not providing L2EngineEndpoint or JwtSecret, then the L2Engine client
// won't be initialized.
type ClientConfig struct {
L1Endpoint string
L2Endpoint string
L2CheckPoint string
TaikoL1Address common.Address
TaikoL2Address common.Address
L2EngineEndpoint string
JwtSecret string
RetryInterval time.Duration
L1Endpoint string
L2Endpoint string
L2CheckPoint string
TaikoL1Address common.Address
TaikoProverPoolL1Address common.Address
TaikoL2Address common.Address
TaikoTokenL1Address common.Address
L2EngineEndpoint string
JwtSecret string
RetryInterval time.Duration
}

// NewClient initializes all RPC clients used by Taiko client softwares.
Expand All @@ -60,6 +64,22 @@ func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error) {
return nil, err
}

var taikoProverPoolL1 *bindings.TaikoL1ProverPool
if cfg.TaikoProverPoolL1Address.Hex() != "" {
taikoProverPoolL1, err = bindings.NewTaikoL1ProverPool(cfg.TaikoProverPoolL1Address, l1RPC)
if err != nil {
return nil, err
}
}

var taikoTokenL1 *bindings.TaikoToken
if cfg.TaikoTokenL1Address.Hex() != "" {
taikoTokenL1, err = bindings.NewTaikoToken(cfg.TaikoTokenL1Address, l1RPC)
if err != nil {
return nil, err
}
}

l2RPC, err := DialClientWithBackoff(ctx, cfg.L2Endpoint, cfg.RetryInterval)
if err != nil {
return nil, err
Expand Down Expand Up @@ -112,18 +132,20 @@ func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error) {
}

client := &Client{
L1: l1RPC,
L2: l2RPC,
L2CheckPoint: l2CheckPoint,
L1RawRPC: l1RawRPC,
L2RawRPC: l2RawRPC,
L1GethClient: gethclient.New(l1RawRPC),
L2GethClient: gethclient.New(l2RawRPC),
L2Engine: l2AuthRPC,
TaikoL1: taikoL1,
TaikoL2: taikoL2,
L1ChainID: l1ChainID,
L2ChainID: l2ChainID,
L1: l1RPC,
L2: l2RPC,
L2CheckPoint: l2CheckPoint,
L1RawRPC: l1RawRPC,
L2RawRPC: l2RawRPC,
L1GethClient: gethclient.New(l1RawRPC),
L2GethClient: gethclient.New(l2RawRPC),
L2Engine: l2AuthRPC,
TaikoL1: taikoL1,
TaikoL2: taikoL2,
TaikoProverPoolL1: taikoProverPoolL1,
TaikoTokenL1: taikoTokenL1,
L1ChainID: l1ChainID,
L2ChainID: l2ChainID,
}

if err := client.ensureGenesisMatched(ctx); err != nil {
Expand Down
16 changes: 9 additions & 7 deletions pkg/rpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import (

func newTestClient(t *testing.T) *Client {
client, err := NewClient(context.Background(), &ClientConfig{
L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"),
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"),
JwtSecret: os.Getenv("JWT_SECRET"),
RetryInterval: backoff.DefaultMaxInterval,
L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"),
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT"),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
TaikoProverPoolL1Address: common.HexToAddress(os.Getenv("TAIKO_PROVER_POOL_L1_ADDRESS")),
TaikoTokenL1Address: common.HexToAddress(os.Getenv("TAIKO_TOKEN_L1_ADDRESS")),
L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"),
JwtSecret: os.Getenv("JWT_SECRET"),
RetryInterval: backoff.DefaultMaxInterval,
})

require.Nil(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (c *Client) WaitL1Origin(ctx context.Context, blockID *big.Int) (*rawdb.L1O
func (c *Client) GetPoolContent(
ctx context.Context,
maxTransactionsPerBlock uint64,
blockMaxGasLimit uint64,
blockMaxGasLimit uint32,
maxBytesPerTxList uint64,
locals []common.Address,
) ([]types.Transactions, error) {
Expand Down
18 changes: 18 additions & 0 deletions pkg/rpc/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ func SubscribeBlockProven(
})
}

// SubscribeSlashed subscribes the prover pool's Slashed events.
func SubscribeSlashed(
taikoProverPool *bindings.TaikoL1ProverPool,
ch chan *bindings.TaikoL1ProverPoolSlashed,
) event.Subscription {
return SubscribeEvent("Slashed", func(ctx context.Context) (event.Subscription, error) {
sub, err := taikoProverPool.WatchSlashed(nil, ch, nil)
if err != nil {
log.Error("Create taikoProverPool.WatchSlashed subscription error", "error", err)
return nil, err
}

defer sub.Unsubscribe()

return waitSubErr(ctx, sub)
})
}

// SubscribeChainHead subscribes the new chain heads.
func SubscribeChainHead(
client *ethclient.Client,
Expand Down
7 changes: 7 additions & 0 deletions pkg/rpc/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ func TestSubscribeBlockProven(t *testing.T) {
)
}

func TestSubscribeSlashed(t *testing.T) {
require.NotNil(t, SubscribeSlashed(
newTestClient(t).TaikoProverPoolL1,
make(chan *bindings.TaikoL1ProverPoolSlashed, 1024)),
)
}

func TestSubscribeChainHead(t *testing.T) {
require.NotNil(t, SubscribeChainHead(
newTestClient(t).L1,
Expand Down
Loading