|
1 |
| -use anyhow::Context as _; |
| 1 | +use aptos_api::{ |
| 2 | + get_api_service, |
| 3 | + runtime::{get_apis, Apis}, |
| 4 | + Context, |
| 5 | +}; |
| 6 | +use aptos_config::config::NodeConfig; |
| 7 | +use aptos_crypto::{ed25519::Ed25519PublicKey, HashValue}; |
2 | 8 | use aptos_db::AptosDB;
|
| 9 | +use aptos_executor::{ |
| 10 | + block_executor::BlockExecutor, |
| 11 | + db_bootstrapper::{generate_waypoint, maybe_bootstrap}, |
| 12 | +}; |
3 | 13 | use aptos_executor_types::BlockExecutorTrait;
|
| 14 | +use aptos_mempool::SubmissionStatus; |
4 | 15 | use aptos_mempool::{
|
5 | 16 | core_mempool::{CoreMempool, TimelineState},
|
6 | 17 | MempoolClientRequest, MempoolClientSender,
|
7 | 18 | };
|
| 19 | +use aptos_sdk::types::mempool_status::{MempoolStatus, MempoolStatusCode}; |
| 20 | +use aptos_sdk::types::on_chain_config::{OnChainConsensusConfig, OnChainExecutionConfig}; |
8 | 21 | use aptos_storage_interface::DbReaderWriter;
|
9 | 22 | use aptos_types::{
|
10 |
| - block_executor::{config::BlockExecutorConfigFromOnchain, partitioner::ExecutableBlock}, chain_id::ChainId, transaction::{ |
11 |
| - ChangeSet, SignedTransaction, Transaction, WriteSetPayload |
12 |
| - }, validator_signer::ValidatorSigner |
| 23 | + aggregate_signature::AggregateSignature, |
| 24 | + block_info::BlockInfo, |
| 25 | + ledger_info::{LedgerInfo, LedgerInfoWithSignatures}, |
| 26 | + transaction::Version, |
| 27 | +}; |
| 28 | +use aptos_types::{ |
| 29 | + block_executor::{config::BlockExecutorConfigFromOnchain, partitioner::ExecutableBlock}, |
| 30 | + chain_id::ChainId, |
| 31 | + transaction::{ChangeSet, SignedTransaction, Transaction, WriteSetPayload}, |
| 32 | + validator_signer::ValidatorSigner, |
13 | 33 | };
|
14 | 34 | use aptos_vm::AptosVM;
|
15 |
| -use std::{path::PathBuf, sync::Arc}; |
16 |
| -use tokio::sync::RwLock; |
17 |
| -use aptos_config::config::NodeConfig; |
18 |
| -use aptos_executor::{ |
19 |
| - block_executor::BlockExecutor, |
20 |
| - db_bootstrapper::{generate_waypoint, maybe_bootstrap}, |
| 35 | +use aptos_vm_genesis::{ |
| 36 | + default_gas_schedule, encode_genesis_change_set, GenesisConfiguration, TestValidator, Validator, |
21 | 37 | };
|
22 |
| -use aptos_api::{get_api_service, runtime::{get_apis, Apis}, Context}; |
| 38 | +use movement_types::Commitment; |
| 39 | + |
| 40 | +use anyhow::Context as _; |
23 | 41 | use futures::channel::mpsc as futures_mpsc;
|
24 |
| -use poem::{listener::TcpListener, Route, Server}; |
25 |
| -use aptos_sdk::types::mempool_status::{MempoolStatus, MempoolStatusCode}; |
26 |
| -use aptos_mempool::SubmissionStatus; |
27 | 42 | use futures::StreamExt;
|
28 |
| -use aptos_types::{ |
29 |
| - aggregate_signature::AggregateSignature, |
30 |
| - block_info::BlockInfo, |
31 |
| - ledger_info::{LedgerInfo, LedgerInfoWithSignatures}, |
32 |
| - transaction::Version |
33 |
| -}; |
34 |
| -use aptos_crypto::{ |
35 |
| - ed25519::{Ed25519PrivateKey, Ed25519PublicKey}, |
36 |
| - HashValue |
37 |
| -}; |
38 |
| -use aptos_vm_genesis::{TestValidator, Validator, encode_genesis_change_set, GenesisConfiguration, default_gas_schedule}; |
39 |
| -use aptos_sdk::types::on_chain_config::{ |
40 |
| - OnChainConsensusConfig, OnChainExecutionConfig |
41 |
| -}; |
42 |
| -// use aptos_types::test_helpers::transaction_test_helpers::block; |
| 43 | +use poem::{listener::TcpListener, Route, Server}; |
| 44 | +use tokio::sync::RwLock; |
| 45 | + |
| 46 | +use std::{path::PathBuf, sync::Arc}; |
43 | 47 |
|
44 | 48 | /// The `Executor` is responsible for executing blocks and managing the state of the execution
|
45 | 49 | /// against the `AptosVM`.
|
@@ -253,7 +257,7 @@ impl Executor {
|
253 | 257 | pub async fn execute_block(
|
254 | 258 | &self,
|
255 | 259 | block: ExecutableBlock,
|
256 |
| - ) -> Result<(), anyhow::Error> { |
| 260 | + ) -> Result<Commitment, anyhow::Error> { |
257 | 261 |
|
258 | 262 | let block_id = block.block_id.clone();
|
259 | 263 | let parent_block_id = {
|
@@ -282,14 +286,14 @@ impl Executor {
|
282 | 286 | )?;
|
283 | 287 | }
|
284 | 288 |
|
285 |
| - { |
| 289 | + let proof = { |
286 | 290 | let reader = self.db.read().await.reader.clone();
|
287 |
| - let proof = reader.get_state_proof( |
| 291 | + reader.get_state_proof( |
288 | 292 | state_compute.version(),
|
289 |
| - )?; |
290 |
| - } |
| 293 | + )? |
| 294 | + }; |
291 | 295 |
|
292 |
| - Ok(()) |
| 296 | + Ok(Commitment::digest_state_proof(&proof)) |
293 | 297 | }
|
294 | 298 |
|
295 | 299 | pub async fn try_get_context(&self) -> Result<Arc<Context>, anyhow::Error> {
|
@@ -579,7 +583,9 @@ mod tests {
|
579 | 583 |
|
580 | 584 | // Create and execute the block.
|
581 | 585 | let block = ExecutableBlock::new(block_id.clone(), transactions);
|
582 |
| - executor.execute_block(block).await?; |
| 586 | + let commitment = executor.execute_block(block).await?; |
| 587 | + |
| 588 | + // TODO: verify commitment against the state. |
583 | 589 |
|
584 | 590 | // Access the database reader to verify state after execution.
|
585 | 591 | let db_reader = executor.db.read().await.reader.clone();
|
|
0 commit comments