Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENG-326: Full Node Commitments #58

Merged
merged 113 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
e61c112
fix: adding stub.
l-monninger May 13, 2024
8228d24
Merge branch 'l-monninger/ci-fix' into eng-326/full-node-commitments
l-monninger May 13, 2024
bd6c85d
fix: remove duplicate trait.
l-monninger May 13, 2024
15c7781
fix: cleanup.
l-monninger May 13, 2024
e4a5b65
mcr-settlement-client: fmt
mzabaluev May 13, 2024
c225540
Merge branch 'main' into eng-326/full-node-commitments
mzabaluev May 13, 2024
eee8edd
movement-types: Commitment from StateProof
mzabaluev May 13, 2024
edc750f
opt-executor: reorder use statements
mzabaluev May 13, 2024
1e5d803
Return Commitment from executors' execute_block
mzabaluev May 13, 2024
4c38cc2
fix: drop contracts.
l-monninger May 14, 2024
04972b7
Merge branch '0xmovses/ENG-317-implement-mcr-contracts' into eng-326/…
l-monninger May 14, 2024
b1a41ba
fix: swap tonic for async trait.
l-monninger May 14, 2024
1f6792d
fix: merge.
l-monninger May 14, 2024
959fbbb
feat: add max tolerable height.
l-monninger May 14, 2024
2753f1d
feat: Instantiate MCR settlement client
mzabaluev May 14, 2024
6c7670c
Merge branch 'main' into eng-326/full-node-commitments
mzabaluev May 14, 2024
01cd707
Return BlockCommitment from execute_block
mzabaluev May 14, 2024
aad48b8
feat(suzuka-full-node): settle block commitments
mzabaluev May 14, 2024
de96f0d
print error returned by process_commitment
mzabaluev May 15, 2024
843822a
Use get_max_tolerable_block_height
mzabaluev May 15, 2024
ac810cc
chore: cleanup.
l-monninger May 15, 2024
b4e8b43
feat: m1-da-light-node.
l-monninger May 15, 2024
a231b16
fix: remove vendors.
l-monninger May 16, 2024
2f35240
fix: trying top-level.
l-monninger May 16, 2024
b747d43
fix: moving back into ./nix.
l-monninger May 16, 2024
0899b94
docker: works.
l-monninger May 16, 2024
6a46edb
suzuka-full-node: process settled commitments
mzabaluev May 16, 2024
60330fe
test(opt-executor): verify block commitment
mzabaluev May 16, 2024
a36219e
Merge branch 'main' into eng-326/full-node-commitments
mzabaluev May 16, 2024
0e96fb6
opt-executor: use version from state compute
mzabaluev May 16, 2024
92b1dd1
fix: testing nix.
l-monninger May 16, 2024
9e15013
Merge branch 'eng-326/full-node-commitments' of https://github.com/mo…
l-monninger May 16, 2024
6c6a2d8
feat: scaffolding and u8; 32.
l-monninger May 16, 2024
a0ebf39
refactor(opt-executor): method to helper fn
mzabaluev May 16, 2024
0739632
Implement Commitment::digest_state_proof
mzabaluev May 16, 2024
eab891c
opt-executor: try different way for block height
mzabaluev May 16, 2024
da3fdbe
fix: docker.
l-monninger May 16, 2024
9a1dfac
example: bad test.
l-monninger May 16, 2024
c8edb4a
fix: passing test.
l-monninger May 16, 2024
608b947
fix: working on docker.
May 17, 2024
cbf1cfb
Merge branch 'docker/docker-nix' of github.com:movementlabsxyz/moveme…
May 17, 2024
db80751
fix: bash.
May 17, 2024
2796ca0
Merge branch 'main' into docker/docker-nix
May 17, 2024
3dd9ac6
feat: add docker image flow.
May 17, 2024
ef3dc9f
fix: should be named containers.
May 17, 2024
cc67080
fix: should be named containers.
May 17, 2024
f14f6be
fix: see if shell: bash fixes.
May 17, 2024
dc2a94f
fix: dropping /usr/bin/env for now.
May 17, 2024
0344a20
opt-executor: copy block metadata trick
mzabaluev May 17, 2024
b013d3e
mcr-settlement-manager: flesh out logic
mzabaluev May 17, 2024
bdcfb37
mcr-settlement-manager: revamp API
mzabaluev May 17, 2024
98ee88d
fix: bumping to docker login v3.
May 18, 2024
4c2231e
fix: bumping to docker login v3.
May 18, 2024
e073e33
fix: cleanup.
May 18, 2024
cfef413
fix: trying build then push.
May 18, 2024
fb2558e
fix: build.
May 18, 2024
dcb82bf
fix: execution concurrency bug.
May 18, 2024
c5376dc
fix: cleanup.
May 18, 2024
3815e9a
feat: trying with scratch.
May 18, 2024
3880d1b
fix: should not be copying result.
May 18, 2024
b92f0a1
fix: try with scratch.
May 18, 2024
79557bf
feat: use build stages with nixos.
l-monninger May 18, 2024
e89dcc1
fix: use build dir
l-monninger May 18, 2024
2a689d6
fix: compare release binaries
l-monninger May 18, 2024
f588553
feat: with select binaries.
l-monninger May 19, 2024
28590a6
feat: explicit buildx.
l-monninger May 19, 2024
bbc5576
feat: without builder.
l-monninger May 19, 2024
ee09836
feat: copy nix.
l-monninger May 19, 2024
a051793
mcr-settlement-manager: basic test
mzabaluev May 20, 2024
f53a83c
opt-executor: gracefully handle empty block
mzabaluev May 20, 2024
b7f1eb1
mcr-settlement-client: convert stub to mock
mzabaluev May 20, 2024
56f408f
mcr-settlement-manager: test commit rejection
mzabaluev May 20, 2024
0f1c2f8
suzuka-full-node: use the mock MCR client
mzabaluev May 20, 2024
dc7de5e
mcr-settlement-manager: fix up doc
mzabaluev May 20, 2024
5803533
feat: native builds.
l-monninger May 20, 2024
0520669
suzuka-full-node: fix crate dependency
mzabaluev May 20, 2024
7cb00d1
fix: keep all context.
l-monninger May 20, 2024
ea3796a
feat: better usage.
l-monninger May 20, 2024
5ef76f4
fix: m1-da-light-node needs defaults.
l-monninger May 20, 2024
b6eda06
Change monza scripts to suzuka
mzabaluev May 20, 2024
089bd51
feat: prebuild aptos-faucet-service.
l-monninger May 20, 2024
c17c398
fix: use ubuntu-latest instead of movement-runner.
l-monninger May 21, 2024
6c280b4
feat: reduced logging.
l-monninger May 21, 2024
ea0b632
fix: merge.
l-monninger May 21, 2024
e63b9c6
fix: merge.
l-monninger May 21, 2024
898e12c
fix: reduced logging.
l-monninger May 21, 2024
55f6e54
fix: monza should not be called suzuka.
l-monninger May 21, 2024
47423a4
fix: quieter logging.
l-monninger May 21, 2024
709761c
fix: use FATAL instead of DPANIC.
l-monninger May 21, 2024
0ff96c0
fix: timestamp.
l-monninger May 21, 2024
2af0c7a
fix: bad mergee.
l-monninger May 21, 2024
6446569
CI: run suzuka-full-node tests
mzabaluev May 22, 2024
03e626e
fix: prebuild.
l-monninger May 22, 2024
489d7c8
Fix up naming in suzuka scripts again
mzabaluev May 22, 2024
bdc0388
CI: disable MOVEMENT_PREBUILT
mzabaluev May 22, 2024
8a332be
CI: don't run prebuild script
mzabaluev May 22, 2024
76fce46
scripts: fix up m1-da-light-node build
mzabaluev May 23, 2024
2719489
scripts: restore monza-aptos naming
mzabaluev May 23, 2024
9ca5b08
CI: print available filesystem space
mzabaluev May 23, 2024
e8d9dca
fix: movement-runner down to debug.
l-monninger May 23, 2024
a0c7681
fix: bad prebuild of aptos-faucet-service.
l-monninger May 23, 2024
abd1bb7
fix: drop containers from ci for now.
l-monninger May 23, 2024
2c2a2ec
fix: missing block metadata.
l-monninger May 23, 2024
6dc612f
opt-executor: refactor execute_block_inner
mzabaluev May 23, 2024
146c51d
Implement get_block_head_height in executors
mzabaluev May 23, 2024
f0abc03
opt-executor: fix up compile
mzabaluev May 24, 2024
47e90a5
streamline logging
mzabaluev May 24, 2024
06ce28d
chore: remove and ignore MCR contract logs
mzabaluev May 24, 2024
fae30be
suzuka-executor: sanity-test block commitment
mzabaluev May 24, 2024
63726a0
mcr-settlement-client: rename settle method
mzabaluev May 27, 2024
b4999b3
mcr-settlement-client: pause and resume for mock
mzabaluev May 27, 2024
df9cb38
mcr-settlement-manager: test back pressure
mzabaluev May 27, 2024
e5feea0
m1-da-light-node: expanded FIXME comment
mzabaluev May 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# global
* @l-monninger @andyjsbell @0xmovses @mzabaluev
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ members = [

"protocol-units/mempool/*",

"protocol-units/settlement/mcr/client",

"util/*",
"util/buildtime/buildtime-helpers",
"util/buildtime/buildtime-macros",
Expand Down Expand Up @@ -61,6 +63,8 @@ m1-da-light-node-grpc = { path = "protocol-units/da/m1/light-node-grpc" }
m1-da-light-node-util = { path = "protocol-units/da/m1/util" }
m1-da-light-node-verifier = { path = "protocol-units/da/m1/light-node-verifier" }
m1-da-light-node-client = { path = "protocol-units/da/m1/light-node-client" }
## settlement
mcr-settlement-client = { path = "protocol-units/settlement/mcr/client" }
## mempool
mempool-util = { path = "protocol-units/mempool/util" }
move-rocks = { path = "protocol-units/mempool/move-rocks" }
Expand Down
25 changes: 25 additions & 0 deletions PR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Summary
- **Status**: `draft` <!-- `review`, `suspended` -->
- **RFCs**: [Link to RFC](#./link/to/rfc), [Link to RFC](#./link/to/rfc), or $\emptyset$.
- **Categories**: any of `protocol-units`, `networks`, `scripts`, `util`, `cicd`, or `misc`.

<!--
Add your summary text here.
-->

# Changelog

<!--
Describe your changes. List roughly in order of importance.
-->

# Testing

<!--
Describe your Test Plan and explain added or modified test components.
-->

# Outstanding issues
<!--
List any outstanding issues that need to be addressed in future PRs, but which do not block merging this PR.
-->
26 changes: 14 additions & 12 deletions networks/monza/monza-full-node/src/partial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ impl <T : MonzaExecutor + Send + Sync + Clone>MonzaPartialNode<T> {
}
}

pub async fn bind_transaction_channel(&mut self) -> Result<(), anyhow::Error> {
self.executor.set_tx_channel(self.transaction_sender.clone()).await?;
Ok(())
}

pub async fn bound(executor : T, light_node_client: LightNodeServiceClient<tonic::transport::Channel>) -> Result<Self, anyhow::Error> {
let mut node = Self::new(executor, light_node_client);
node.bind_transaction_channel().await?;
Ok(node)
}
fn bind_transaction_channel(&mut self) {
self.executor.set_tx_channel(self.transaction_sender.clone());
}

pub fn bound(
executor: T,
light_node_client: LightNodeServiceClient<tonic::transport::Channel>,
) -> Result<Self, anyhow::Error> {
let mut node = Self::new(executor, light_node_client);
node.bind_transaction_channel();
Ok(node)
}

pub async fn tick_write_transactions_to_da(&self) -> Result<(), anyhow::Error> {

Expand Down Expand Up @@ -166,7 +168,7 @@ impl <T : MonzaExecutor + Send + Sync + Clone>MonzaPartialNode<T> {
);
let block_id = executable_block.block_id;
self.executor.execute_block(
&FinalityMode::Opt,
FinalityMode::Opt,
executable_block
).await?;

Expand Down Expand Up @@ -225,7 +227,7 @@ impl MonzaPartialNode<MonzaExecutorV1> {
let executor = MonzaExecutorV1::try_from_env(tx).await.context(
"Failed to get executor from environment"
)?;
Self::bound(executor, light_node_client).await
Self::bound(executor, light_node_client)
}

}
1 change: 1 addition & 0 deletions networks/suzuka/suzuka-full-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rust-version = { workspace = true }
[dependencies]
suzuka-executor = { workspace = true }
m1-da-light-node-client = { workspace = true }
mcr-settlement-client = { workspace = true }
async-channel = { workspace = true }
serde_json = { workspace = true }
anyhow = { workspace = true }
Expand Down
97 changes: 75 additions & 22 deletions networks/suzuka/suzuka-full-node/src/partial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,54 @@ use async_channel::{Sender, Receiver};
use sha2::Digest;
use crate::*;
use tokio_stream::StreamExt;
use tokio::sync::mpsc::{self, error::TrySendError};
use tokio::sync::RwLock;
use movement_types::Block;

use movement_types::{Block, BlockCommitment};
use mcr_settlement_client::{McrSettlementClient, McrSettlementClientOperations};

#[derive(Clone)]
pub struct SuzukaPartialNode<T : SuzukaExecutor + Send + Sync + Clone> {
pub struct SuzukaPartialNode<T, C>
{
executor: T,
transaction_sender : Sender<SignedTransaction>,
pub transaction_receiver : Receiver<SignedTransaction>,
light_node_client: Arc<RwLock<LightNodeServiceClient<tonic::transport::Channel>>>,
settlement_client: Arc<C>,
}

impl <T : SuzukaExecutor + Send + Sync + Clone>SuzukaPartialNode<T> {

pub fn new(executor : T, light_node_client: LightNodeServiceClient<tonic::transport::Channel>) -> Self {
impl<T, C> SuzukaPartialNode<T, C>
where
T: SuzukaExecutor + Send + Sync,
C: McrSettlementClientOperations + Send + Sync + 'static,
{

pub fn new(
executor: T,
light_node_client: LightNodeServiceClient<tonic::transport::Channel>,
settlement_client: C,
) -> Self {
let (transaction_sender, transaction_receiver) = async_channel::unbounded();
Self {
executor : executor,
transaction_sender,
transaction_receiver,
light_node_client : Arc::new(RwLock::new(light_node_client)),
settlement_client: Arc::new(settlement_client)
}
}

pub async fn bind_transaction_channel(&mut self) -> Result<(), anyhow::Error> {
self.executor.set_tx_channel(self.transaction_sender.clone()).await?;
Ok(())
}

pub async fn bound(executor : T, light_node_client: LightNodeServiceClient<tonic::transport::Channel>) -> Result<Self, anyhow::Error> {
let mut node = Self::new(executor, light_node_client);
node.bind_transaction_channel().await?;
Ok(node)
fn bind_transaction_channel(&mut self) {
self.executor.set_tx_channel(self.transaction_sender.clone());
}

pub fn bound(
executor: T,
light_node_client: LightNodeServiceClient<tonic::transport::Channel>,
settlement_client: C,
) -> Result<Self, anyhow::Error> {
let mut node = Self::new(executor, light_node_client, settlement_client);
node.bind_transaction_channel();
Ok(node)
}

pub async fn tick_write_transactions_to_da(&self) -> Result<(), anyhow::Error> {
Expand Down Expand Up @@ -108,9 +123,11 @@ impl <T : SuzukaExecutor + Send + Sync + Clone>SuzukaPartialNode<T> {
// receive transactions from the transaction channel and send them to be executed
// ! This assumes the m1 da light node is running sequencer mode
pub async fn read_blocks_from_da(&self) -> Result<(), anyhow::Error> {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's turn those comments into doc comments

let block_head_height = self.executor.get_block_head_height().await?;


let (sender, receiver) = mpsc::channel(16);

let mut stream = {
let client_ptr = self.light_node_client.clone();
let mut light_node_client = client_ptr.write().await;
Expand All @@ -121,6 +138,14 @@ impl <T : SuzukaExecutor + Send + Sync + Clone>SuzukaPartialNode<T> {
).await?
}.into_inner();

let settlement_client = self.settlement_client.clone();
// TODO: consume the commitment stream to finalize blocks
let commitment_stream = settlement_client.stream_block_commitments().await?;

tokio::spawn(async move {
process_commitments(receiver, settlement_client).await;
});
mzabaluev marked this conversation as resolved.
Show resolved Hide resolved

while let Some(blob) = stream.next().await {

println!("Stream hot!");
Expand Down Expand Up @@ -165,13 +190,22 @@ impl <T : SuzukaExecutor + Send + Sync + Clone>SuzukaPartialNode<T> {
block
);
let block_id = executable_block.block_id;
self.executor.execute_block(
&FinalityMode::Opt,
let commitment = self.executor.execute_block(
FinalityMode::Opt,
executable_block
).await?;

println!("Executed block: {:?}", block_id);

match sender.try_send(commitment) {
Ok(_) => {},
Err(TrySendError::Closed(_)) => {
break;
},
Err(TrySendError::Full(_commitment)) => {
println!("Commitment channel full, dropping commitment");
}
}
}

Ok(())
Expand All @@ -180,7 +214,25 @@ impl <T : SuzukaExecutor + Send + Sync + Clone>SuzukaPartialNode<T> {

}

impl <T : SuzukaExecutor + Send + Sync + Clone>SuzukaFullNode for SuzukaPartialNode<T> {
async fn process_commitments<C>(
mut receiver: mpsc::Receiver<BlockCommitment>,
settlement_client: Arc<C>,
) -> Result<(), anyhow::Error>
where
C: McrSettlementClientOperations,
{
while let Some(commitment) = receiver.recv().await {
println!("Got commitment: {:?}", commitment);
settlement_client.post_block_commitment(commitment).await?;
}
Ok(())
}

impl<T, C> SuzukaFullNode for SuzukaPartialNode<T, C>
where
T: SuzukaExecutor + Send + Sync,
C: McrSettlementClientOperations + Send + Sync + 'static,
{

/// Runs the services until crash or shutdown.
async fn run_services(&self) -> Result<(), anyhow::Error> {
Expand Down Expand Up @@ -217,15 +269,16 @@ impl <T : SuzukaExecutor + Send + Sync + Clone>SuzukaFullNode for SuzukaPartialN

}

impl SuzukaPartialNode<SuzukaExecutorV1> {
impl SuzukaPartialNode<SuzukaExecutorV1, McrSettlementClient> {

pub async fn try_from_env() -> Result<Self, anyhow::Error> {
let (tx, _) = async_channel::unbounded();
let light_node_client = LightNodeServiceClient::connect("http://[::1]:30730").await?;
let executor = SuzukaExecutorV1::try_from_env(tx).await.context(
"Failed to get executor from environment"
)?;
Self::bound(executor, light_node_client).await
let settlement_client = McrSettlementClient::new();
Self::bound(executor, light_node_client, settlement_client)
}

}
5 changes: 3 additions & 2 deletions protocol-units/execution/maptos/opt-executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ tokio = { workspace = true }
rand = { workspace = true }
rand_core = { workspace = true }
bcs = { workspace = true}
futures = { workspace = true }
async-channel = { workspace = true }

aptos-vm = { workspace = true }
aptos-config = { workspace = true }
Expand All @@ -58,9 +60,8 @@ aptos-mempool = { workspace = true }
aptos-temppath = { workspace = true }
aptos-faucet-core = { workspace = true }
aptos-cached-packages = { workspace = true }
futures = { workspace = true }
async-channel = { workspace = true }
maptos-execution-util = { workspace = true }
movement-types = { workspace = true }

dirs = { workspace = true }
tempfile = { workspace = true }
Expand Down
Loading
Loading