-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b2f377
commit 6438553
Showing
32 changed files
with
465 additions
and
89 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "aptos-block-executor" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
# internal | ||
movement-sdk = { workspace = true } | ||
|
||
# general | ||
anyhow = { workspace = true } | ||
async-trait = { workspace = true } | ||
tokio = { workspace = true } | ||
|
||
# aptos | ||
aptos-executor = { workspace = true } | ||
aptos-types = { workspace = true } | ||
aptos-vm = { workspace = true } | ||
aptos-helper-types = { workspace = true } |
95 changes: 95 additions & 0 deletions
95
movement-sdk/execution/aptos-block-executor/src/aptos_block_executor.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
use tokio::sync::RwLock; | ||
use std::sync::Arc; | ||
use aptos_executor::block_executor::BlockExecutor; | ||
use aptos_types::transaction::Transaction; | ||
use aptos_vm::AptosVM; | ||
use movement_sdk::{ExecutionLayer, Layer}; | ||
use aptos_helper_types::block::Block; | ||
|
||
|
||
#[derive(Clone)] | ||
pub struct AptosBlockExecutor { | ||
pub executor: Arc<RwLock<BlockExecutor<AptosVM>>>, | ||
} | ||
|
||
impl std::fmt::Debug for AptosBlockExecutor { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
f.debug_struct("AptosBlockExecutor") | ||
.finish() | ||
} | ||
} | ||
|
||
impl AptosBlockExecutor { | ||
pub fn new(executor: Arc<RwLock<BlockExecutor<AptosVM>>>) -> Self { | ||
AptosBlockExecutor { executor } | ||
} | ||
} | ||
|
||
impl Layer for AptosBlockExecutor {} | ||
|
||
#[async_trait::async_trait] | ||
impl ExecutionLayer for AptosBlockExecutor { | ||
|
||
type Block = Block; | ||
type BlockId = String; // todo: change later | ||
type ChangeSet = u64; // todo: change later | ||
|
||
// Gets the next block from the previous layer. | ||
async fn get_next_block( | ||
&self | ||
) -> Result<Option<Self::Block>, anyhow::Error> { | ||
unimplemented!(); | ||
} | ||
|
||
// Executes a block and produces a change set. | ||
async fn execute_block( | ||
&self, | ||
block: Self::Block | ||
) -> Result<Self::ChangeSet, anyhow::Error> { | ||
|
||
let mut executor = self.executor.write().await; | ||
// let parent_block_id_now = executor.committed_block_id(); | ||
|
||
// todo: update for aptos 1.70 | ||
/*// execute the block | ||
let output = executor | ||
.execute_block((block_id, block_tx.clone()), parent_block_id) | ||
.unwrap(); | ||
// sign for the the ledger | ||
let ledger_info = LedgerInfo::new( | ||
BlockInfo::new( | ||
next_epoch, | ||
0, | ||
block_id, | ||
output.root_hash(), | ||
output.version(), | ||
ts, | ||
output.epoch_state().clone(), | ||
), | ||
HashValue::zero(), | ||
); | ||
let li = generate_ledger_info_with_sig(&[self.signer.as_ref().unwrap().clone()], ledger_info); | ||
executor.commit_blocks(vec![block_id], li.clone()).unwrap();*/ | ||
|
||
Ok(0) | ||
|
||
} | ||
|
||
// Sends a change set to the next layer, i.e., the storage layer. | ||
async fn send_change_set( | ||
&self, | ||
change_set: Self::ChangeSet | ||
) -> Result<(), anyhow::Error> { | ||
unimplemented!(); | ||
} | ||
|
||
// Gets an executed block | ||
async fn get_block( | ||
&self, | ||
block_id: Self::BlockId | ||
) -> Result<Option<Self::Block>, anyhow::Error> { | ||
unimplemented!(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod aptos_block_executor; |
16 changes: 16 additions & 0 deletions
16
movement-sdk/execution/canonical-block-executor/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "canonical-block-executor" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
# internal | ||
movement-sdk = { workspace = true } | ||
|
||
# general | ||
anyhow = { workspace = true } | ||
async-trait = { workspace = true } | ||
tokio = { workspace = true } | ||
aptos-helper-types = { workspace = true } |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.