Skip to content
This repository has been archived by the owner on Jan 26, 2023. It is now read-only.

Commit

Permalink
Port RC7 to Tendermint 0.34.x
Browse files Browse the repository at this point in the history
Using `tendermint-rs` 0.28.0

This commit contains a workaround for
informalsystems/tendermint-rs#1251
  • Loading branch information
fmorency committed Dec 15, 2022
1 parent 55ce0c3 commit e3b719f
Show file tree
Hide file tree
Showing 9 changed files with 642 additions and 548 deletions.
1,123 changes: 607 additions & 516 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Below are some examples of how to use the different CLI.

## Requirements
1. Install `tendermint`
1. Download `tendermint` **v0.35.4** from https://github.com/tendermint/tendermint/releases/tag/v0.35.4
1. Download `tendermint` **v0.34.24** from https://github.com/tendermint/tendermint/releases/tag/v0.34.24
2. Extract the archive
3. Put the path to the `tendermint` executable in your `$PATH`
2. Install the `many` CLI
Expand Down
4 changes: 2 additions & 2 deletions docker/e2e/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NB_NODES ?= 4
ID_WITH_BALANCES ?=
TENDERMINT_VERSION ?= 0.35.4
TENDERMINT_VERSION ?= 0.34.24

.PHONY: clean
clean:
Expand Down Expand Up @@ -65,7 +65,7 @@ genfiles/generate-tendermint-e2e-config:
make genfiles/node$$I; \
(( I = I + 1 )); \
done
sh update_config.sh -c "genfiles/node%/tendermint/config" -i tendermint-% $(NB_NODES)
sh update_config.sh -c "genfiles/node%/tendermint/config" -r "$$PWD/genfiles/node%/tendermint" -i tendermint-% $(NB_NODES)
mkdir -p $(dir $@) && touch $@

.PHONY: start-all-nodes stop-node start-ledger-local
Expand Down
5 changes: 2 additions & 3 deletions docker/e2e/docker-compose.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ local ledger(i, user, id_with_balances) = {
local tendermint(i, user, tendermint_tag) = {
image: "tendermint/tendermint:v" + tendermint_tag,
command: [
"--log-level", "info",
"start",
"--rpc.laddr", "tcp://0.0.0.0:26657",
"--proxy-app", "tcp://abci-" + i + ":26658",
"--proxy_app", "tcp://abci-" + i + ":26658",
],
user: "" + user,
volumes: [
Expand All @@ -60,7 +59,7 @@ local tendermint(i, user, tendermint_tag) = {
ports: [ "" + (26600 + i) + ":26600" ],
};

function(nb_nodes=4, user=1000, id_with_balances="", tendermint_tag="0.35.4") {
function(nb_nodes=4, user=1000, id_with_balances="", tendermint_tag="0.34.24") {
version: '3',
services: {
["abci-" + i]: abci(i, user) for i in std.range(0, nb_nodes - 1)
Expand Down
11 changes: 7 additions & 4 deletions docker/e2e/update_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ END_OF_USAGE
ip_range=10.254.254.%
port=26656
config_root=""
while getopts ":i:p:c:" opt; do
while getopts ":i:p:c:r:" opt; do
case "${opt}" in
i) ip_range="${OPTARG}"
;;
Expand All @@ -60,6 +60,8 @@ while getopts ":i:p:c:" opt; do
;;
c) config_root="${OPTARG}"
;;
r) tm_root="${OPTARG}"
;;
*) usage
;;
esac
Expand Down Expand Up @@ -94,15 +96,16 @@ for node in $(seq 0 "$NB_NODES"); do

peer_ids=$(seq 0 "$NB_NODES" | grep -v "$node")
peers=$(for peer in $peer_ids; do
node_id=$(jq -r .id < "${config_root//%/$peer}"/node_key.json)
node_id=$(docker run -u $(id -u):$(id -g) -i --rm -v "${tm_root//%/$peer}:/tendermint" tendermint/tendermint:v0.34.24 show_node_id | tail -n +2 | tr -d '\n')
ip_address=${ip_range//%/$peer}
printf '%s' "$node_id@$ip_address:$port,"
done | sed 's/,$//')

update_toml_key "$config_toml_path" '' proxy-app "\"tcp:\\/\\/abci-${node}:26658\\/\""
update_toml_key "$config_toml_path" '' proxy_app "\"tcp:\\/\\/abci-${node}:26658\\/\""
update_toml_key "$config_toml_path" '' moniker "\"many-tendermint-${node}\""
update_toml_key "$config_toml_path" p2p persistent-peers "\"$peers\""
update_toml_key "$config_toml_path" p2p persistent_peers "\"$peers\""
update_toml_key "$config_toml_path" p2p max_packet_msg_payload_size "1400"
# update_toml_key "$config_toml_path" p2p bootstrap-peers "\"$peers\""
done

Expand Down
14 changes: 7 additions & 7 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# $ cd /path/to/many-ledger
# $ ./script/run.sh
set -pube # .. snicker ..
TM_MIN_VERSION=0.35.0 # The minimum tendermint version supported
TM_MIN_VERSION=0.34.24 # The minimum tendermint version supported

toml_set() {
local tmp=$(mktemp)
Expand Down Expand Up @@ -97,17 +97,17 @@ main() {
TMHOME="$root_dir/ledger" tendermint init validator
TMHOME="$root_dir/kvstore" tendermint init validator

toml_set "$root_dir/ledger/config/config.toml" consensus.create-empty-blocks "false"
toml_set "$root_dir/ledger/config/config.toml" consensus.create-empty-blocks-interval "20s"
toml_set "$root_dir/ledger/config/config.toml" consensus.timeout-commit "10s"
toml_set "$root_dir/ledger/config/config.toml" consensus.timeout-precommit "10s"
toml_set "$root_dir/ledger/config/config.toml" consensus.create_empty_blocks "false"
toml_set "$root_dir/ledger/config/config.toml" consensus.create_empty_blocks_interval "20s"
toml_set "$root_dir/ledger/config/config.toml" consensus.timeout_commit "10s"
toml_set "$root_dir/ledger/config/config.toml" consensus.timeout_precommit "10s"

toml_set "$root_dir/ledger/config/config.toml" p2p.laddr "tcp://127.0.0.1:26656"
toml_set "$root_dir/ledger/config/config.toml" rpc.laddr "tcp://127.0.0.1:26657"
toml_set "$root_dir/ledger/config/config.toml" proxy-app "tcp://127.0.0.1:26658"
toml_set "$root_dir/ledger/config/config.toml" proxy_app "tcp://127.0.0.1:26658"
toml_set "$root_dir/kvstore/config/config.toml" p2p.laddr "tcp://127.0.0.1:16656"
toml_set "$root_dir/kvstore/config/config.toml" rpc.laddr "tcp://127.0.0.1:16657"
toml_set "$root_dir/kvstore/config/config.toml" proxy-app "tcp://127.0.0.1:16658"
toml_set "$root_dir/kvstore/config/config.toml" proxy_app "tcp://127.0.0.1:16658"
}

tmux new-session -s "$tmux_name" -n tendermint-ledger -d "TMHOME=\"$root_dir/ledger\" tendermint start 2>&1 | tee \"$root_dir/tendermint-ledger.log\""
Expand Down
9 changes: 5 additions & 4 deletions src/many-abci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ doc = false

[dependencies]
async-trait = "0.1.51"
base64 = "0.20.0" # TODO: Remove when https://github.com/informalsystems/tendermint-rs/issues/1251 is fixed
ciborium = "0.2.0"
clap = { version = "3.0.0", features = ["derive"] }
coset = "0.3"
Expand All @@ -34,10 +35,10 @@ reqwest = "0.11.6"
sha2 = "0.10.1"
signal-hook = "0.3.13"
smol = "1.2.5"
tendermint = { git = "https://github.com/informalsystems/tendermint-rs.git", rev = "ab896a6971b1782ecf45e0c2dae553bce798c39b" }
tendermint-abci = { git = "https://github.com/informalsystems/tendermint-rs.git", rev = "ab896a6971b1782ecf45e0c2dae553bce798c39b" }
tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs.git", features = [ "http-client" ], rev = "ab896a6971b1782ecf45e0c2dae553bce798c39b" }
tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs.git", rev = "ab896a6971b1782ecf45e0c2dae553bce798c39b" }
tendermint = "0.28.0"
tendermint-abci = "0.28.0"
tendermint-rpc = { version = "0.28.0", features = ["http-client"]}
tendermint-proto = "0.28.0"
tokio = { version = "1.13.0", features = [ "full" ] }
tracing = "0.1.28"
tracing-subscriber = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion src/many-abci/src/many_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<C: Client + Sync> AbciModuleMany<C> {
if is_command {
let response = self
.client
.broadcast_tx_sync(tendermint_rpc::abci::Transaction::from(data))
.broadcast_tx_sync(data)
.await
.map_err(ManyError::unexpected_transport_error)?;

Expand Down
20 changes: 10 additions & 10 deletions src/many-abci/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn _many_block_from_tendermint_block(block: tendermint::Block) -> Block {
} else {
BlockIdentifier::new(block.header.last_block_id.unwrap().hash.into(), height - 1)
},
app_hash: Some(block.header.app_hash.value()),
app_hash: Some(block.header.app_hash.as_bytes().to_vec()),
timestamp: Timestamp::new(
block
.header
Expand Down Expand Up @@ -76,16 +76,16 @@ impl<C: Client + Send + Sync> r#async::AsyncModuleBackend for AbciBlockchainModu

if let Ok(hash) = TryInto::<[u8; 32]>::try_into(hash) {
smol::block_on(async {
match self
.client
.tx(tendermint_rpc::abci::transaction::Hash::new(hash), false)
.await
{
match self.client.tx(tendermint::Hash::Sha256(hash), false).await {
Ok(tx) => {
tracing::warn!("result: {}", hex::encode(tx.tx_result.data.as_bytes()));
// Bse64 decode is required because of an issue in `tendermint-rs` 0.28.0
// TODO: Remove when https://github.com/informalsystems/tendermint-rs/issues/1251 is fixed
let cbor_tx_result_data = base64::decode(&tx.tx_result.data)
.map_err(ManyError::deserialization_error)?;
tracing::warn!("result: {}", hex::encode(&cbor_tx_result_data));
Ok(StatusReturn::Done {
response: Box::new(
ResponseMessage::from_bytes(tx.tx_result.data.as_bytes())
ResponseMessage::from_bytes(&cbor_tx_result_data)
.map_err(abci_frontend::abci_transport_error)?,
),
})
Expand All @@ -112,7 +112,7 @@ impl<C: Client + Send + Sync> blockchain::BlockchainModuleBackend for AbciBlockc
hash: status.sync_info.latest_block_hash.as_bytes().to_vec(),
height: status.sync_info.latest_block_height.value(),
},
app_hash: Some(status.sync_info.latest_app_hash.value().to_vec()),
app_hash: Some(status.sync_info.latest_app_hash.as_bytes().to_vec()),
retained_height: None,
})
}
Expand All @@ -126,7 +126,7 @@ impl<C: Client + Send + Sync> blockchain::BlockchainModuleBackend for AbciBlockc
SingleTransactionQuery::Hash(hash) => {
if let Ok(hash) = TryInto::<[u8; 32]>::try_into(hash) {
self.client
.tx(tendermint_rpc::abci::transaction::Hash::new(hash), true)
.tx(tendermint::Hash::Sha256(hash), true)
.await
.map_err(|e| {
tracing::error!("abci transport: {}", e.to_string());
Expand Down

0 comments on commit e3b719f

Please sign in to comment.