Skip to content

Commit

Permalink
Merge branch 'origin/bengt/cometbft-correct' (#1476)
Browse files Browse the repository at this point in the history
* origin/bengt/cometbft-correct:
  ci: restore ci files
  feat: switch tendermint references to cometbft
  • Loading branch information
Fraccaman committed Jun 15, 2023
2 parents 0947994 + 0e8db33 commit 864ff37
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 150 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/miscellaneous/1476-cometbft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Switch from unreleased Tendermint fork to an official CometBFT release
v0.37.1. ([\#1476](https://github.com/anoma/namada/pull/1476))
6 changes: 0 additions & 6 deletions .github/workflows/build-and-test-bridge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,6 @@ jobs:
run: |
wget -q -O- https://github.com/rui314/mold/releases/download/v${{ matrix.mold_version }}/mold-${{ matrix.mold_version }}-x86_64-linux.tar.gz | tar -xz
mv mold-${{ matrix.mold_version }}-x86_64-linux/bin/mold /usr/local/bin
- name: Download masp parameters
run: |
mkdir /home/runner/work/masp
curl -o /home/runner/work/masp/masp-spend.params -sLO https://github.com/anoma/masp-mpc/releases/download/namada-trusted-setup/masp-spend.params?raw=true
curl -o /home/runner/work/masp/masp-output.params -sLO https://github.com/anoma/masp-mpc/releases/download/namada-trusted-setup/masp-output.params?raw=true
curl -o /home/runner/work/masp/masp-convert.params -sLO https://github.com/anoma/masp-mpc/releases/download/namada-trusted-setup/masp-convert.params?raw=true
- name: Build
run: make build
env:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ jobs:
suffix: ''
cache_key: namada
cache_version: v2
tendermint_artifact: tendermint-unreleased-v0.1.4-abciplus

env:
CARGO_INCREMENTAL: 0
Expand Down Expand Up @@ -378,12 +379,14 @@ jobs:
index: 0
cache_key: namada
cache_version: v2
tendermint_artifact: tendermint-unreleased-v0.1.4-abciplus
wait_for: namada-release (ubuntu-20.04, 1.7.0, ABCI Release build, namada-e2e-release, v2)
- name: e2e
suffix: ''
index: 1
cache_key: namada
cache_version: v2
tendermint_artifact: tendermint-unreleased-v0.1.4-abciplus
wait_for: namada-release (ubuntu-20.04, 1.7.0, ABCI Release build, namada-e2e-release, v2)

env:
Expand Down Expand Up @@ -512,6 +515,7 @@ jobs:
shasum /home/runner/work/masp-params/*.params
python3 .github/workflows/scripts/schedule-e2e.py
env:
NAMADA_TENDERMINT_WEBSOCKET_TIMEOUT: 20
NAMADA_E2E_USE_PREBUILT_BINARIES: "true"
NAMADA_E2E_KEEP_TEMP: "true"
NAMADA_TM_STDOUT: "false"
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/build-tendermint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build tendermint binaries

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

permissions:
id-token: write
contents: read

env:
GIT_LFS_SKIP_SMUDGE: 1


jobs:
tendermint:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
make:
- name: tendermint-unreleased
repository: heliaxdev/tendermint
tendermint_version: v0.1.4-abciplus

steps:
- name: Build ${{ matrix.make.name }}
run: |
git clone https://github.com/${{ matrix.make.repository }}.git && cd tendermint
git checkout ${{ matrix.make.tendermint_version }} && make build
- name: Upload ${{ matrix.make.name }} binary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.make.name }}-${{ matrix.make.tendermint_version }}
path: tendermint/build/tendermint
4 changes: 2 additions & 2 deletions apps/src/bin/namada-node/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use namada_apps::node::ledger;
pub fn main() -> Result<()> {
let (cmd, mut ctx) = cli::namada_node_cli()?;
if let Some(mode) = ctx.global_args.mode.clone() {
ctx.config.ledger.tendermint.tendermint_mode = mode;
ctx.config.ledger.cometbft.tendermint_mode = mode;
}
match cmd {
cmds::NamadaNode::Ledger(sub) => match sub {
cmds::Ledger::Run(cmds::LedgerRun(args)) => {
let wasm_dir = ctx.wasm_dir();
sleep_until(args.start_time);
ctx.config.ledger.tendermint.tx_index = args.tx_index;
ctx.config.ledger.cometbft.tx_index = args.tx_index;
ledger::run(ctx.config.ledger, wasm_dir);
}
cmds::Ledger::RunUntil(cmds::LedgerRunUntil(args)) => {
Expand Down
4 changes: 2 additions & 2 deletions apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,13 @@ pub async fn submit_init_validator<
crate::wallet::save(&ctx.wallet)
.unwrap_or_else(|err| eprintln!("{}", err));

let tendermint_home = ctx.config.ledger.tendermint_dir();
let tendermint_home = ctx.config.ledger.cometbft_dir();
tendermint_node::write_validator_key(&tendermint_home, &consensus_key);
tendermint_node::write_validator_state(tendermint_home);

// Write Namada config stuff or figure out how to do the above
// tendermint_node things two epochs in the future!!!
ctx.config.ledger.tendermint.tendermint_mode =
ctx.config.ledger.cometbft.tendermint_mode =
TendermintMode::Validator;
ctx.config
.write(
Expand Down
69 changes: 29 additions & 40 deletions apps/src/lib/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ pub async fn join_network(
})
.clone();

let tm_home_dir = chain_dir.join("tendermint");
let tm_home_dir = chain_dir.join("cometbft");

// Write consensus key to tendermint home
tendermint_node::write_validator_key(
Expand Down Expand Up @@ -324,26 +324,21 @@ pub async fn join_network(
tokio::task::spawn_blocking(move || {
let mut config = Config::load(&base_dir, &chain_id, None);

config.ledger.tendermint.tendermint_mode =
TendermintMode::Validator;
config.ledger.cometbft.tendermint_mode = TendermintMode::Validator;
// Validator node should turned off peer exchange reactor
config.ledger.tendermint.p2p_pex = false;
config.ledger.cometbft.p2p_pex = false;
// Remove self from persistent peers
config
.ledger
.tendermint
.p2p_persistent_peers
.retain(|peer| {
if let TendermintAddress::Tcp {
peer_id: Some(peer_id),
..
} = peer
{
node_id != *peer_id
} else {
true
}
});
config.ledger.cometbft.p2p_persistent_peers.retain(|peer| {
if let TendermintAddress::Tcp {
peer_id: Some(peer_id),
..
} = peer
{
node_id != *peer_id
} else {
true
}
});
config.write(&base_dir, &chain_id, true).unwrap();
})
.await
Expand Down Expand Up @@ -456,7 +451,7 @@ pub fn init_network(
let validator_dir = accounts_dir.join(name);

let chain_dir = validator_dir.join(&accounts_temp_dir);
let tm_home_dir = chain_dir.join("tendermint");
let tm_home_dir = chain_dir.join("cometbft");

// Find or generate tendermint node key
let node_pk = try_parse_public_key(
Expand Down Expand Up @@ -744,7 +739,7 @@ pub fn init_network(
// directories.
config.ledger.shell.base_dir = config::DEFAULT_BASE_DIR.into();
// Add a ledger P2P persistent peers
config.ledger.tendermint.p2p_persistent_peers = persistent_peers
config.ledger.cometbft.p2p_persistent_peers = persistent_peers
.iter()
.enumerate()
.filter_map(|(index, peer)|
Expand All @@ -755,57 +750,51 @@ pub fn init_network(
None
})
.collect();
config.ledger.tendermint.consensus_timeout_commit =
config.ledger.cometbft.consensus_timeout_commit =
consensus_timeout_commit;
config.ledger.tendermint.p2p_allow_duplicate_ip =
allow_duplicate_ip;
config.ledger.tendermint.p2p_addr_book_strict = !localhost;
config.ledger.cometbft.p2p_allow_duplicate_ip = allow_duplicate_ip;
config.ledger.cometbft.p2p_addr_book_strict = !localhost;
// Clear the net address from the config and use it to set ports
let net_address = validator_config.net_address.take().unwrap();
let first_port = SocketAddr::from_str(&net_address).unwrap().port();
if !localhost {
config
.ledger
.tendermint
.cometbft
.p2p_address
.set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)));
}
config.ledger.tendermint.p2p_address.set_port(first_port);
config.ledger.cometbft.p2p_address.set_port(first_port);
if !localhost {
config
.ledger
.tendermint
.cometbft
.rpc_address
.set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)));
}
config
.ledger
.tendermint
.rpc_address
.set_port(first_port + 1);
config.ledger.cometbft.rpc_address.set_port(first_port + 1);
config.ledger.shell.ledger_address.set_port(first_port + 2);
// Validator node should turned off peer exchange reactor
config.ledger.tendermint.p2p_pex = false;
config.ledger.cometbft.p2p_pex = false;

config.write(&validator_dir, &chain_id, true).unwrap();
},
);

// Update the ledger config persistent peers and save it
let mut config = Config::load(&global_args.base_dir, &chain_id, None);
config.ledger.tendermint.p2p_persistent_peers = persistent_peers;
config.ledger.tendermint.consensus_timeout_commit =
consensus_timeout_commit;
config.ledger.tendermint.p2p_allow_duplicate_ip = allow_duplicate_ip;
config.ledger.cometbft.p2p_persistent_peers = persistent_peers;
config.ledger.cometbft.consensus_timeout_commit = consensus_timeout_commit;
config.ledger.cometbft.p2p_allow_duplicate_ip = allow_duplicate_ip;
// Open P2P address
if !localhost {
config
.ledger
.tendermint
.cometbft
.p2p_address
.set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)));
}
config.ledger.tendermint.p2p_addr_book_strict = !localhost;
config.ledger.cometbft.p2p_addr_book_strict = !localhost;
config.ledger.genesis_time = genesis.genesis_time.into();
config
.write(&global_args.base_dir, &chain_id, true)
Expand Down
22 changes: 11 additions & 11 deletions apps/src/lib/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub const DEFAULT_WASM_DIR: &str = "wasm";
pub const DEFAULT_WASM_CHECKSUMS_FILE: &str = "checksums.json";
/// Chain-specific Namada configuration. Nested in chain dirs.
pub const FILENAME: &str = "config.toml";
/// Chain-specific Tendermint configuration. Nested in chain dirs.
pub const TENDERMINT_DIR: &str = "tendermint";
/// Chain-specific CometBFT configuration. Nested in chain dirs.
pub const COMETBFT_DIR: &str = "cometbft";
/// Chain-specific Namada DB. Nested in chain dirs.
pub const DB_DIR: &str = "db";

Expand Down Expand Up @@ -95,7 +95,7 @@ pub struct Ledger {
pub genesis_time: Rfc3339String,
pub chain_id: ChainId,
pub shell: Shell,
pub tendermint: Tendermint,
pub cometbft: Tendermint,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand All @@ -116,8 +116,8 @@ pub struct Shell {
pub storage_read_past_height_limit: Option<u64>,
/// Use the [`Ledger::db_dir()`] method to read the value.
db_dir: PathBuf,
/// Use the [`Ledger::tendermint_dir()`] method to read the value.
tendermint_dir: PathBuf,
/// Use the [`Ledger::cometbft_dir()`] method to read the value.
cometbft_dir: PathBuf,
/// An optional action to take when a given blockheight is reached.
pub action_at_height: Option<ActionAtHeight>,
}
Expand Down Expand Up @@ -173,10 +173,10 @@ impl Ledger {
// Default corresponds to 1 hour of past blocks at 1 block/sec
storage_read_past_height_limit: Some(3600),
db_dir: DB_DIR.into(),
tendermint_dir: TENDERMINT_DIR.into(),
cometbft_dir: COMETBFT_DIR.into(),
action_at_height: None,
},
tendermint: Tendermint {
cometbft: Tendermint {
rpc_address: SocketAddr::new(
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
26657,
Expand Down Expand Up @@ -222,8 +222,8 @@ impl Ledger {
}

/// Get the directory path to Tendermint
pub fn tendermint_dir(&self) -> PathBuf {
self.shell.tendermint_dir(&self.chain_id)
pub fn cometbft_dir(&self) -> PathBuf {
self.shell.cometbft_dir(&self.chain_id)
}
}

Expand All @@ -234,10 +234,10 @@ impl Shell {
}

/// Get the directory path to Tendermint
pub fn tendermint_dir(&self, chain_id: &ChainId) -> PathBuf {
pub fn cometbft_dir(&self, chain_id: &ChainId) -> PathBuf {
self.base_dir
.join(chain_id.as_str())
.join(&self.tendermint_dir)
.join(&self.cometbft_dir)
}
}

Expand Down
Loading

0 comments on commit 864ff37

Please sign in to comment.