From b93cfcf8fc60e85d7223bf22540ce42ad13f416b Mon Sep 17 00:00:00 2001 From: Roger <50648015+RogerLamTd@users.noreply.github.com> Date: Fri, 16 Feb 2024 07:54:52 -0800 Subject: [PATCH] feat(proposer): restore l2.suggestedFeeRecipient flag (#550) Co-authored-by: David --- .github/workflows/test.yml | 1 - cmd/flags/proposer.go | 7 +++++++ driver/chain_syncer/calldata/syncer_test.go | 1 + driver/chain_syncer/chain_syncer_test.go | 1 + driver/driver_test.go | 1 + integration_test/test_env.sh | 2 ++ proposer/config.go | 7 +++++++ proposer/config_test.go | 20 +++++++++++++++++++ proposer/proposer.go | 2 +- proposer/proposer_test.go | 3 +++ .../proof_submitter/proof_submitter_test.go | 1 + prover/prover_test.go | 1 + 12 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b28114109..d4a2b5d97 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,7 +45,6 @@ jobs: with: repository: taikoxyz/taiko-mono path: ${{ env.TAIKO_MONO_DIR }} - ref: reentrance - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 diff --git a/cmd/flags/proposer.go b/cmd/flags/proposer.go index 63cd09524..cf12bbbb6 100644 --- a/cmd/flags/proposer.go +++ b/cmd/flags/proposer.go @@ -20,6 +20,12 @@ var ( Required: true, Category: proposerCategory, } + L2SuggestedFeeRecipient = &cli.StringFlag{ + Name: "l2.suggestedFeeRecipient", + Usage: "Address of the proposed block's suggested L2 fee recipient", + Required: true, + Category: proposerCategory, + } ProposerAssignmentHookAddress = &cli.StringFlag{ Name: "assignmentHookAddress", Usage: "Address of the AssignmentHook contract", @@ -135,6 +141,7 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{ L2HTTPEndpoint, TaikoTokenAddress, L1ProposerPrivKey, + L2SuggestedFeeRecipient, ProposeInterval, TxPoolLocals, TxPoolLocalsOnly, diff --git a/driver/chain_syncer/calldata/syncer_test.go b/driver/chain_syncer/calldata/syncer_test.go index 0073e7dd2..6f7289d35 100644 --- a/driver/chain_syncer/calldata/syncer_test.go +++ b/driver/chain_syncer/calldata/syncer_test.go @@ -58,6 +58,7 @@ func (s *CalldataSyncerTestSuite) SetupTest() { }, AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, + L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), ProposeInterval: &proposeInterval, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second, diff --git a/driver/chain_syncer/chain_syncer_test.go b/driver/chain_syncer/chain_syncer_test.go index 55e261b22..bbce8b09c 100644 --- a/driver/chain_syncer/chain_syncer_test.go +++ b/driver/chain_syncer/chain_syncer_test.go @@ -59,6 +59,7 @@ func (s *ChainSyncerTestSuite) SetupTest() { }, AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, + L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), ProposeInterval: &proposeInterval, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second, diff --git a/driver/driver_test.go b/driver/driver_test.go index 8c5362049..3cdb47efa 100644 --- a/driver/driver_test.go +++ b/driver/driver_test.go @@ -65,6 +65,7 @@ func (s *DriverTestSuite) SetupTest() { }, AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, + L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), ProposeInterval: &proposeInterval, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second, diff --git a/integration_test/test_env.sh b/integration_test/test_env.sh index 0a3d038b6..c93b4fbbc 100755 --- a/integration_test/test_env.sh +++ b/integration_test/test_env.sh @@ -19,6 +19,7 @@ export L1_SIGNAL_SERVICE_CONTRACT_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.signa export L1_CONTRACT_OWNER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 export L1_SECURITY_COUNCIL_PRIVATE_KEY=0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 export L1_PROPOSER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 +export L2_SUGGESTED_FEE_RECIPIENT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 export L1_PROVER_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d export TREASURY=0x1670010000000000000000000000000000010001 @@ -26,6 +27,7 @@ export TREASURY=0x1670010000000000000000000000000000010001 echo "TAIKO_MONO_DIR=$TAIKO_MONO_DIR" echo "L1_NODE_HTTP_ENDPOINT=$L1_NODE_HTTP_ENDPOINT" echo "L1_NODE_WS_ENDPOINT=$L1_NODE_WS_ENDPOINT" +echo "L2_SUGGESTED_FEE_RECIPIENT=$L2_SUGGESTED_FEE_RECIPIENT" echo "L2_EXECUTION_ENGINE_HTTP_ENDPOINT=$L2_EXECUTION_ENGINE_HTTP_ENDPOINT" echo "L2_EXECUTION_ENGINE_WS_ENDPOINT=$L2_EXECUTION_ENGINE_WS_ENDPOINT" echo "L2_EXECUTION_ENGINE_AUTH_ENDPOINT=$L2_EXECUTION_ENGINE_AUTH_ENDPOINT" diff --git a/proposer/config.go b/proposer/config.go index 4010f1552..29d3a9060 100644 --- a/proposer/config.go +++ b/proposer/config.go @@ -21,6 +21,7 @@ type Config struct { *rpc.ClientConfig AssignmentHookAddress common.Address L1ProposerPrivKey *ecdsa.PrivateKey + L2SuggestedFeeRecipient common.Address ExtraData string ProposeInterval *time.Duration LocalAddresses []common.Address @@ -65,6 +66,11 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { proposeEmptyBlocksInterval = &interval } + l2SuggestedFeeRecipient := c.String(flags.L2SuggestedFeeRecipient.Name) + if !common.IsHexAddress(l2SuggestedFeeRecipient) { + return nil, fmt.Errorf("invalid L2 suggested fee recipient address: %s", l2SuggestedFeeRecipient) + } + var localAddresses []common.Address if c.IsSet(flags.TxPoolLocals.Name) { for _, account := range strings.Split(c.String(flags.TxPoolLocals.Name), ",") { @@ -109,6 +115,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { }, AssignmentHookAddress: common.HexToAddress(c.String(flags.ProposerAssignmentHookAddress.Name)), L1ProposerPrivKey: l1ProposerPrivKey, + L2SuggestedFeeRecipient: common.HexToAddress(l2SuggestedFeeRecipient), ExtraData: c.String(flags.ExtraData.Name), ProposeInterval: proposingInterval, LocalAddresses: localAddresses, diff --git a/proposer/config_test.go b/proposer/config_test.go index 57ba91f24..034c2e032 100644 --- a/proposer/config_test.go +++ b/proposer/config_test.go @@ -42,6 +42,7 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() { s.Equal(taikoL2, c.TaikoL2Address.String()) s.Equal(taikoToken, c.TaikoTokenAddress.String()) s.Equal(goldenTouchAddress, crypto.PubkeyToAddress(c.L1ProposerPrivKey.PublicKey)) + s.Equal(goldenTouchAddress, c.L2SuggestedFeeRecipient) s.Equal(float64(10), c.ProposeInterval.Seconds()) s.Equal(1, len(c.LocalAddresses)) s.Equal(goldenTouchAddress, c.LocalAddresses[0]) @@ -72,6 +73,7 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() { "--" + flags.TaikoL2Address.Name, taikoL2, "--" + flags.TaikoTokenAddress.Name, taikoToken, "--" + flags.L1ProposerPrivKey.Name, encoding.GoldenTouchPrivKey, + "--" + flags.L2SuggestedFeeRecipient.Name, goldenTouchAddress.Hex(), "--" + flags.ProposeInterval.Name, proposeInterval, "--" + flags.TxPoolLocals.Name, goldenTouchAddress.Hex(), "--" + flags.ProposeBlockTxReplacementMultiplier.Name, "5", @@ -99,7 +101,22 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContextPrivKeyErr() { }), "invalid L1 proposer private key") } +func (s *ProposerTestSuite) TestNewConfigFromCliContextL2RecipErr() { + app := s.SetupApp() + + s.ErrorContains(app.Run([]string{ + "TestNewConfigFromCliContextL2RecipErr", + "--" + flags.L1ProposerPrivKey.Name, encoding.GoldenTouchPrivKey, + "--" + flags.ProposeInterval.Name, proposeInterval, + "--" + flags.ProposeEmptyBlocksInterval.Name, proposeInterval, + "--" + flags.L2SuggestedFeeRecipient.Name, "notAnAddress", + }), "invalid L2 suggested fee recipient address") +} + func (s *ProposerTestSuite) TestNewConfigFromCliContextTxPoolLocalsErr() { + goldenTouchAddress, err := s.RPCClient.TaikoL2.GOLDENTOUCHADDRESS(nil) + s.Nil(err) + app := s.SetupApp() s.ErrorContains(app.Run([]string{ @@ -107,6 +124,7 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContextTxPoolLocalsErr() { "--" + flags.L1ProposerPrivKey.Name, encoding.GoldenTouchPrivKey, "--" + flags.ProposeInterval.Name, proposeInterval, "--" + flags.ProposeEmptyBlocksInterval.Name, proposeInterval, + "--" + flags.L2SuggestedFeeRecipient.Name, goldenTouchAddress.Hex(), "--" + flags.TxPoolLocals.Name, "notAnAddress", }), "invalid account in --txpool.locals") } @@ -120,6 +138,7 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContextReplMultErr() { s.ErrorContains(app.Run([]string{ "TestNewConfigFromCliContextReplMultErr", "--" + flags.L1ProposerPrivKey.Name, encoding.GoldenTouchPrivKey, + "--" + flags.L2SuggestedFeeRecipient.Name, goldenTouchAddress.Hex(), "--" + flags.ProposeInterval.Name, proposeInterval, "--" + flags.ProposeEmptyBlocksInterval.Name, proposeInterval, "--" + flags.TxPoolLocals.Name, goldenTouchAddress.Hex(), @@ -136,6 +155,7 @@ func (s *ProposerTestSuite) SetupApp() *cli.App { &cli.StringFlag{Name: flags.TaikoL2Address.Name}, &cli.StringFlag{Name: flags.TaikoTokenAddress.Name}, &cli.StringFlag{Name: flags.L1ProposerPrivKey.Name}, + &cli.StringFlag{Name: flags.L2SuggestedFeeRecipient.Name}, &cli.DurationFlag{Name: flags.ProposeEmptyBlocksInterval.Name}, &cli.DurationFlag{Name: flags.ProposeInterval.Name}, &cli.StringFlag{Name: flags.TxPoolLocals.Name}, diff --git a/proposer/proposer.go b/proposer/proposer.go index 5181bc1f9..3b9f4e1f5 100644 --- a/proposer/proposer.go +++ b/proposer/proposer.go @@ -372,7 +372,7 @@ func (p *Proposer) sendProposeBlockTx( encodedParams, err := encoding.EncodeBlockParams(&encoding.BlockParams{ AssignedProver: assignedProver, - Coinbase: p.proposerAddress, + Coinbase: p.L2SuggestedFeeRecipient, ExtraData: rpc.StringToBytes32(p.ExtraData), TxListByteOffset: common.Big0, TxListByteSize: common.Big0, diff --git a/proposer/proposer_test.go b/proposer/proposer_test.go index b810e3861..f42612dd1 100644 --- a/proposer/proposer_test.go +++ b/proposer/proposer_test.go @@ -45,6 +45,7 @@ func (s *ProposerTestSuite) SetupTest() { }, AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, + L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), ProposeInterval: &proposeInterval, MaxProposedTxListsPerEpoch: 1, ProposeBlockTxReplacementMultiplier: 2, @@ -109,6 +110,8 @@ func (s *ProposerTestSuite) TestProposeOp() { event := <-sink + s.Equal(event.Meta.Coinbase, s.p.L2SuggestedFeeRecipient) + _, isPending, err := s.p.rpc.L1.TransactionByHash(context.Background(), event.Raw.TxHash) s.Nil(err) s.False(isPending) diff --git a/prover/proof_submitter/proof_submitter_test.go b/prover/proof_submitter/proof_submitter_test.go index 30885fb6c..12206be06 100644 --- a/prover/proof_submitter/proof_submitter_test.go +++ b/prover/proof_submitter/proof_submitter_test.go @@ -100,6 +100,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() { AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, + L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), ProposeInterval: &proposeInterval, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second, diff --git a/prover/prover_test.go b/prover/prover_test.go index 823693a2a..cd34fe19a 100644 --- a/prover/prover_test.go +++ b/prover/prover_test.go @@ -82,6 +82,7 @@ func (s *ProverTestSuite) SetupTest() { }, AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, + L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), ProposeInterval: &proposeInterval, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second,