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

Commit

Permalink
feat(proposer): restore l2.suggestedFeeRecipient flag (#550)
Browse files Browse the repository at this point in the history
Co-authored-by: David <[email protected]>
  • Loading branch information
RogerLamTd and davidtaikocha authored Feb 16, 2024
1 parent 4ace57c commit b93cfcf
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 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,
}
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",
Expand Down Expand Up @@ -135,6 +141,7 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
L2HTTPEndpoint,
TaikoTokenAddress,
L1ProposerPrivKey,
L2SuggestedFeeRecipient,
ProposeInterval,
TxPoolLocals,
TxPoolLocalsOnly,
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 @@ -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,
Expand Down
1 change: 1 addition & 0 deletions driver/chain_syncer/chain_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions integration_test/test_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ 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

# show the integration test environment variables.
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"
Expand Down
7 changes: 7 additions & 0 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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), ",") {
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 20 additions & 0 deletions proposer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -99,14 +101,30 @@ 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{
"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")
}
Expand All @@ -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(),
Expand All @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions prover/proof_submitter/proof_submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

2 comments on commit b93cfcf

@dzhamilrustamov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent result

@dzhamilrustamov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent result

Please sign in to comment.