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

Commit

Permalink
feat(proposer): add --maxProposedTxListsPerEpoch flag (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jun 5, 2023
1 parent 5d20027 commit 937e8b1
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 35 deletions.
6 changes: 6 additions & 0 deletions cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ var (
Usage: "Minimal block gasLimit when proposing a block",
Category: proposerCategory,
}
MaxProposedTxListsPerEpoch = &cli.Uint64Flag{
Name: "maxProposedTxListsPerEpoch",
Value: 1,
Category: proposerCategory,
}
)

// All proposer flags.
Expand All @@ -62,4 +67,5 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
TxPoolLocals,
ProposeEmptyBlocksInterval,
MinBlockGasLimit,
MaxProposedTxListsPerEpoch,
})
15 changes: 8 additions & 7 deletions driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ func (s *CalldataSyncerTestSuite) SetupTest() {
s.Nil(err)
proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests
s.Nil(proposer.InitFromConfig(context.Background(), prop, (&proposer.Config{
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")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval,
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")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval,
MaxProposedTxListsPerEpoch: 1,
})))

s.p = prop
Expand Down
15 changes: 8 additions & 7 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ func (s *DriverTestSuite) SetupTest() {

proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests
s.Nil(proposer.InitFromConfig(context.Background(), p, (&proposer.Config{
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")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval, // No need to periodically propose transactions list in unit tests
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")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval, // No need to periodically propose transactions list in unit tests
MaxProposedTxListsPerEpoch: 1,
})))
s.p = p
}
Expand Down
2 changes: 2 additions & 0 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Config struct {
LocalAddresses []common.Address
ProposeEmptyBlocksInterval *time.Duration
MinBlockGasLimit uint64
MaxProposedTxListsPerEpoch uint64
}

// NewConfigFromCliContext initializes a Config instance from
Expand Down Expand Up @@ -83,5 +84,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
LocalAddresses: localAddresses,
ProposeEmptyBlocksInterval: proposeEmptyBlocksInterval,
MinBlockGasLimit: c.Uint64(flags.MinBlockGasLimit.Name),
MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name),
}, nil
}
6 changes: 6 additions & 0 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type Proposer struct {
commitSlot uint64
locals []common.Address
minBlockGasLimit *uint64
maxProposedTxListsPerEpoch uint64

// Protocol configurations
protocolConfigs *bindings.TaikoDataConfig
Expand Down Expand Up @@ -79,6 +80,7 @@ func InitFromConfig(ctx context.Context, p *Proposer, cfg *Config) (err error) {
p.wg = sync.WaitGroup{}
p.locals = cfg.LocalAddresses
p.commitSlot = cfg.CommitSlot
p.maxProposedTxListsPerEpoch = cfg.MaxProposedTxListsPerEpoch
p.ctx = ctx

// RPC clients
Expand Down Expand Up @@ -226,6 +228,10 @@ func (p *Proposer) ProposeOp(ctx context.Context) error {
for i, txs := range txLists {
func(i int, txs types.Transactions) {
g.Go(func() error {
if i >= int(p.maxProposedTxListsPerEpoch) {
return nil
}

txListBytes, err := rlp.EncodeToBytes(txs)
if err != nil {
return fmt.Errorf("failed to encode transactions: %w", err)
Expand Down
15 changes: 8 additions & 7 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ func (s *ProposerTestSuite) SetupTest() {
ctx, cancel := context.WithCancel(context.Background())
proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests
s.Nil(InitFromConfig(ctx, p, (&Config{
L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"),
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT"),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval,
L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"),
L2Endpoint: os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT"),
TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval,
MaxProposedTxListsPerEpoch: 1,
})))

s.p = p
Expand Down
15 changes: 8 additions & 7 deletions prover/proof_submitter/valid_proof_submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
s.Nil(err)
proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests
s.Nil(proposer.InitFromConfig(context.Background(), prop, (&proposer.Config{
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")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval, // No need to periodically propose transactions list in unit tests
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")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval, // No need to periodically propose transactions list in unit tests
MaxProposedTxListsPerEpoch: 1,
})))

s.proposer = prop
Expand Down
15 changes: 8 additions & 7 deletions prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ func (s *ProverTestSuite) SetupTest() {

proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests
s.Nil(proposer.InitFromConfig(context.Background(), prop, (&proposer.Config{
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")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval, // No need to periodically propose transactions list in unit tests
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")),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval, // No need to periodically propose transactions list in unit tests
MaxProposedTxListsPerEpoch: 1,
})))

s.proposer = prop
Expand Down

0 comments on commit 937e8b1

Please sign in to comment.