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

feat(pd)!: migrate to cometbft v0.37 #3115

Merged
merged 1 commit into from
Sep 29, 2023
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
8 changes: 5 additions & 3 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ jobs:

- name: Install cometbft binary
run: |
curl -L -O "https://github.com/cometbft/cometbft/releases/download/v0.34.27/cometbft_0.34.27_linux_amd64.tar.gz"
tar -xzf "cometbft_0.34.27_linux_amd64.tar.gz" cometbft
COMETBFT_VERSION="0.37.2"
curl -L -O "https://github.com/cometbft/cometbft/releases/download/v${COMETBFT_VERSION}/cometbft_${COMETBFT_VERSION}_linux_amd64.tar.gz"
tar -xzf "cometbft_${COMETBFT_VERSION}_linux_amd64.tar.gz" cometbft
mkdir -p $HOME/bin
cp cometbft $HOME/bin
echo $PATH
export PATH=$HOME/bin:$PATH
which cometbft
cometbft version

- name: Run the smoke test suite
run: |
export PATH=$HOME/bin:$PATH
export PATH="$HOME/bin:$PATH"
./deployments/scripts/smoke-test.sh
env:
TESTNET_RUNTIME: 2m
1 change: 1 addition & 0 deletions Cargo.lock

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

55 changes: 54 additions & 1 deletion crates/bin/pd/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Result;
use penumbra_app::genesis;
use penumbra_storage::Storage;
use tendermint::abci::Event;
use tendermint::v0_34::abci::{
use tendermint::v0_37::abci::{
request, response, ConsensusRequest as Request, ConsensusResponse as Response,
};
use tokio::sync::mpsc;
Expand Down Expand Up @@ -81,6 +81,18 @@ impl Consensus {
.await
.expect("commit must succeed"),
),
Request::PrepareProposal(proposal) => Response::PrepareProposal(
self.prepare_proposal(proposal)
.instrument(span)
.await
.expect("prepare proposal must succeed"),
),
Request::ProcessProposal(proposal) => Response::ProcessProposal(
self.process_proposal(proposal)
.instrument(span)
.await
.expect("process proposal must succeed"),
),
}));
}
Ok(())
Expand Down Expand Up @@ -203,4 +215,45 @@ impl Consensus {
retain_height: 0u32.into(),
})
}

/// Ensures that a proposal is suitable for processing. Inspects
/// the transactions within the proposal, discarding any that would
/// exceed the maximum number of tx bytes for a proposal, and returns
/// a propoal with the remainder.
async fn prepare_proposal(
&mut self,
proposal: request::PrepareProposal,
) -> Result<response::PrepareProposal> {
let mut txs: Vec<bytes::Bytes> = Vec::new();
let num_candidate_txs = proposal.txs.len();
tracing::debug!(
"processing PrepareProposal, found {} candidate transactions",
proposal.txs.len()
);
// Ensure that list of transactions doesn't exceed max tx bytes. See spec at
// https://github.com/cometbft/cometbft/blob/v0.37.2/spec/abci/abci%2B%2B_comet_expected_behavior.md#adapting-existing-applications-that-use-abci
for tx in proposal.txs {
if (tx.len() + txs.len()) <= proposal.max_tx_bytes.try_into()? {
txs.push(tx);
} else {
break;
}
}
tracing::debug!(
"finished processing PrepareProposal, including {}/{} candidate transactions",
txs.len(),
num_candidate_txs
);
Ok(response::PrepareProposal { txs: txs })
}

/// Mark the proposal as accepted. The [prepare_proposal] method ensures
/// that the number of tx bytes is within the acceptable limit.
async fn process_proposal(
&mut self,
proposal: request::ProcessProposal,
) -> Result<response::ProcessProposal> {
tracing::debug!(?proposal, "processing proposal");
Ok(response::ProcessProposal::Accept)
}
}
4 changes: 3 additions & 1 deletion crates/bin/pd/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Result;
use futures::FutureExt;
use regex::RegexSet;
use tendermint::abci::Event;
use tendermint::v0_34::abci::{ConsensusRequest as Request, ConsensusResponse as Response};
use tendermint::v0_37::abci::{ConsensusRequest as Request, ConsensusResponse as Response};
use tower::{Layer, Service};

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -102,6 +102,8 @@ where
// No events.
Response::InitChain(_) => {}
Response::Commit(_) => {}
Response::PrepareProposal(_) => {}
Response::ProcessProposal(_) => {}
// These responses have events.
Response::BeginBlock(ref mut msg) => config.adjust_events(&mut msg.events),
Response::DeliverTx(ref mut msg) => config.adjust_events(&mut msg.events),
Expand Down
5 changes: 2 additions & 3 deletions crates/bin/pd/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ use penumbra_ibc::component::ConnectionStateReadExt as _;
use penumbra_storage::Storage;
use prost::Message;
use std::str::FromStr;
use tendermint::v0_34::abci::{
use tendermint::v0_37::abci::{
request,
response::{self, Echo},
InfoRequest, InfoResponse,
};
use tower_abci::BoxError;
use tracing::Instrument;

use penumbra_tower_trace::v034::RequestExt;
use penumbra_tower_trace::v037::RequestExt;

const ABCI_INFO_VERSION: &str = env!("VERGEN_GIT_SEMVER");

Expand Down Expand Up @@ -609,7 +609,6 @@ impl tower_service::Service<InfoRequest> for Info {
InfoRequest::Echo(echo) => Ok(InfoResponse::Echo(Echo {
message: echo.message,
})),
InfoRequest::SetOption(_) => todo!(),
}
}
.instrument(span)
Expand Down
6 changes: 3 additions & 3 deletions crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ use tonic::transport::Server;
use tracing_subscriber::{prelude::*, EnvFilter};
use url::Url;

use penumbra_tower_trace::v034::RequestExt;
use tendermint::v0_34::abci::{ConsensusRequest, MempoolRequest};
use penumbra_tower_trace::v037::RequestExt;
use tendermint::v0_37::abci::{ConsensusRequest, MempoolRequest};

#[derive(Debug, Parser)]
#[clap(
Expand Down Expand Up @@ -318,7 +318,7 @@ async fn main() -> anyhow::Result<()> {
let abci_server = tokio::task::Builder::new()
.name("abci_server")
.spawn(
tower_abci::v034::Server::builder()
tower_abci::v037::Server::builder()
.consensus(consensus)
.snapshot(snapshot)
.mempool(mempool)
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/pd/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;

use penumbra_storage::{Snapshot, Storage};

use tendermint::v0_34::abci::{
use tendermint::v0_37::abci::{
request::CheckTx as CheckTxReq, request::CheckTxKind, response::CheckTx as CheckTxRsp,
MempoolRequest as Request, MempoolResponse as Response,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/pd/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
};

use futures::FutureExt;
use tendermint::v0_34::abci::{SnapshotRequest, SnapshotResponse};
use tendermint::v0_37::abci::{SnapshotRequest, SnapshotResponse};
use tower_abci::BoxError;

#[derive(Clone, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/component/dex/src/component/dex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use penumbra_chain::component::StateReadExt as _;
use penumbra_component::Component;
use penumbra_proto::{StateReadProto, StateWriteProto};
use penumbra_storage::{StateRead, StateWrite};
use tendermint::v0_34::abci;
use tendermint::v0_37::abci;
use tracing::instrument;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/core/component/governance/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use anyhow::{Context, Result};
use async_trait::async_trait;
use penumbra_storage::StateWrite;
use tendermint::v0_34::abci;
use tendermint::v0_37::abci;
use tracing::instrument;

use penumbra_component::Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use penumbra_proto::StateReadProto;
use penumbra_sct::Nullifier;
use penumbra_storage::StateRead;
use penumbra_storage::StateWrite;
use tendermint::v0_34::abci;
use tendermint::v0_37::abci;
use tracing::instrument;

use crate::genesis::Content as GenesisContent;
Expand Down
1 change: 1 addition & 0 deletions crates/narsil/narsil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ tower-actor = "0.1.0"
# External dependencies
anyhow = "1"
async-stream = "0.2"
bytes = "1"
clap = { version = "3", features = ["derive", "env"] }
console-subscriber = "0.1.8"
futures = "0.3"
Expand Down
6 changes: 3 additions & 3 deletions crates/narsil/narsil/src/bin/narsild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use console_subscriber::ConsoleLayer;
use metrics_tracing_context::{MetricsLayer, TracingContextLayer};
use metrics_util::layers::Stack;
use penumbra_tendermint_proxy::TendermintProxy;
use penumbra_tower_trace::v034::RequestExt;
use tendermint::v0_34::abci::{ConsensusRequest, MempoolRequest};
use penumbra_tower_trace::v037::RequestExt;
use tendermint::v0_37::abci::{ConsensusRequest, MempoolRequest};

use narsil::{
ledger::{consensus::Consensus, mempool::Mempool, snapshot::Snapshot, Info},
Expand Down Expand Up @@ -159,7 +159,7 @@ async fn main() -> anyhow::Result<()> {
let abci_server = tokio::task::Builder::new()
.name("abci_server")
.spawn(
tower_abci::v034::Server::builder()
tower_abci::v037::Server::builder()
.consensus(consensus)
.snapshot(snapshot)
.mempool(mempool)
Expand Down
55 changes: 54 additions & 1 deletion crates/narsil/narsil/src/ledger/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Result;
use penumbra_app::genesis;
use penumbra_storage::Storage;
use tendermint::abci::Event;
use tendermint::v0_34::abci::{
use tendermint::v0_37::abci::{
request, response, ConsensusRequest as Request, ConsensusResponse as Response,
};
use tokio::sync::mpsc;
Expand Down Expand Up @@ -81,6 +81,18 @@ impl Consensus {
.await
.expect("commit must succeed"),
),
Request::PrepareProposal(proposal) => Response::PrepareProposal(
self.prepare_proposal(proposal)
.instrument(span)
.await
.expect("prepare proposal must succeed"),
),
Request::ProcessProposal(proposal) => Response::ProcessProposal(
self.process_proposal(proposal)
.instrument(span)
.await
.expect("process proposal must succeed"),
),
}));
}
Ok(())
Expand Down Expand Up @@ -193,4 +205,45 @@ impl Consensus {
retain_height: 0u32.into(),
})
}

/// Ensures that a proposal is suitable for processing. Inspects
/// the transactions within the proposal, discarding any that would
/// exceed the maximum number of tx bytes for a proposal, and returns
/// a propoal with the remainder.
async fn prepare_proposal(
&mut self,
proposal: request::PrepareProposal,
) -> Result<response::PrepareProposal> {
let mut txs: Vec<bytes::Bytes> = Vec::new();
let num_candidate_txs = proposal.txs.len();
tracing::debug!(
"Processing PrepareProposal, found {} candidate transactions",
proposal.txs.len()
);
// Ensure that list of transactions doesn't exceed max tx bytes. See spec at
// https://github.com/cometbft/cometbft/blob/v0.37.2/spec/abci/abci%2B%2B_comet_expected_behavior.md#adapting-existing-applications-that-use-abci
for tx in proposal.txs {
if (tx.len() + txs.len()) <= proposal.max_tx_bytes.try_into()? {
txs.push(tx);
} else {
break;
}
}
tracing::debug!(
"Finished processing PrepareProposal, including {}/{} candidate transactions",
txs.len(),
num_candidate_txs
);
Ok(response::PrepareProposal { txs: txs })
}

/// Mark the proposal as accepted. The [prepare_proposal] method ensures
/// that the number of tx bytes is within the acceptable limit.
async fn process_proposal(
&mut self,
proposal: request::ProcessProposal,
) -> Result<response::ProcessProposal> {
tracing::debug!(?proposal, "Processing proposal");
Ok(response::ProcessProposal::Accept)
}
}
5 changes: 2 additions & 3 deletions crates/narsil/narsil/src/ledger/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::{
use futures::FutureExt;
use penumbra_chain::component::{AppHashRead, StateReadExt};
use penumbra_storage::Storage;
use penumbra_tower_trace::v034::RequestExt;
use tendermint::v0_34::abci::{self, response::Echo, InfoRequest, InfoResponse};
use penumbra_tower_trace::v037::RequestExt;
use tendermint::v0_37::abci::{self, response::Echo, InfoRequest, InfoResponse};
use tower_abci::BoxError;
use tracing::Instrument;

Expand Down Expand Up @@ -78,7 +78,6 @@ impl tower_service::Service<InfoRequest> for Info {
InfoRequest::Echo(echo) => Ok(InfoResponse::Echo(Echo {
message: echo.message,
})),
InfoRequest::SetOption(_) => todo!(),
}
}
.instrument(span)
Expand Down
6 changes: 3 additions & 3 deletions crates/narsil/narsil/src/ledger/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use anyhow::Result;

use penumbra_storage::{Snapshot, Storage};

use tendermint::v0_34::abci::request::{CheckTx as CheckTxReq, CheckTxKind};
use tendermint::v0_34::abci::response::CheckTx as CheckTxRsp;
use tendermint::v0_34::abci::{MempoolRequest as Request, MempoolResponse as Response};
use tendermint::v0_37::abci::request::{CheckTx as CheckTxReq, CheckTxKind};
use tendermint::v0_37::abci::response::CheckTx as CheckTxRsp;
use tendermint::v0_37::abci::{MempoolRequest as Request, MempoolResponse as Response};

use tokio::sync::{mpsc, watch};
use tower_actor::Message;
Expand Down
2 changes: 1 addition & 1 deletion crates/narsil/narsil/src/ledger/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
};

use futures::FutureExt;
use tendermint::v0_34::abci::{SnapshotRequest, SnapshotResponse};
use tendermint::v0_37::abci::{SnapshotRequest, SnapshotResponse};
use tower_abci::BoxError;

#[derive(Clone, Debug)]
Expand Down
Binary file modified crates/proto/src/gen/proto_descriptor.bin.no_lfs
Binary file not shown.
14 changes: 1 addition & 13 deletions deployments/charts/penumbra-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ cometbft:
repository: cometbft/cometbft
pullPolicy: IfNotPresent
# https://github.com/cometbft/cometbft#supported-versions
# https://github.com/cometbft/cometbft/blob/main/UPGRADING.md#v03427
tag: "v0.34.27"
tag: "v0.37.2"
containerArgs:
- start
- --proxy_app=tcp://127.0.0.1:26658
Expand All @@ -106,17 +105,6 @@ securityContext: {}
# runAsNonRoot: true
# runAsUser: 1000

cometbft:
image:
repository: cometbft/cometbft
pullPolicy: IfNotPresent
# https://github.com/cometbft/cometbft#supported-versions
# https://github.com/cometbft/cometbft/blob/main/UPGRADING.md#v03427
tag: "v0.34.27"
containerArgs:
- start
- --proxy_app=tcp://127.0.0.1:26658

# N.B. Only `IngressRoute`, a custom CRD specific to Traefik ingress controller
# is supported. This is because a traditional Ingress object doesn't allow us
# to force a backend scheme of h2c, which is required for pd's gRPC service.
Expand Down
3 changes: 1 addition & 2 deletions deployments/charts/penumbra-node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ cometbft:
repository: cometbft/cometbft
pullPolicy: IfNotPresent
# https://github.com/cometbft/cometbft#supported-versions
# https://github.com/cometbft/cometbft/blob/main/UPGRADING.md#v03427
tag: "v0.34.27"
tag: "v0.37.2"

# Configure nodes. By default, only one is created.
# Extend this list to add more. Valid node attributes are:
Expand Down
Loading