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

fix(proposer): rename lastUnfilteredPoolContentProposedAt #685

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading