Skip to content

Commit a27e160

Browse files
committed
redo: move accumulator to end of block
1 parent 824aba9 commit a27e160

File tree

2 files changed

+45
-18
lines changed

2 files changed

+45
-18
lines changed

runtime/src/bank.rs

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,17 +1410,24 @@ impl Bank {
14101410
bank.update_recent_blockhashes();
14111411
bank.fill_missing_sysvar_cache_entries();
14121412

1413-
// If the accumulator is not moved to end of block, update the
1414-
// accumulator last to make sure that the solana fully updated
1415-
// state before the accumulator is used. bank is in a fully
1416-
// updated state before the accumulator is used.
1417-
if !bank
1413+
// The features are activated one after another.
1414+
// The accumulator is moved to end of the block either if the
1415+
// move_accumulator_to_end_of_block feature is active or if all
1416+
// the features are active.
1417+
let accumulator_moved_to_end_of_block = bank
14181418
.feature_set
14191419
.is_active(&feature_set::move_accumulator_to_end_of_block::id())
1420-
|| bank
1420+
^ bank
14211421
.feature_set
14221422
.is_active(&feature_set::undo_move_accumulator_to_end_of_block::id())
1423-
{
1423+
^ bank
1424+
.feature_set
1425+
.is_active(&feature_set::redo_move_accumulator_to_end_of_block::id());
1426+
// If the accumulator is not moved to end of block, update the
1427+
// accumulator last to make sure that the solana fully updated
1428+
// state before the accumulator is used. bank is in a fully
1429+
// updated state before the accumulator is used.
1430+
if !accumulator_moved_to_end_of_block {
14241431
bank.update_accumulator();
14251432
}
14261433

@@ -1789,17 +1796,24 @@ impl Bank {
17891796
);
17901797

17911798
let (_, update_accumulator_time) = measure!({
1792-
// If the accumulator is not moved to end of block, update the
1793-
// accumulator last to make sure that all fully updated state before
1794-
// the accumulator sysvar updates. sysvars are in a fully updated
1795-
// state before the accumulator sysvar updates.
1796-
if !new
1799+
// The features are activated one after another.
1800+
// The accumulator is moved to end of the block either if the
1801+
// move_accumulator_to_end_of_block feature is active or if all
1802+
// the features are active.
1803+
let accumulator_moved_to_end_of_block = new
17971804
.feature_set
17981805
.is_active(&feature_set::move_accumulator_to_end_of_block::id())
1799-
|| new
1806+
^ new
18001807
.feature_set
18011808
.is_active(&feature_set::undo_move_accumulator_to_end_of_block::id())
1802-
{
1809+
^ new
1810+
.feature_set
1811+
.is_active(&feature_set::redo_move_accumulator_to_end_of_block::id());
1812+
// If the accumulator is not moved to end of block, update the
1813+
// accumulator last to make sure that all fully updated state before
1814+
// the accumulator sysvar updates. sysvars are in a fully updated
1815+
// state before the accumulator sysvar updates.
1816+
if !accumulator_moved_to_end_of_block {
18031817
new.update_accumulator();
18041818
}
18051819
});
@@ -3534,14 +3548,22 @@ impl Bank {
35343548
// committed before this write lock can be obtained here.
35353549
let mut hash = self.hash.write().unwrap();
35363550
if *hash == Hash::default() {
3537-
// Update the accumulator before doing other tasks when freezing to avoid any conflicts.
3538-
if self
3551+
// The features are activated one after another.
3552+
// The accumulator is moved to end of the block either if the
3553+
// move_accumulator_to_end_of_block feature is active or if all
3554+
// the features are active.
3555+
let accumulator_moved_to_end_of_block = self
35393556
.feature_set
35403557
.is_active(&feature_set::move_accumulator_to_end_of_block::id())
3541-
&& !self
3558+
^ self
35423559
.feature_set
35433560
.is_active(&feature_set::undo_move_accumulator_to_end_of_block::id())
3544-
{
3561+
^ self
3562+
.feature_set
3563+
.is_active(&feature_set::redo_move_accumulator_to_end_of_block::id());
3564+
// If accumulator move to end of block is active update the accumulator before doing
3565+
// other tasks when freezing to avoid any conflicts.
3566+
if accumulator_moved_to_end_of_block {
35453567
self.update_accumulator();
35463568
} else {
35473569
info!(

sdk/src/feature_set.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ pub mod undo_move_accumulator_to_end_of_block {
560560
solana_sdk::declare_id!("EfmMYu7ajxsKNgtWmDWKYq9Pt5EUrC3qEHAXEVBBT1bs");
561561
}
562562

563+
pub mod redo_move_accumulator_to_end_of_block {
564+
solana_sdk::declare_id!("skyhwRBbP1LoHzWy1QrwLWy3vo2uHkzVV1zpN9UsGuw");
565+
}
566+
563567
lazy_static! {
564568
/// Map of feature identifiers to user-visible description
565569
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
@@ -694,6 +698,7 @@ lazy_static! {
694698
(move_accumulator_to_end_of_block::id(), "move accumulator to end of block #<GH_ISSUE_NUMBER>"),
695699
(zero_wormhole_message_timestamps::id(), "use zeroed timestamps in wormhole messages"),
696700
(undo_move_accumulator_to_end_of_block::id(), "undo accumulator end of block change"),
701+
(redo_move_accumulator_to_end_of_block::id(), "redo accumulator end of block change"),
697702
/*************** ADD NEW FEATURES HERE ***************/
698703
]
699704
.iter()

0 commit comments

Comments
 (0)