Skip to content

Commit

Permalink
fix(consensus): add a safety margin so the batcher stops building ear…
Browse files Browse the repository at this point in the history
…ly enough

This should become configurable as part of a refactor Guy will do to the consensus configs.
  • Loading branch information
matan-starkware committed Dec 16, 2024
1 parent 8fbf802 commit ae3ff8f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type HeightToIdToContent =
type ValidationParams = (BlockNumber, ValidatorId, Duration, mpsc::Receiver<ProposalPart>);

const CHANNEL_SIZE: usize = 100;
// TODO(Guy): Move this to the context config.
const BUILD_PROPOSAL_MARGIN: Duration = Duration::from_millis(100);

pub struct SequencerConsensusContext {
batcher: Arc<dyn BatcherClient>,
Expand Down Expand Up @@ -153,8 +155,9 @@ impl ConsensusContext for SequencerConsensusContext {

let proposal_id = ProposalId(self.proposal_id);
self.proposal_id += 1;
let timeout =
chrono::Duration::from_std(timeout).expect("Can't convert timeout to chrono::Duration");
assert!(timeout > BUILD_PROPOSAL_MARGIN);
let timeout = chrono::Duration::from_std(timeout - BUILD_PROPOSAL_MARGIN)
.expect("Can't convert timeout to chrono::Duration");
let now = chrono::Utc::now();
let build_proposal_input = ProposeBlockInput {
proposal_id,
Expand Down

0 comments on commit ae3ff8f

Please sign in to comment.