Skip to content

Commit 8ec152e

Browse files
committed
Add protocol support to staker and validator test helps.
Add tests for legacy add_stake.
1 parent 7c58dd2 commit 8ec152e

6 files changed

Lines changed: 1128 additions & 821 deletions

File tree

blockchain/src/blockchain/history_sync.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,9 @@ impl Blockchain {
208208
// Also, this works only if a single macro block is missing between history items.
209209
let batch_number = Policy::batch_at(hist_tx.block_number);
210210
if batch_number > prev_batch
211-
&& block_state
212-
.last()
213-
.map_or(false, |block_state: &BlockState| {
214-
!Policy::is_macro_block_at(block_state.number)
215-
})
211+
&& block_state.last().is_some_and(|block_state: &BlockState| {
212+
!Policy::is_macro_block_at(block_state.number)
213+
})
216214
{
217215
debug!(
218216
history_item_block_number = hist_tx.block_number,
@@ -224,21 +222,19 @@ impl Blockchain {
224222
);
225223
assert_eq!(batch_number, prev_batch + 1, "Missing batch");
226224

227-
// We only allow protocol version upgrades on election blocks, so the version cannot be change here.
228225
block_state.push(BlockState {
229226
number: Policy::macro_block_of(prev_batch).unwrap(),
230-
time: 0, // FIXME
231-
protocol_version: this.state.current_version(),
227+
time: 0, // FIXME
228+
protocol_version: this.state.current_version(), // Cannot change, protocol version upgrades only on election blocks.
232229
});
233230
block_transactions.push(vec![]);
234231
block_inherents.push(vec![]);
235232
}
236233

237-
// We only allow protocol version upgrades on election blocks, so the version cannot be change here.
238234
block_state.push(BlockState {
239235
number: hist_tx.block_number,
240236
time: hist_tx.block_time,
241-
protocol_version: this.state.current_version(),
237+
protocol_version: this.state.current_version(), // Cannot change, protocol version upgrades only on election blocks.
242238
});
243239
block_transactions.push(vec![]);
244240
block_inherents.push(vec![]);

primitives/account/src/account/staking_contract/staker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ impl StakingContract {
290290
tx_logger: &mut TransactionLog,
291291
) -> Result<AddStakeReceipt, AccountError> {
292292
if protocol_version < Policy::ADD_STAKE_PROTOCOL_UPGRADE_VERSION {
293+
log::warn!(%protocol_version, "Adding stake using old protocol version");
293294
return self.legacy_add_stake(store, staker_address, value, tx_logger);
294295
}
295296
// Get the staker.

0 commit comments

Comments
 (0)