Skip to content

Commit 8fd1750

Browse files
authored
feat: upgrade to comet bft 0.38 (#1554)
1 parent 699d1d6 commit 8fd1750

23 files changed

Lines changed: 442 additions & 558 deletions

File tree

Cargo.lock

Lines changed: 101 additions & 259 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ paste = "1"
183183
pin-project = "1.1.2"
184184
prometheus = { version = "0.13", features = ["process"] }
185185
prometheus_exporter = "0.8"
186-
prost = { version = "0.11" }
186+
prost = { version = "0.13" }
187187
quickcheck = "1"
188188
quickcheck_async = "0.1"
189189
quickcheck_macros = "1"
@@ -294,17 +294,17 @@ netwatch = { path = "patches/netwatch" }
294294

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

297-
# Using the same tendermint-rs dependency as tower-abci. From both we are interested in v037 modules.
298-
tower-abci = { version = "0.7" }
297+
# Using the same tendermint-rs dependency as tower-abci.
298+
tower-abci = { version = "0.16" }
299299
tower = { version = "0.4" }
300-
tendermint = { version = "0.31", features = ["secp256k1"] }
301-
tendermint-config = "0.33.0"
302-
tendermint-rpc = { version = "0.31", features = [
300+
tendermint = { version = "0.38.1", features = ["secp256k1"] }
301+
tendermint-config = "0.38.1"
302+
tendermint-rpc = { version = "0.38.1", features = [
303303
"secp256k1",
304304
"http-client",
305305
"websocket-client",
306306
] }
307-
tendermint-proto = { version = "0.31" }
307+
tendermint-proto = { version = "0.38.1" }
308308

309309
rust-f3 = { git = "https://github.com/ChainSafe/rust-f3.git", branch = "main" }
310310
filecoin-proofs = { git = "https://github.com/consensus-shipyard/ipc-filecoin-proofs.git", branch = "main" }

fendermint/abci/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ license.workspace = true
88

99
[dependencies]
1010
async-trait = { workspace = true }
11+
bytes = { workspace = true }
1112
futures = { workspace = true }
1213
tower = "0.4"
1314
tracing = { workspace = true }

fendermint/abci/examples/kvstore.rs

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ use fendermint_abci::{
1010
use structopt::StructOpt;
1111
use tendermint::abci::{request, response, Event, EventAttributeIndexExt};
1212
use tower::ServiceBuilder;
13-
use tower_abci::{split, v037::Server};
13+
use tower_abci::v038::split;
14+
use tower_abci::v038::Server;
1415
use tracing::{info, Level};
1516

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

98-
async fn deliver_tx(&self, request: request::DeliverTx) -> Result<response::DeliverTx> {
99-
let tx = String::from_utf8(request.tx.to_vec()).unwrap();
100-
let (key, value) = match tx.split('=').collect::<Vec<_>>() {
101-
k if k.len() == 1 => (k[0], k[0]),
102-
kv => (kv[0], kv[1]),
103-
};
104-
105-
atomically(|| {
106-
self.store.update(|mut store| {
107-
store.insert(key.into(), value.into());
108-
store
99+
async fn finalize_block(
100+
&self,
101+
request: request::FinalizeBlock,
102+
) -> Result<response::FinalizeBlock> {
103+
let mut tx_results = Vec::with_capacity(request.txs.len());
104+
105+
for tx in request.txs {
106+
let tx = String::from_utf8(tx.to_vec()).unwrap();
107+
let (key, value) = match tx.split('=').collect::<Vec<_>>() {
108+
k if k.len() == 1 => (k[0], k[0]),
109+
kv => (kv[0], kv[1]),
110+
};
111+
112+
atomically(|| {
113+
self.store.update(|mut store| {
114+
store.insert(key.into(), value.into());
115+
store
116+
})
109117
})
110-
})
111-
.await;
118+
.await;
112119

113-
info!(?key, ?value, "update");
120+
info!(?key, ?value, "update");
114121

115-
Ok(response::DeliverTx {
116-
events: vec![Event::new(
122+
let events = vec![Event::new(
117123
"app",
118124
vec![
119125
("key", key).index(),
120126
("index_key", "index is working").index(),
121127
("noindex_key", "index is working").no_index(),
122128
],
123-
)],
124-
..Default::default()
129+
)];
130+
131+
tx_results.push(tendermint::abci::types::ExecTxResult {
132+
code: tendermint::abci::Code::Ok,
133+
data: Default::default(),
134+
log: Default::default(),
135+
info: Default::default(),
136+
gas_wanted: 0,
137+
gas_used: 0,
138+
events,
139+
codespace: Default::default(),
140+
});
141+
}
142+
143+
Ok(response::FinalizeBlock {
144+
events: Vec::new(),
145+
tx_results,
146+
validator_updates: Vec::new(),
147+
consensus_param_updates: None,
148+
app_hash: Default::default(),
125149
})
126150
}
127151

@@ -204,7 +228,7 @@ async fn main() {
204228

205229
// Run the ABCI server.
206230
server
207-
.listen(format!("{}:{}", opt.host, opt.port))
231+
.listen_tcp(format!("{}:{}", opt.host, opt.port))
208232
.await
209233
.unwrap();
210234
}

fendermint/abci/src/application.rs

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
pin::Pin,
88
task::{Context, Poll},
99
};
10-
use tendermint::abci::{request, response, Request, Response};
10+
use tendermint::v0_38::abci::{request, response, Request, Response};
1111
use tower::Service;
1212
use tower_abci::BoxError;
1313

@@ -81,19 +81,33 @@ pub trait Application {
8181
Ok(response::ProcessProposal::Accept)
8282
}
8383

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

89-
/// Apply a transaction to the application's state.
90-
async fn deliver_tx(&self, request: request::DeliverTx) -> AbciResult<response::DeliverTx> {
91-
Ok(Default::default())
91+
/// Verify vote extensions from peer validators.
92+
async fn verify_vote_extension(
93+
&self,
94+
_request: request::VerifyVoteExtension,
95+
) -> AbciResult<response::VerifyVoteExtension> {
96+
Ok(response::VerifyVoteExtension::Accept)
9297
}
9398

94-
/// Signals the end of a block.
95-
async fn end_block(&self, request: request::EndBlock) -> AbciResult<response::EndBlock> {
96-
Ok(Default::default())
99+
/// Execute and finalize an entire block.
100+
async fn finalize_block(
101+
&self,
102+
_request: request::FinalizeBlock,
103+
) -> AbciResult<response::FinalizeBlock> {
104+
Ok(response::FinalizeBlock {
105+
events: Vec::new(),
106+
tx_results: Vec::new(),
107+
validator_updates: Vec::new(),
108+
consensus_param_updates: None,
109+
app_hash: tendermint::AppHash::default(),
110+
})
97111
}
98112

99113
/// Commit the current state at the current height.
@@ -174,11 +188,15 @@ where
174188
Request::ProcessProposal(r) => {
175189
Response::ProcessProposal(log_error(app.process_proposal(r).await)?)
176190
}
177-
Request::BeginBlock(r) => {
178-
Response::BeginBlock(log_error(app.begin_block(r).await)?)
191+
Request::ExtendVote(r) => {
192+
Response::ExtendVote(log_error(app.extend_vote(r).await)?)
193+
}
194+
Request::VerifyVoteExtension(r) => {
195+
Response::VerifyVoteExtension(log_error(app.verify_vote_extension(r).await)?)
196+
}
197+
Request::FinalizeBlock(r) => {
198+
Response::FinalizeBlock(log_error(app.finalize_block(r).await)?)
179199
}
180-
Request::DeliverTx(r) => Response::DeliverTx(log_error(app.deliver_tx(r).await)?),
181-
Request::EndBlock(r) => Response::EndBlock(log_error(app.end_block(r).await)?),
182200
Request::Commit => Response::Commit(log_error(app.commit().await)?),
183201
Request::ListSnapshots => {
184202
Response::ListSnapshots(log_error(app.list_snapshots().await)?)
@@ -192,7 +210,8 @@ where
192210
Request::ApplySnapshotChunk(r) => {
193211
Response::ApplySnapshotChunk(log_error(app.apply_snapshot_chunk(r).await)?)
194212
}
195-
Request::Flush => panic!("Flush should be handled by the Server!"),
213+
// Some clients still send explicit Flush requests; never panic on protocol input.
214+
Request::Flush => Response::Flush,
196215
};
197216
Ok(res)
198217
};

fendermint/actors-custom-car/build.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ fn create_metadata_command(path: impl Into<PathBuf>) -> MetadataCommand {
152152
metadata_command
153153
}
154154

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

176+
if let Some(manifest_dir) = std::env::var_os("CARGO_MANIFEST_DIR") {
177+
if let Some(path) = find_impl(PathBuf::from(manifest_dir)) {
178+
return Some(path);
179+
}
180+
}
181+
175182
None
176183
}
177184

0 commit comments

Comments
 (0)