Skip to content

Commit f0c7e0e

Browse files
authored
[Priority Fee] Move some BlockEpilogue logic into executor. (aptos-labs#16760)
1 parent 5762524 commit f0c7e0e

30 files changed

+466
-242
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_entry_function_payload.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,12 @@
292292
"accumulator_root_hash": "",
293293
"changes": [],
294294
"timestamp": "500000",
295-
"type": "state_checkpoint_transaction"
295+
"block_end_info": {
296+
"block_gas_limit_reached": false,
297+
"block_output_limit_reached": false,
298+
"block_effective_block_gas_units": 9,
299+
"block_approx_output_size": 0
300+
},
301+
"type": "block_epilogue_transaction"
296302
}
297303
]

api/goldens/aptos_api__tests__transactions_test__test_get_transactions_returns_last_page_when_start_version_is_not_specified.json

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
"accumulator_root_hash": "",
1212
"changes": [],
1313
"timestamp": "6000000",
14-
"type": "state_checkpoint_transaction"
14+
"block_end_info": {
15+
"block_gas_limit_reached": false,
16+
"block_output_limit_reached": false,
17+
"block_effective_block_gas_units": 9,
18+
"block_approx_output_size": 0
19+
},
20+
"type": "block_epilogue_transaction"
1521
},
1622
{
1723
"version": "37",
@@ -297,7 +303,13 @@
297303
"accumulator_root_hash": "",
298304
"changes": [],
299305
"timestamp": "6500000",
300-
"type": "state_checkpoint_transaction"
306+
"block_end_info": {
307+
"block_gas_limit_reached": false,
308+
"block_output_limit_reached": false,
309+
"block_effective_block_gas_units": 9,
310+
"block_approx_output_size": 0
311+
},
312+
"type": "block_epilogue_transaction"
301313
},
302314
{
303315
"version": "40",
@@ -583,7 +595,13 @@
583595
"accumulator_root_hash": "",
584596
"changes": [],
585597
"timestamp": "7000000",
586-
"type": "state_checkpoint_transaction"
598+
"block_end_info": {
599+
"block_gas_limit_reached": false,
600+
"block_output_limit_reached": false,
601+
"block_effective_block_gas_units": 9,
602+
"block_approx_output_size": 0
603+
},
604+
"type": "block_epilogue_transaction"
587605
},
588606
{
589607
"version": "43",
@@ -869,7 +887,13 @@
869887
"accumulator_root_hash": "",
870888
"changes": [],
871889
"timestamp": "7500000",
872-
"type": "state_checkpoint_transaction"
890+
"block_end_info": {
891+
"block_gas_limit_reached": false,
892+
"block_output_limit_reached": false,
893+
"block_effective_block_gas_units": 9,
894+
"block_approx_output_size": 0
895+
},
896+
"type": "block_epilogue_transaction"
873897
},
874898
{
875899
"version": "46",
@@ -1155,7 +1179,13 @@
11551179
"accumulator_root_hash": "",
11561180
"changes": [],
11571181
"timestamp": "8000000",
1158-
"type": "state_checkpoint_transaction"
1182+
"block_end_info": {
1183+
"block_gas_limit_reached": false,
1184+
"block_output_limit_reached": false,
1185+
"block_effective_block_gas_units": 9,
1186+
"block_approx_output_size": 0
1187+
},
1188+
"type": "block_epilogue_transaction"
11591189
},
11601190
{
11611191
"version": "49",
@@ -1441,7 +1471,13 @@
14411471
"accumulator_root_hash": "",
14421472
"changes": [],
14431473
"timestamp": "8500000",
1444-
"type": "state_checkpoint_transaction"
1474+
"block_end_info": {
1475+
"block_gas_limit_reached": false,
1476+
"block_output_limit_reached": false,
1477+
"block_effective_block_gas_units": 9,
1478+
"block_approx_output_size": 0
1479+
},
1480+
"type": "block_epilogue_transaction"
14451481
},
14461482
{
14471483
"version": "52",
@@ -1727,7 +1763,13 @@
17271763
"accumulator_root_hash": "",
17281764
"changes": [],
17291765
"timestamp": "9000000",
1730-
"type": "state_checkpoint_transaction"
1766+
"block_end_info": {
1767+
"block_gas_limit_reached": false,
1768+
"block_output_limit_reached": false,
1769+
"block_effective_block_gas_units": 9,
1770+
"block_approx_output_size": 0
1771+
},
1772+
"type": "block_epilogue_transaction"
17311773
},
17321774
{
17331775
"version": "55",
@@ -2013,7 +2055,13 @@
20132055
"accumulator_root_hash": "",
20142056
"changes": [],
20152057
"timestamp": "9500000",
2016-
"type": "state_checkpoint_transaction"
2058+
"block_end_info": {
2059+
"block_gas_limit_reached": false,
2060+
"block_output_limit_reached": false,
2061+
"block_effective_block_gas_units": 9,
2062+
"block_approx_output_size": 0
2063+
},
2064+
"type": "block_epilogue_transaction"
20172065
},
20182066
{
20192067
"version": "58",
@@ -2299,6 +2347,12 @@
22992347
"accumulator_root_hash": "",
23002348
"changes": [],
23012349
"timestamp": "10000000",
2302-
"type": "state_checkpoint_transaction"
2350+
"block_end_info": {
2351+
"block_gas_limit_reached": false,
2352+
"block_output_limit_reached": false,
2353+
"block_effective_block_gas_units": 9,
2354+
"block_approx_output_size": 0
2355+
},
2356+
"type": "block_epilogue_transaction"
23032357
}
23042358
]

api/test-context/src/test_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ impl TestContext {
842842
self.executor
843843
.commit_blocks(
844844
vec![metadata.id()],
845-
// StateCheckpoint/BlockEpilogue is added on top of the input transactions.
845+
// BlockEpilogue is added on top of the input transactions.
846846
self.new_ledger_info(&metadata, result.root_hash(), txns.len() + 1),
847847
)
848848
.unwrap();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,7 +2648,7 @@ impl AptosVMBlockExecutor {
26482648
state_view: &(impl StateView + Sync),
26492649
config: BlockExecutorConfig,
26502650
transaction_slice_metadata: TransactionSliceMetadata,
2651-
) -> Result<BlockOutput, VMStatus> {
2651+
) -> Result<BlockOutput<TransactionOutput>, VMStatus> {
26522652
fail_point!("aptos_vm_block_executor::execute_block_with_config", |_| {
26532653
Err(VMStatus::error(
26542654
StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR,
@@ -2696,7 +2696,7 @@ impl VMBlockExecutor for AptosVMBlockExecutor {
26962696
state_view: &(impl StateView + Sync),
26972697
onchain_config: BlockExecutorConfigFromOnchain,
26982698
transaction_slice_metadata: TransactionSliceMetadata,
2699-
) -> Result<BlockOutput, VMStatus> {
2699+
) -> Result<BlockOutput<TransactionOutput>, VMStatus> {
27002700
let config = BlockExecutorConfig {
27012701
local: BlockExecutorLocalConfig {
27022702
concurrency_level: AptosVM::get_concurrency_level(),

aptos-move/aptos-vm/src/block_executor/mod.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,28 @@ impl BlockExecutorTransactionOutput for AptosTransactionOutput {
345345
.fee_statement()
346346
}
347347

348+
/// Returns true iff the TransactionsStatus is Retry.
349+
fn is_retry(&self) -> bool {
350+
if let Some(committed_output) = self.committed_output.get() {
351+
committed_output.status().is_retry()
352+
} else {
353+
self.vm_output
354+
.lock()
355+
.as_ref()
356+
.expect("Either vm_output or committed_output must exist.")
357+
.status()
358+
.is_retry()
359+
}
360+
}
361+
362+
/// Returns true iff it has a new epoch event.
363+
fn has_new_epoch_event(&self) -> bool {
364+
self.committed_output
365+
.get()
366+
.expect("Must call after commit.")
367+
.has_new_epoch_event()
368+
}
369+
348370
fn output_approx_size(&self) -> u64 {
349371
let vm_output = self.vm_output.lock();
350372
vm_output
@@ -419,7 +441,7 @@ impl<
419441
config: BlockExecutorConfig,
420442
transaction_slice_metadata: TransactionSliceMetadata,
421443
transaction_commit_listener: Option<L>,
422-
) -> Result<BlockOutput, VMStatus> {
444+
) -> Result<BlockOutput<TransactionOutput>, VMStatus> {
423445
let _timer = BLOCK_EXECUTOR_EXECUTE_BLOCK_SECONDS.start_timer();
424446

425447
let num_txns = signature_verified_block.num_txns();
@@ -446,6 +468,7 @@ impl<
446468
let ret = executor.execute_block(
447469
signature_verified_block,
448470
state_view,
471+
&transaction_slice_metadata,
449472
&mut module_cache_manager_guard,
450473
);
451474
match ret {
@@ -490,7 +513,7 @@ impl<
490513
config: BlockExecutorConfig,
491514
transaction_slice_metadata: TransactionSliceMetadata,
492515
transaction_commit_listener: Option<L>,
493-
) -> Result<BlockOutput, VMStatus> {
516+
) -> Result<BlockOutput<TransactionOutput>, VMStatus> {
494517
Self::execute_block_on_thread_pool::<S, L, TP>(
495518
Arc::clone(&RAYON_EXEC_POOL),
496519
signature_verified_block,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub trait VMBlockExecutor: Send + Sync {
173173
state_view: &(impl StateView + Sync),
174174
onchain_config: BlockExecutorConfigFromOnchain,
175175
transaction_slice_metadata: TransactionSliceMetadata,
176-
) -> Result<BlockOutput, VMStatus>;
176+
) -> Result<BlockOutput<TransactionOutput>, VMStatus>;
177177

178178
/// Executes a block of transactions and returns output for each one of them, without applying
179179
/// any block limit.

aptos-move/block-executor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ rust-version = { workspace = true }
1616
ambassador = { workspace = true }
1717
anyhow = { workspace = true }
1818
aptos-aggregator = { workspace = true }
19+
aptos-crypto = { workspace = true }
1920
aptos-drop-helper = { workspace = true }
2021
aptos-infallible = { workspace = true }
2122
aptos-logger = { workspace = true }

0 commit comments

Comments
 (0)