Skip to content

Commit 1f6792d

Browse files
committed
fix: merge.
2 parents b1a41ba + 1e5d803 commit 1f6792d

File tree

13 files changed

+163
-129
lines changed

13 files changed

+163
-129
lines changed

Cargo.lock

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protocol-units/execution/maptos/opt-executor/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ tokio = { workspace = true }
3333
rand = { workspace = true }
3434
rand_core = { workspace = true }
3535
bcs = { workspace = true}
36+
futures = { workspace = true }
37+
async-channel = { workspace = true }
3638

3739
aptos-vm = { workspace = true }
3840
aptos-config = { workspace = true }
@@ -58,9 +60,8 @@ aptos-mempool = { workspace = true }
5860
aptos-temppath = { workspace = true }
5961
aptos-faucet-core = { workspace = true }
6062
aptos-cached-packages = { workspace = true }
61-
futures = { workspace = true }
62-
async-channel = { workspace = true }
6363
maptos-execution-util = { workspace = true }
64+
movement-types = { workspace = true }
6465

6566
dirs = { workspace = true }
6667
tempfile = { workspace = true }

protocol-units/execution/maptos/opt-executor/src/executor.rs

+42-36
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,49 @@
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};
28
use aptos_db::AptosDB;
9+
use aptos_executor::{
10+
block_executor::BlockExecutor,
11+
db_bootstrapper::{generate_waypoint, maybe_bootstrap},
12+
};
313
use aptos_executor_types::BlockExecutorTrait;
14+
use aptos_mempool::SubmissionStatus;
415
use aptos_mempool::{
516
core_mempool::{CoreMempool, TimelineState},
617
MempoolClientRequest, MempoolClientSender,
718
};
19+
use aptos_sdk::types::mempool_status::{MempoolStatus, MempoolStatusCode};
20+
use aptos_sdk::types::on_chain_config::{OnChainConsensusConfig, OnChainExecutionConfig};
821
use aptos_storage_interface::DbReaderWriter;
922
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,
1333
};
1434
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,
2137
};
22-
use aptos_api::{get_api_service, runtime::{get_apis, Apis}, Context};
38+
use movement_types::Commitment;
39+
40+
use anyhow::Context as _;
2341
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;
2742
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};
4347

4448
/// The `Executor` is responsible for executing blocks and managing the state of the execution
4549
/// against the `AptosVM`.
@@ -253,7 +257,7 @@ impl Executor {
253257
pub async fn execute_block(
254258
&self,
255259
block: ExecutableBlock,
256-
) -> Result<(), anyhow::Error> {
260+
) -> Result<Commitment, anyhow::Error> {
257261

258262
let block_id = block.block_id.clone();
259263
let parent_block_id = {
@@ -282,14 +286,14 @@ impl Executor {
282286
)?;
283287
}
284288

285-
{
289+
let proof = {
286290
let reader = self.db.read().await.reader.clone();
287-
let proof = reader.get_state_proof(
291+
reader.get_state_proof(
288292
state_compute.version(),
289-
)?;
290-
}
293+
)?
294+
};
291295

292-
Ok(())
296+
Ok(Commitment::digest_state_proof(&proof))
293297
}
294298

295299
pub async fn try_get_context(&self) -> Result<Arc<Context>, anyhow::Error> {
@@ -579,7 +583,9 @@ mod tests {
579583

580584
// Create and execute the block.
581585
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.
583589

584590
// Access the database reader to verify state after execution.
585591
let db_reader = executor.db.read().await.reader.clone();

protocol-units/execution/monza/executor/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ aptos-proptest-helpers = { workspace = true }
6363

6464
maptos-opt-executor = { workspace = true }
6565
maptos-execution-util = { workspace = true }
66+
movement-types = { workspace = true }
6667

6768
dirs = "5.0.1"
6869
tempfile = "3.10.1"

protocol-units/execution/monza/executor/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ pub use aptos_types::{
77
transaction::{SignedTransaction, Transaction}
88
};
99
pub use aptos_crypto::hash::HashValue;
10-
use async_channel::Sender;
1110
use aptos_api::runtime::Apis;
11+
1212
pub use maptos_execution_util::FinalityMode;
13+
use movement_types::Commitment;
1314

15+
use async_channel::Sender;
1416

1517
#[tonic::async_trait]
1618
pub trait MonzaExecutor {
@@ -26,7 +28,7 @@ pub trait MonzaExecutor {
2628
&self,
2729
mode : &FinalityMode,
2830
block: ExecutableBlock,
29-
) -> Result<(), anyhow::Error>;
31+
) -> Result<Commitment, anyhow::Error>;
3032

3133
/// Sets the transaction channel.
3234
async fn set_tx_channel(&mut self, tx_channel: Sender<SignedTransaction>) -> Result<(), anyhow::Error>;

protocol-units/execution/monza/executor/src/v1.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::*;
22
use aptos_types::transaction::SignedTransaction;
33
use async_channel::Sender;
44
use maptos_opt_executor::Executor;
5+
use movement_types::Commitment;
56

67
#[derive(Clone)]
78
pub struct MonzaExecutorV1 {
@@ -45,7 +46,7 @@ impl MonzaExecutor for MonzaExecutorV1 {
4546
&self,
4647
mode: &FinalityMode,
4748
block: ExecutableBlock,
48-
) -> Result<(), anyhow::Error> {
49+
) -> Result<Commitment, anyhow::Error> {
4950
match mode {
5051
FinalityMode::Dyn => unimplemented!(),
5152
FinalityMode::Opt => {

protocol-units/execution/suzuka/executor/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ aptos-temppath = { workspace = true }
6262

6363
maptos-opt-executor = { workspace = true }
6464
maptos-execution-util = { workspace = true }
65+
movement-types = { workspace = true }
6566

6667
dirs = "5.0.1"
6768
tempfile = "3.10.1"

protocol-units/execution/suzuka/executor/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ pub use aptos_types::{
77
transaction::{SignedTransaction, Transaction}
88
};
99
pub use aptos_crypto::hash::HashValue;
10-
use async_channel::Sender;
1110
use aptos_api::runtime::Apis;
11+
1212
pub use maptos_execution_util::FinalityMode;
13+
use movement_types::Commitment;
1314

15+
use async_channel::Sender;
1416

1517
#[tonic::async_trait]
1618
pub trait SuzukaExecutor {
@@ -26,7 +28,7 @@ pub trait SuzukaExecutor {
2628
&self,
2729
mode : &FinalityMode,
2830
block: ExecutableBlock,
29-
) -> Result<(), anyhow::Error>;
31+
) -> Result<Commitment, anyhow::Error>;
3032

3133
/// Sets the transaction channel.
3234
async fn set_tx_channel(&mut self, tx_channel: Sender<SignedTransaction>) -> Result<(), anyhow::Error>;

protocol-units/execution/suzuka/executor/src/v1.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::*;
22
use maptos_opt_executor::Executor;
33
use async_channel::Sender;
44
use aptos_types::transaction::SignedTransaction;
5+
use movement_types::Commitment;
56

67
#[derive(Clone)]
78
pub struct SuzukaExecutorV1 {
@@ -50,7 +51,7 @@ impl SuzukaExecutor for SuzukaExecutorV1 {
5051
&self,
5152
mode : &FinalityMode,
5253
block: ExecutableBlock,
53-
) -> Result<(), anyhow::Error> {
54+
) -> Result<Commitment, anyhow::Error> {
5455

5556
match mode {
5657
FinalityMode::Dyn => unimplemented!(),
@@ -138,7 +139,7 @@ mod opt_tests {
138139
#[tokio::test]
139140
async fn test_execute_opt_block() -> Result<(), anyhow::Error> {
140141
let (tx, rx) = async_channel::unbounded();
141-
let mut executor = SuzukaExecutorV1::try_from_env(tx).await?;
142+
let executor = SuzukaExecutorV1::try_from_env(tx).await?;
142143
let block_id = HashValue::random();
143144
let tx = SignatureVerifiedTransaction::Valid(Transaction::UserTransaction(
144145
create_signed_transaction(0),
@@ -228,7 +229,11 @@ mod opt_tests {
228229
));
229230
let txs = ExecutableTransactions::Unsharded(vec![tx]);
230231
let block = ExecutableBlock::new(block_id.clone(), txs);
231-
executor.execute_block(&FinalityMode::Opt, block).await?;
232+
let commitment = executor.execute_block(&FinalityMode::Opt, block).await?;
233+
234+
println!("Commitment: {:?}", commitment);
235+
236+
// TODO: test the commitment
232237

233238
services_handle.abort();
234239
background_handle.abort();

protocol-units/settlement/mcr/client/src/lib.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ pub mod stub;
77
#[cfg(feature = "stub")]
88
pub use stub::*;
99

10-
11-
type CommitmentStream = std::pin::Pin<Box<dyn Stream<Item = Result<BlockCommitment, anyhow::Error>> + Send>>;
10+
type CommitmentStream =
11+
std::pin::Pin<Box<dyn Stream<Item = Result<BlockCommitment, anyhow::Error>> + Send>>;
1212

1313
#[async_trait::async_trait]
1414
pub trait McrSettlementClientOperations {
15-
16-
async fn post_block_commitment(&self, block_commitment : BlockCommitment) -> Result<(), anyhow::Error>;
15+
16+
async fn post_block_commitment(
17+
&self,
18+
block_commitment: BlockCommitment,
19+
) -> Result<(), anyhow::Error>;
1720

1821
async fn post_block_commitment_batch(&self, block_commitment: Vec<BlockCommitment>) -> Result<(), anyhow::Error>;
1922

20-
async fn stream_block_commitments(&self) -> Result<
21-
CommitmentStream,
22-
anyhow::Error
23-
>;
23+
async fn stream_block_commitments(&self) -> Result<CommitmentStream, anyhow::Error>;
2424

2525
async fn get_commitment_at_height(&self, height : u64) -> Result<Option<BlockCommitment>, anyhow::Error>;
2626

27-
}
27+
}

0 commit comments

Comments
 (0)