Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
360 changes: 101 additions & 259 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ paste = "1"
pin-project = "1.1.2"
prometheus = { version = "0.13", features = ["process"] }
prometheus_exporter = "0.8"
prost = { version = "0.11" }
prost = { version = "0.13" }
quickcheck = "1"
quickcheck_async = "0.1"
quickcheck_macros = "1"
Expand Down Expand Up @@ -294,17 +294,17 @@ netwatch = { path = "patches/netwatch" }

frc42_dispatch = { path = "./ext/frc42_dispatch" }

# Using the same tendermint-rs dependency as tower-abci. From both we are interested in v037 modules.
tower-abci = { version = "0.7" }
# Using the same tendermint-rs dependency as tower-abci.
tower-abci = { version = "0.16" }
tower = { version = "0.4" }
tendermint = { version = "0.31", features = ["secp256k1"] }
tendermint-config = "0.33.0"
tendermint-rpc = { version = "0.31", features = [
tendermint = { version = "0.38.1", features = ["secp256k1"] }
tendermint-config = "0.38.1"
tendermint-rpc = { version = "0.38.1", features = [
"secp256k1",
"http-client",
"websocket-client",
] }
tendermint-proto = { version = "0.31" }
tendermint-proto = { version = "0.38.1" }

rust-f3 = { git = "https://github.com/ChainSafe/rust-f3.git", branch = "main" }
filecoin-proofs = { git = "https://github.com/consensus-shipyard/ipc-filecoin-proofs.git", branch = "main" }
Expand Down
1 change: 1 addition & 0 deletions fendermint/abci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license.workspace = true

[dependencies]
async-trait = { workspace = true }
bytes = { workspace = true }
futures = { workspace = true }
tower = "0.4"
tracing = { workspace = true }
Expand Down
64 changes: 44 additions & 20 deletions fendermint/abci/examples/kvstore.rs
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we even need this example?

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use fendermint_abci::{
use structopt::StructOpt;
use tendermint::abci::{request, response, Event, EventAttributeIndexExt};
use tower::ServiceBuilder;
use tower_abci::{split, v037::Server};
use tower_abci::v038::split;
use tower_abci::v038::Server;
use tracing::{info, Level};

// For the sake of example, sho the relationship between buffering, concurrency and block size.
Expand Down Expand Up @@ -95,33 +96,56 @@ impl Application for KVStore {
}
}

async fn deliver_tx(&self, request: request::DeliverTx) -> Result<response::DeliverTx> {
let tx = String::from_utf8(request.tx.to_vec()).unwrap();
let (key, value) = match tx.split('=').collect::<Vec<_>>() {
k if k.len() == 1 => (k[0], k[0]),
kv => (kv[0], kv[1]),
};

atomically(|| {
self.store.update(|mut store| {
store.insert(key.into(), value.into());
store
async fn finalize_block(
&self,
request: request::FinalizeBlock,
) -> Result<response::FinalizeBlock> {
let mut tx_results = Vec::with_capacity(request.txs.len());

for tx in request.txs {
let tx = String::from_utf8(tx.to_vec()).unwrap();
let (key, value) = match tx.split('=').collect::<Vec<_>>() {
k if k.len() == 1 => (k[0], k[0]),
kv => (kv[0], kv[1]),
};

atomically(|| {
self.store.update(|mut store| {
store.insert(key.into(), value.into());
store
})
})
})
.await;
.await;

info!(?key, ?value, "update");
info!(?key, ?value, "update");

Ok(response::DeliverTx {
events: vec![Event::new(
let events = vec![Event::new(
"app",
vec![
("key", key).index(),
("index_key", "index is working").index(),
("noindex_key", "index is working").no_index(),
],
)],
..Default::default()
)];

tx_results.push(tendermint::abci::types::ExecTxResult {
code: tendermint::abci::Code::Ok,
data: Default::default(),
log: Default::default(),
info: Default::default(),
gas_wanted: 0,
gas_used: 0,
events,
codespace: Default::default(),
});
}

Ok(response::FinalizeBlock {
events: Vec::new(),
tx_results,
validator_updates: Vec::new(),
consensus_param_updates: None,
app_hash: Default::default(),
})
}

Expand Down Expand Up @@ -204,7 +228,7 @@ async fn main() {

// Run the ABCI server.
server
.listen(format!("{}:{}", opt.host, opt.port))
.listen_tcp(format!("{}:{}", opt.host, opt.port))
.await
.unwrap();
}
49 changes: 34 additions & 15 deletions fendermint/abci/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
pin::Pin,
task::{Context, Poll},
};
use tendermint::abci::{request, response, Request, Response};
use tendermint::v0_38::abci::{request, response, Request, Response};
use tower::Service;
use tower_abci::BoxError;

Expand Down Expand Up @@ -81,19 +81,33 @@ pub trait Application {
Ok(response::ProcessProposal::Accept)
}

/// Signals the beginning of a new block, prior to any `DeliverTx` calls.
async fn begin_block(&self, request: request::BeginBlock) -> AbciResult<response::BeginBlock> {
Ok(Default::default())
/// Opportunity for the application to add arbitrary extension data to precommit votes.
async fn extend_vote(&self, _request: request::ExtendVote) -> AbciResult<response::ExtendVote> {
Ok(response::ExtendVote {
vote_extension: bytes::Bytes::new(),
})
}

/// Apply a transaction to the application's state.
async fn deliver_tx(&self, request: request::DeliverTx) -> AbciResult<response::DeliverTx> {
Ok(Default::default())
/// Verify vote extensions from peer validators.
async fn verify_vote_extension(
&self,
_request: request::VerifyVoteExtension,
) -> AbciResult<response::VerifyVoteExtension> {
Ok(response::VerifyVoteExtension::Accept)
}

/// Signals the end of a block.
async fn end_block(&self, request: request::EndBlock) -> AbciResult<response::EndBlock> {
Ok(Default::default())
/// Execute and finalize an entire block.
async fn finalize_block(
&self,
_request: request::FinalizeBlock,
) -> AbciResult<response::FinalizeBlock> {
Ok(response::FinalizeBlock {
events: Vec::new(),
tx_results: Vec::new(),
validator_updates: Vec::new(),
consensus_param_updates: None,
app_hash: tendermint::AppHash::default(),
})
}

/// Commit the current state at the current height.
Expand Down Expand Up @@ -174,11 +188,15 @@ where
Request::ProcessProposal(r) => {
Response::ProcessProposal(log_error(app.process_proposal(r).await)?)
}
Request::BeginBlock(r) => {
Response::BeginBlock(log_error(app.begin_block(r).await)?)
Request::ExtendVote(r) => {
Response::ExtendVote(log_error(app.extend_vote(r).await)?)
}
Request::VerifyVoteExtension(r) => {
Response::VerifyVoteExtension(log_error(app.verify_vote_extension(r).await)?)
}
Request::FinalizeBlock(r) => {
Response::FinalizeBlock(log_error(app.finalize_block(r).await)?)
}
Request::DeliverTx(r) => Response::DeliverTx(log_error(app.deliver_tx(r).await)?),
Request::EndBlock(r) => Response::EndBlock(log_error(app.end_block(r).await)?),
Request::Commit => Response::Commit(log_error(app.commit().await)?),
Request::ListSnapshots => {
Response::ListSnapshots(log_error(app.list_snapshots().await)?)
Expand All @@ -192,7 +210,8 @@ where
Request::ApplySnapshotChunk(r) => {
Response::ApplySnapshotChunk(log_error(app.apply_snapshot_chunk(r).await)?)
}
Request::Flush => panic!("Flush should be handled by the Server!"),
// Some clients still send explicit Flush requests; never panic on protocol input.
Request::Flush => Response::Flush,
};
Ok(res)
};
Expand Down
11 changes: 9 additions & 2 deletions fendermint/actors-custom-car/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ fn create_metadata_command(path: impl Into<PathBuf>) -> MetadataCommand {
metadata_command
}

/// Find the `Cargo.lock` relative to the `OUT_DIR` environment variable.
/// Find the `Cargo.lock` by walking parent directories from known anchors.
///
/// If the `Cargo.lock` cannot be found, we emit a warning and return `None`.
/// We first try `OUT_DIR`, then fall back to `CARGO_MANIFEST_DIR`.
/// The fallback is needed when `CARGO_TARGET_DIR` points outside the workspace.
fn find_cargo_lock(out_dir: &Path) -> Option<PathBuf> {
fn find_impl(mut path: PathBuf) -> Option<PathBuf> {
loop {
Expand All @@ -172,6 +173,12 @@ fn find_cargo_lock(out_dir: &Path) -> Option<PathBuf> {
return Some(path);
}

if let Some(manifest_dir) = std::env::var_os("CARGO_MANIFEST_DIR") {
if let Some(path) = find_impl(PathBuf::from(manifest_dir)) {
return Some(path);
}
}

None
}

Expand Down
Loading
Loading