Skip to content

Commit df02d72

Browse files
committed
feat: early soft activation of spend limit
1 parent 3dbfc5c commit df02d72

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: node/bft/src/primary.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,12 @@ impl<N: Network> Primary<N> {
564564
}
565565

566566
// Ensure the transaction doesn't bring the proposal above the spend limit.
567-
let block_height = self.ledger.latest_block_height() + 1;
567+
//
568+
// Validators start following the new consensus rules early, in order to guarantee a smooth transition.
569+
// The activation height is offset by the maximum number of blocks that can be produced within gc to
570+
// ensure honest validators can't mismatch due to differing views of the dag.
571+
let block_height =
572+
self.ledger.latest_block_height() + 1 + (BatchHeader::<N>::MAX_GC_ROUNDS as u32 / 2);
568573
if N::CONSENSUS_VERSION(block_height)? >= ConsensusVersion::V4 {
569574
match self.ledger.compute_cost(transaction_id, transaction) {
570575
Ok(cost) if proposal_cost + cost <= N::BATCH_SPEND_LIMIT => proposal_cost += cost,
@@ -2241,7 +2246,9 @@ mod tests {
22412246
1,
22422247
&accounts,
22432248
committee,
2244-
CurrentNetwork::CONSENSUS_HEIGHT(ConsensusVersion::V4).unwrap(),
2249+
CurrentNetwork::CONSENSUS_HEIGHT(ConsensusVersion::V4).unwrap()
2250+
// Offset to check soft activation.
2251+
- (BatchHeader::<CurrentNetwork>::MAX_GC_ROUNDS as u32 / 2),
22452252
);
22462253

22472254
// Check there is no batch currently proposed.

0 commit comments

Comments
 (0)