Skip to content

Avoids circular dependency related to block creation between Consensus and Execution#3111

Closed
diegoximenes wants to merge 82 commits into
masterfrom
seq_in_consensus
Closed

Avoids circular dependency related to block creation between Consensus and Execution#3111
diegoximenes wants to merge 82 commits into
masterfrom
seq_in_consensus

Conversation

@diegoximenes

@diegoximenes diegoximenes commented Apr 8, 2025

Copy link
Copy Markdown
Contributor

Resolves NIT-3189

Avoids circular dependency related to block creation between Consensus and Execution:

  • Moves sequencing triggering from Execution to Consensus. With that all triggers that create blocks are in a single place, Consensus, which simplifies lock handling related to that operation.
  • Execution doesn't call Consensus to write messages related to sequenced transactions anymore. With this PR Consensus calls Execution triggering a sequencing operation. In that call Execution returns a sequenced message to Consensus. Consensus then processes this sequenced message, and finally calls Execution again to end sequencing, e.g., appending the related block to the blockchain.

@diegoximenes diegoximenes force-pushed the seq_in_consensus branch 6 times, most recently from 62b24dd to 14706b8 Compare April 15, 2025 16:27
@diegoximenes diegoximenes marked this pull request as ready for review April 16, 2025 16:42

@tsahee tsahee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

initial

Comment thread arbnode/delayed_sequencer.go Outdated
Comment thread arbnode/delayed_sequencer.go Outdated
Comment thread arbnode/sequencer_triggerer.go Outdated
@tsahee tsahee assigned diegoximenes and unassigned diegoximenes Jul 8, 2025

@tsahee tsahee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some more notes about forward/pause.

I think this is a good direction, but it touches a lot of delicate code so we'll need to be very careful with it.

Comment thread execution/gethexec/sequencer.go Outdated
@diegoximenes diegoximenes force-pushed the seq_in_consensus branch 2 times, most recently from 0e403b0 to e8186e4 Compare July 17, 2025 16:08
@diegoximenes diegoximenes marked this pull request as draft July 31, 2025 15:54
@codecov

codecov Bot commented Jul 31, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.65199% with 202 lines in your changes missing coverage. Please review.
✅ Project coverage is 22.67%. Comparing base (a9286ce) to head (25d311e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3111      +/-   ##
==========================================
+ Coverage   22.62%   22.67%   +0.04%     
==========================================
  Files         387      387              
  Lines       58608    58664      +56     
==========================================
+ Hits        13262    13304      +42     
- Misses      43307    43318      +11     
- Partials     2039     2042       +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@diegoximenes diegoximenes force-pushed the seq_in_consensus branch 2 times, most recently from 920c0e1 to 5e70558 Compare August 13, 2025 13:48
@diegoximenes diegoximenes force-pushed the seq_in_consensus branch 2 times, most recently from 47ec1af to 5a1da4f Compare August 20, 2025 15:43
@diegoximenes diegoximenes requested a review from tsahee August 20, 2025 18:23
@eljobe eljobe self-requested a review December 15, 2025 10:57
Comment on lines +1665 to +1673
sequencedMsg, err := s.execEngine.SequenceDelayedMessage()
if err != nil {
return nil, 0
}
if sequencedMsg != nil {
return sequencedMsg, 0
}

sequencedMsg, waitUntilSequencingNextBlock := s.createBlockWithRegularTxs(ctx)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe I'm missing some context, but isn't there a possibility to starve createBlockWithRegularTxs() if Sequencer keeps getting delayed messages? Or not a problem here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are right.
I will add some randomization, or alternate which kind of transaction to sequence first.
Good catch 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Strategy to address that:

  • If next delayed msg to be sequence is too old:
    • next will be delayed msg turn, will wait 0ms
  • Else if is sequenced delayed msg turn:
    • If there are normal txs to be sequenced: next will be normal tx turn, will wait 250ms
    • Else if there are delayed msgs to be sequenced: next will be delayed msg turn, will wait 0ms
    • Else: next will be normal tx turn, will wait 250ms
  • Else is normal tx turn:
    • if there are delayed msgs to be sequenced: next will be delayed msg turn, will wait 0ms
    • Else If there are normal txs to be sequenced: next will be normal tx turn, will wait 250ms (or 0ms, since today we retry immediately in some scenarios, such as if the block was not created due to all txs failing)
    • Else: next will be normal tx turn, will wait 250ms

Comment thread execution/gethexec/executionengine.go
Comment thread execution/gethexec/executionengine.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

after-next-version This PR shouldn't be merged until after the next version is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants