Skip to content

Commit 948e273

Browse files
committed
[execution] gate hot-state via on-chain features
The hot-state rollout switches that control write-set format, block epilogue payload format, and `TransactionInfo` format all affect bytes committed to the ledger, so they must agree across all validators. They previously lived in the local `HotStateConfig`, where they could drift per-node. Move them to two new permanent feature flags: - `HOTNESS_IN_EPILOGUE`: persists per-block hot-state promotions in `BlockEpiloguePayload::V2`, and emits V1 write sets that encode the hot-state changes inline. - `TRANSACTION_INFO_V1`: assembles `TransactionInfoV1`, which carries the hot state root hash into the ledger accumulator. `OnChainExecutionConfig::block_executor_onchain_config()` now takes `&Features` and threads the booleans into `BlockExecutorConfigFromOnchain`. Consensus reads `Features` from the reconfiguration payload and propagates it through the epoch manager, execution client, and consensus observer. The block executor and `do_get_execution_output` consume the on-chain values, and the `TransactionInfoV1` flag rides along on `ExecutionOutput` into ledger update. The chunk-apply path still derives the transaction info format from each chunk's actual `TransactionInfo` variants and so does not depend on the on-chain flag.
1 parent 7f900aa commit 948e273

28 files changed

Lines changed: 151 additions & 87 deletions

File tree

aptos-move/aptos-release-builder/src/components/feature_flags.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ pub enum FeatureFlag {
166166
VersionedTransactionValidation,
167167
StorageSlotNatives,
168168
AllowFriendEntryVisibilityDowngrade,
169+
HotnessInEpilogue,
170+
TransactionInfoV1,
169171
}
170172

171173
fn generate_features_blob(writer: &CodeWriter, data: &[u64]) {
@@ -435,6 +437,8 @@ impl From<FeatureFlag> for AptosFeatureFlag {
435437
FeatureFlag::AllowFriendEntryVisibilityDowngrade => {
436438
AptosFeatureFlag::ALLOW_FRIEND_ENTRY_VISIBILITY_DOWNGRADE
437439
},
440+
FeatureFlag::HotnessInEpilogue => AptosFeatureFlag::HOTNESS_IN_EPILOGUE,
441+
FeatureFlag::TransactionInfoV1 => AptosFeatureFlag::TRANSACTION_INFO_V1,
438442
}
439443
}
440444
}
@@ -631,6 +635,8 @@ impl From<AptosFeatureFlag> for FeatureFlag {
631635
AptosFeatureFlag::ALLOW_FRIEND_ENTRY_VISIBILITY_DOWNGRADE => {
632636
FeatureFlag::AllowFriendEntryVisibilityDowngrade
633637
},
638+
AptosFeatureFlag::HOTNESS_IN_EPILOGUE => FeatureFlag::HotnessInEpilogue,
639+
AptosFeatureFlag::TRANSACTION_INFO_V1 => FeatureFlag::TransactionInfoV1,
634640
}
635641
}
636642
}

aptos-move/aptos-vm/src/aptos_vm.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ static NUM_PROOF_READING_THREADS: OnceCell<usize> = OnceCell::new();
164164
static DISCARD_FAILED_BLOCKS: OnceCell<bool> = OnceCell::new();
165165
static PROCESSED_TRANSACTIONS_DETAILED_COUNTERS: OnceCell<bool> = OnceCell::new();
166166
static ENABLE_PRE_WRITE: OnceCell<bool> = OnceCell::new();
167-
static PERSIST_HOTNESS_IN_EPILOGUE: OnceCell<bool> = OnceCell::new();
168167

169168
macro_rules! deprecated_module_bundle {
170169
() => {
@@ -514,19 +513,6 @@ impl AptosVM {
514513
}
515514
}
516515

517-
/// Sets persist_hotness_in_epilogue flag when invoked the first time.
518-
pub fn set_persist_hotness_in_epilogue_once(persist: bool) {
519-
let _ = PERSIST_HOTNESS_IN_EPILOGUE.set(persist);
520-
}
521-
522-
/// Get the persist_hotness_in_epilogue flag if already set, otherwise return default (false)
523-
pub fn get_persist_hotness_in_epilogue() -> bool {
524-
match PERSIST_HOTNESS_IN_EPILOGUE.get() {
525-
Some(persist) => *persist,
526-
None => false,
527-
}
528-
}
529-
530516
pub fn set_num_shards_once(mut num_shards: usize) {
531517
num_shards = max(num_shards, 1);
532518
// Only the first call succeeds, due to OnceCell semantics.
@@ -3425,7 +3411,6 @@ impl VMBlockExecutor for AptosVMBlockExecutor {
34253411
discard_failed_blocks: AptosVM::get_discard_failed_blocks(),
34263412
module_cache_config: BlockExecutorModuleCacheLocalConfig::default(),
34273413
enable_pre_write: AptosVM::get_enable_pre_write(),
3428-
persist_hotness_in_epilogue: AptosVM::get_persist_hotness_in_epilogue(),
34293414
},
34303415
onchain: onchain_config,
34313416
};

aptos-move/aptos-vm/src/sharded_block_executor/local_executor_shard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<S: StateView + Sync + Send + 'static> ExecutorClient<S> for LocalExecutorCl
195195
state_view.clone(),
196196
sub_blocks_for_shard,
197197
concurrency_level_per_shard,
198-
onchain_config.clone(),
198+
onchain_config,
199199
))
200200
.unwrap();
201201
}

aptos-move/block-executor/src/executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,7 @@ where
21782178
}
21792179
}
21802180
let fee_distribution = FeeDistribution::new(amount);
2181-
if self.config.local.persist_hotness_in_epilogue {
2181+
if self.config.onchain.hotness_in_epilogue() {
21822182
let (inner, to_make_hot) = block_end_info.into_parts();
21832183
Ok(T::block_epilogue_v2(
21842184
block_id,

aptos-move/e2e-tests/src/executor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,9 +1009,8 @@ impl<O: OutputLogger> FakeExecutorImpl<O> {
10091009
discard_failed_blocks: false,
10101010
module_cache_config: BlockExecutorModuleCacheLocalConfig::default(),
10111011
enable_pre_write: true,
1012-
persist_hotness_in_epilogue: false,
10131012
},
1014-
onchain: onchain_config.clone(),
1013+
onchain: onchain_config,
10151014
};
10161015

10171016
#[cfg(fuzzing)]
259 Bytes
Binary file not shown.

aptos-move/framework/move-stdlib/sources/configs/features.move

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,19 @@ module std::features {
876876
is_enabled(MULTISIG_TIMELOCK)
877877
}
878878

879+
/// When enabled, per-block hot-state promotions are persisted through the block
880+
/// epilogue: the promotion set is embedded into the block epilogue transaction
881+
/// payload (`BlockEpiloguePayload::V2`), and every transaction output in the block
882+
/// uses the V1 write-set format, which encodes hot-state changes in its serialized
883+
/// writes.
884+
/// Lifetime: permanent
885+
const HOTNESS_IN_EPILOGUE: u64 = 116;
886+
887+
/// When enabled, execution assembles `TransactionInfoV1`, which carries the hot
888+
/// state root hash, so it is committed to the ledger accumulator.
889+
/// Lifetime: permanent
890+
const TRANSACTION_INFO_V1: u64 = 117;
891+
879892
// ============================================================================================
880893
// Feature Flag Implementation
881894

aptos-move/replay-benchmark/src/execution.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ pub(crate) fn execute_workload(
2828
discard_failed_blocks: false,
2929
module_cache_config: BlockExecutorModuleCacheLocalConfig::default(),
3030
enable_pre_write: true,
31-
persist_hotness_in_epilogue: false,
3231
},
33-
// For replay, there is no block limit.
32+
// For replay, there is no block limit. TODO(HotState): may need to update this.
3433
onchain: BlockExecutorConfigFromOnchain::on_but_large_for_test(),
3534
};
3635

aptos-node/src/utils.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ pub fn set_aptos_vm_configurations(node_config: &NodeConfig) {
7676
);
7777
AptosVM::set_blockstm_v2_enabled_once(node_config.execution.blockstm_v2_enabled);
7878
AptosVM::set_enable_pre_write_once(node_config.execution.enable_pre_write);
79-
AptosVM::set_persist_hotness_in_epilogue_once(
80-
node_config
81-
.storage
82-
.hot_state_config
83-
.persist_hotness_in_epilogue,
84-
);
8579

8680
if node_config
8781
.execution

config/src/config/storage_config.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,6 @@ pub struct HotStateConfig {
255255
/// Whether we compute root hashes for hot state in executor and commit the resulting JMT to
256256
/// db.
257257
pub compute_root_hash: bool,
258-
/// Whether execution should construct write sets using the V1 format and include hotness
259-
/// changes in serialized format.
260-
pub use_write_set_v1: bool,
261-
/// Whether to embed the per-block hot-state promotions into the epilogue transactions.
262-
pub persist_hotness_in_epilogue: bool,
263-
/// Whether execution should assemble `TransactionInfoV1` which carries hot state root hash.
264-
pub use_transaction_info_v1: bool,
265258
}
266259

267260
impl Default for HotStateConfig {
@@ -271,9 +264,6 @@ impl Default for HotStateConfig {
271264
refresh_interval_versions: 100_000,
272265
delete_on_restart: true,
273266
compute_root_hash: true,
274-
use_write_set_v1: false,
275-
persist_hotness_in_epilogue: false,
276-
use_transaction_info_v1: false,
277267
}
278268
}
279269
}

0 commit comments

Comments
 (0)