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

Commit

Permalink
fix(proposer): rename lastUnfilteredPoolContentProposedAt (#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Apr 5, 2024
1 parent 62cc7ff commit 8c85703
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Proposer struct {
// Protocol configurations
protocolConfigs *bindings.TaikoDataConfig

lastUnfilteredPoolContentProposedAt time.Time
lastProposedAt time.Time

txmgr *txmgr.SimpleTxManager

Expand All @@ -80,7 +80,7 @@ func (p *Proposer) InitFromConfig(ctx context.Context, cfg *Config) (err error)
p.proposerAddress = crypto.PubkeyToAddress(cfg.L1ProposerPrivKey.PublicKey)
p.ctx = ctx
p.Config = cfg
p.lastUnfilteredPoolContentProposedAt = time.Now()
p.lastProposedAt = time.Now()

// RPC clients
if p.rpc, err = rpc.NewClient(p.ctx, cfg.ClientConfig); err != nil {
Expand Down Expand Up @@ -268,7 +268,7 @@ func (p *Proposer) fetchPoolContent(filterPoolContent bool) ([]types.Transaction
// and then proposing them to TaikoL1 contract.
func (p *Proposer) ProposeOp(ctx context.Context) error {
// Check if it's time to propose unfiltered pool content.
filterPoolContent := time.Now().Before(p.lastUnfilteredPoolContentProposedAt.Add(p.MinProposingInternal))
filterPoolContent := time.Now().Before(p.lastProposedAt.Add(p.MinProposingInternal))

// Wait until L2 execution engine is synced at first.
if err := p.rpc.WaitTillL2ExecutionEngineSynced(ctx); err != nil {
Expand All @@ -278,7 +278,7 @@ func (p *Proposer) ProposeOp(ctx context.Context) error {
log.Info(
"Start fetching L2 execution engine's transaction pool content",
"filterPoolContent", filterPoolContent,
"lastUnfilteredPoolContentProposedAt", p.lastUnfilteredPoolContentProposedAt,
"lastProposedAt", p.lastProposedAt,
)

txLists, err := p.fetchPoolContent(filterPoolContent)
Expand All @@ -301,9 +301,7 @@ func (p *Proposer) ProposeOp(ctx context.Context) error {
return fmt.Errorf("failed to send TaikoL1.proposeBlock transactions: %w", err)
}

if len(txs) != 0 {
p.lastUnfilteredPoolContentProposedAt = time.Now()
}
p.lastProposedAt = time.Now()
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (s *ProposerTestSuite) TestProposeOp() {

func (s *ProposerTestSuite) TestProposeEmptyBlockOp() {
s.p.MinProposingInternal = 1 * time.Second
s.p.lastUnfilteredPoolContentProposedAt = time.Now().Add(-10 * time.Second)
s.p.lastProposedAt = time.Now().Add(-10 * time.Second)
s.Nil(s.p.ProposeOp(context.Background()))
}

Expand Down

0 comments on commit 8c85703

Please sign in to comment.