From a358511c53dadfbdb9b0213059273cf151f54c55 Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli <> Date: Wed, 3 Aug 2022 14:12:41 +0200 Subject: [PATCH 01/17] [ci] improve e2e log upload to add validator logs --- .github/workflows/build-and-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index be86985717..467defb3a3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -205,7 +205,9 @@ jobs: uses: actions/upload-artifact@v3 with: name: logs-e2e${{ matrix.make.suffix }}-${{ github.sha }} - path: /tmp/.*/logs/ + path: | + /tmp/.*/logs/ + /tmp/.*/e2e-test.*/setup/validator-*/.anoma/logs/*.log retention-days: 5 - name: Print sccache stats if: always() From 92d52d8cdb0d0f1e09b54c7f4d39ae18160f9976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 26 Jul 2022 14:21:36 +0200 Subject: [PATCH 02/17] test/e2e: update assert_success/failure to first consume output --- tests/src/e2e/ledger_tests.rs | 4 ++-- tests/src/e2e/setup.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index f150e6eac0..a83d3f54ca 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -1566,7 +1566,7 @@ fn test_genesis_validators() -> Result<()> { let validator_0_alias = "validator-0"; let validator_1_alias = "validator-1"; - let init_genesis_validator_0 = setup::run_cmd( + let mut init_genesis_validator_0 = setup::run_cmd( Bin::Client, [ "utils", @@ -1602,7 +1602,7 @@ fn test_genesis_validators() -> Result<()> { .remove(validator_0_alias) .unwrap(); - let init_genesis_validator_1 = setup::run_cmd( + let mut init_genesis_validator_1 = setup::run_cmd( Bin::Client, [ "utils", diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index 2b0aba0696..28f1cf1825 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -503,14 +503,20 @@ impl AnomaCmd { } /// Assert that the process exited with success - pub fn assert_success(&self) { + pub fn assert_success(&mut self) { + // Make sure that there is no unread output first + let _ = self.exp_eof().unwrap(); + let status = self.session.wait().unwrap(); assert_eq!(WaitStatus::Exited(self.session.pid(), 0), status); } /// Assert that the process exited with failure #[allow(dead_code)] - pub fn assert_failure(&self) { + pub fn assert_failure(&mut self) { + // Make sure that there is no unread output first + let _ = self.exp_eof().unwrap(); + let status = self.session.wait().unwrap(); assert_ne!(WaitStatus::Exited(self.session.pid(), 0), status); } From 0bacc9506258bbf484a09f9d51963d18f036f473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 1 Aug 2022 17:19:14 +0200 Subject: [PATCH 03/17] changelog: add #247 --- .changelog/unreleased/testing/247-e2e-fix-cmd-assert.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/testing/247-e2e-fix-cmd-assert.md diff --git a/.changelog/unreleased/testing/247-e2e-fix-cmd-assert.md b/.changelog/unreleased/testing/247-e2e-fix-cmd-assert.md new file mode 100644 index 0000000000..6696c5946a --- /dev/null +++ b/.changelog/unreleased/testing/247-e2e-fix-cmd-assert.md @@ -0,0 +1,2 @@ +- E2E: Consume unread output before checking exit status. + ([#247](https://github.com/anoma/namada/pull/247)) From 0dd32e6953c016a169691e1b187a88310bc7d3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 27 Jul 2022 18:33:05 +0200 Subject: [PATCH 04/17] deps: remove ABCI dependencies, use ABCI++ as default --- Cargo.lock | 285 +++----------------------- apps/Cargo.toml | 39 +--- encoding_spec/Cargo.toml | 14 +- shared/Cargo.toml | 34 +-- tests/Cargo.toml | 23 +-- tx_prelude/Cargo.toml | 12 +- vm_env/Cargo.toml | 14 +- vp_prelude/Cargo.toml | 12 +- wasm/tx_template/Cargo.lock | 18 +- wasm/tx_template/Cargo.toml | 2 - wasm/vp_template/Cargo.lock | 18 +- wasm/vp_template/Cargo.toml | 2 - wasm/wasm_source/Cargo.lock | 18 +- wasm/wasm_source/Cargo.toml | 5 - wasm_for_tests/wasm_source/Cargo.lock | 18 +- 15 files changed, 80 insertions(+), 434 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31d67389e0..8eab58b3a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2189,10 +2189,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi 0.10.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -2595,33 +2593,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "ibc" -version = "0.12.0" -source = "git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5#e14560ecfc3f275a63b5702e038cbabd2797b2b6" -dependencies = [ - "bytes 1.1.0", - "derive_more", - "flex-error", - "ibc-proto 0.16.0 (git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5)", - "ics23", - "num-traits 0.2.15", - "prost 0.9.0", - "prost-types 0.9.0", - "safe-regex", - "serde 1.0.137", - "serde_derive", - "serde_json", - "sha2 0.10.2", - "subtle-encoding", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-light-client-verifier 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-testgen 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "time 0.3.9", - "tracing 0.1.35", -] - [[package]] name = "ibc" version = "0.12.0" @@ -2630,7 +2601,7 @@ dependencies = [ "bytes 1.1.0", "derive_more", "flex-error", - "ibc-proto 0.16.0 (git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc)", + "ibc-proto", "ics23", "num-traits 0.2.15", "prost 0.9.0", @@ -2641,27 +2612,14 @@ dependencies = [ "serde_json", "sha2 0.10.2", "subtle-encoding", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "tendermint-light-client-verifier 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "tendermint-testgen 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", + "tendermint", + "tendermint-light-client-verifier", + "tendermint-proto", + "tendermint-testgen", "time 0.3.9", "tracing 0.1.35", ] -[[package]] -name = "ibc-proto" -version = "0.16.0" -source = "git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5#e14560ecfc3f275a63b5702e038cbabd2797b2b6" -dependencies = [ - "bytes 1.1.0", - "prost 0.9.0", - "prost-types 0.9.0", - "serde 1.0.137", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tonic", -] - [[package]] name = "ibc-proto" version = "0.16.0" @@ -2671,7 +2629,7 @@ dependencies = [ "prost 0.9.0", "prost-types 0.9.0", "serde 1.0.137", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", + "tendermint-proto", "tonic", ] @@ -3890,10 +3848,8 @@ dependencies = [ "ferveo-common", "group-threshold-cryptography", "hex", - "ibc 0.12.0 (git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5)", - "ibc 0.12.0 (git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc)", - "ibc-proto 0.16.0 (git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5)", - "ibc-proto 0.16.0 (git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc)", + "ibc", + "ibc-proto", "ics23", "itertools 0.10.3", "loupe", @@ -3912,10 +3868,8 @@ dependencies = [ "sha2 0.9.9", "sparse-merkle-tree", "tempfile", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", + "tendermint", + "tendermint-proto", "test-log", "thiserror", "tonic-build", @@ -3995,14 +3949,10 @@ dependencies = [ "sysinfo", "tar", "tempfile", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "tendermint-config 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-config 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "tendermint-rpc 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-rpc 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", + "tendermint", + "tendermint-config", + "tendermint-proto", + "tendermint-rpc", "test-log", "thiserror", "tokio", @@ -4011,8 +3961,7 @@ dependencies = [ "tonic", "tonic-build", "tower", - "tower-abci 0.1.0 (git+https://github.com/heliaxdev/tower-abci?branch=yuji/rebase_v0.23.5_tracing)", - "tower-abci 0.1.0 (git+https://github.com/heliaxdev/tower-abci?rev=f6463388fc319b6e210503b43b3aecf6faf6b200)", + "tower-abci", "tracing 0.1.35", "tracing-log", "tracing-subscriber 0.3.11", @@ -4076,10 +4025,6 @@ dependencies = [ "serde_json", "sha2 0.9.9", "tempfile", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/abcipp-v0.23.5)", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/abcipp-v0.23.5)", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", "test-log", "toml", "tracing 0.1.35", @@ -6305,62 +6250,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "tendermint" -version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/abcipp-v0.23.5#e43b68719e70e8e1c002e7f6fa557e0bafa01e0d" -dependencies = [ - "async-trait", - "bytes 1.1.0", - "ed25519", - "ed25519-dalek", - "flex-error", - "futures 0.3.21", - "num-traits 0.2.15", - "once_cell", - "prost 0.9.0", - "prost-types 0.9.0", - "serde 1.0.137", - "serde_bytes", - "serde_json", - "serde_repr", - "sha2 0.9.9", - "signature", - "subtle 2.4.1", - "subtle-encoding", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/abcipp-v0.23.5)", - "time 0.3.9", - "zeroize", -] - -[[package]] -name = "tendermint" -version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" -dependencies = [ - "async-trait", - "bytes 1.1.0", - "ed25519", - "ed25519-dalek", - "flex-error", - "futures 0.3.21", - "num-traits 0.2.15", - "once_cell", - "prost 0.9.0", - "prost-types 0.9.0", - "serde 1.0.137", - "serde_bytes", - "serde_json", - "serde_repr", - "sha2 0.9.9", - "signature", - "subtle 2.4.1", - "subtle-encoding", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "time 0.3.9", - "zeroize", -] - [[package]] name = "tendermint" version = "0.23.5" @@ -6384,24 +6273,11 @@ dependencies = [ "signature", "subtle 2.4.1", "subtle-encoding", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", + "tendermint-proto", "time 0.3.9", "zeroize", ] -[[package]] -name = "tendermint-config" -version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" -dependencies = [ - "flex-error", - "serde 1.0.137", - "serde_json", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "toml", - "url 2.2.2", -] - [[package]] name = "tendermint-config" version = "0.23.5" @@ -6410,24 +6286,11 @@ dependencies = [ "flex-error", "serde 1.0.137", "serde_json", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", + "tendermint", "toml", "url 2.2.2", ] -[[package]] -name = "tendermint-light-client-verifier" -version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" -dependencies = [ - "derive_more", - "flex-error", - "serde 1.0.137", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-rpc 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "time 0.3.9", -] - [[package]] name = "tendermint-light-client-verifier" version = "0.23.5" @@ -6436,42 +6299,8 @@ dependencies = [ "derive_more", "flex-error", "serde 1.0.137", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "tendermint-rpc 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "time 0.3.9", -] - -[[package]] -name = "tendermint-proto" -version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/abcipp-v0.23.5#e43b68719e70e8e1c002e7f6fa557e0bafa01e0d" -dependencies = [ - "bytes 1.1.0", - "flex-error", - "num-derive", - "num-traits 0.2.15", - "prost 0.9.0", - "prost-types 0.9.0", - "serde 1.0.137", - "serde_bytes", - "subtle-encoding", - "time 0.3.9", -] - -[[package]] -name = "tendermint-proto" -version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" -dependencies = [ - "bytes 1.1.0", - "flex-error", - "num-derive", - "num-traits 0.2.15", - "prost 0.9.0", - "prost-types 0.9.0", - "serde 1.0.137", - "serde_bytes", - "subtle-encoding", + "tendermint", + "tendermint-rpc", "time 0.3.9", ] @@ -6492,39 +6321,6 @@ dependencies = [ "time 0.3.9", ] -[[package]] -name = "tendermint-rpc" -version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" -dependencies = [ - "async-trait", - "async-tungstenite", - "bytes 1.1.0", - "flex-error", - "futures 0.3.21", - "getrandom 0.2.6", - "http", - "hyper 0.14.19", - "hyper-proxy", - "hyper-rustls", - "peg", - "pin-project 1.0.10", - "serde 1.0.137", - "serde_bytes", - "serde_json", - "subtle-encoding", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-config 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "thiserror", - "time 0.3.9", - "tokio", - "tracing 0.1.35", - "url 2.2.2", - "uuid", - "walkdir", -] - [[package]] name = "tendermint-rpc" version = "0.23.5" @@ -6546,9 +6342,9 @@ dependencies = [ "serde_bytes", "serde_json", "subtle-encoding", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "tendermint-config 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", + "tendermint", + "tendermint-config", + "tendermint-proto", "thiserror", "time 0.3.9", "tokio", @@ -6558,21 +6354,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "tendermint-testgen" -version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" -dependencies = [ - "ed25519-dalek", - "gumdrop", - "serde 1.0.137", - "serde_json", - "simple-error", - "tempfile", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "time 0.3.9", -] - [[package]] name = "tendermint-testgen" version = "0.23.5" @@ -6584,7 +6365,7 @@ dependencies = [ "serde_json", "simple-error", "tempfile", - "tendermint 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", + "tendermint", "time 0.3.9", ] @@ -7024,24 +6805,6 @@ dependencies = [ "tracing 0.1.35", ] -[[package]] -name = "tower-abci" -version = "0.1.0" -source = "git+https://github.com/heliaxdev/tower-abci?branch=yuji/rebase_v0.23.5_tracing#73e43bf79fb21b4969cc09f79a0a40ce4cc7bb52" -dependencies = [ - "bytes 1.1.0", - "futures 0.3.21", - "pin-project 1.0.10", - "prost 0.9.0", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5)", - "tokio", - "tokio-stream", - "tokio-util 0.6.10", - "tower", - "tracing 0.1.30", - "tracing-tower", -] - [[package]] name = "tower-abci" version = "0.1.0" @@ -7051,7 +6814,7 @@ dependencies = [ "futures 0.3.21", "pin-project 1.0.10", "prost 0.9.0", - "tendermint-proto 0.23.5 (git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9)", + "tendermint-proto", "tokio", "tokio-stream", "tokio-util 0.6.10", diff --git a/apps/Cargo.toml b/apps/Cargo.toml index 1464b22c8b..7a4dffac76 100644 --- a/apps/Cargo.toml +++ b/apps/Cargo.toml @@ -39,32 +39,14 @@ name = "namadaw" path = "src/bin/anoma-wallet/main.rs" [features] -default = ["std", "ABCI"] +default = ["std"] dev = ["namada/dev"] std = ["ed25519-consensus/std", "rand/std", "rand_core/std"] # for integration tests and test utilies -ABCI = [ - "tendermint-stable", - "tendermint-config-abci", - "tendermint-proto-abci", - "tendermint-rpc-abci", - "tower-abci-old", - "namada/ABCI", - "namada/ibc-vp-abci", -] -ABCI-plus-plus = [ - "tendermint", - "tendermint-config", - "tendermint-proto", - "tendermint-rpc", - "tower-abci", - "namada/ABCI-plus-plus", - "namada/ibc-vp", -] testing = ["dev"] [dependencies] -namada = {path = "../shared", default-features = false, features = ["wasm-runtime", "ferveo-tpke", "rand"]} +namada = {path = "../shared", features = ["wasm-runtime", "ferveo-tpke", "rand"]} ark-serialize = "0.3.0" ark-std = "0.3.0" async-std = {version = "1.9.0", features = ["unstable"]} @@ -123,14 +105,10 @@ sparse-merkle-tree = {git = "https://github.com/heliaxdev/sparse-merkle-tree", b sysinfo = {version = "=0.21.1", default-features = false} tar = "0.4.37" # temporarily using fork work-around -tendermint = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9", optional = true} -tendermint-config = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9", optional = true} -tendermint-config-abci = {package = "tendermint-config", git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5", optional = true} -tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9", optional = true} -tendermint-proto-abci = {package = "tendermint-proto", git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5", optional = true} -tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9", optional = true, features = ["http-client", "websocket-client"]} -tendermint-rpc-abci = {package = "tendermint-rpc", git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5", optional = true, features = ["http-client", "websocket-client"]} -tendermint-stable = {package = "tendermint", git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5", optional = true} +tendermint = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} +tendermint-config = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} +tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} +tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9", features = ["http-client", "websocket-client"]} thiserror = "1.0.30" tokio = {version = "1.8.2", features = ["full"]} toml = "0.5.8" @@ -138,8 +116,7 @@ tonic = "0.6.1" tower = "0.4" # Also, using the same version of tendermint-rs as we do here. # with a patch for https://github.com/penumbra-zone/tower-abci/issues/7. -tower-abci = {git = "https://github.com/heliaxdev/tower-abci", rev = "f6463388fc319b6e210503b43b3aecf6faf6b200", optional = true} -tower-abci-old = {package = "tower-abci", git = "https://github.com/heliaxdev/tower-abci", branch = "yuji/rebase_v0.23.5_tracing", optional = true} +tower-abci = {git = "https://github.com/heliaxdev/tower-abci", rev = "f6463388fc319b6e210503b43b3aecf6faf6b200"} tracing = "0.1.30" tracing-log = "0.1.2" tracing-subscriber = {version = "0.3.7", features = ["env-filter"]} @@ -147,7 +124,7 @@ websocket = "0.26.2" winapi = "0.3.9" [dev-dependencies] -namada = {path = "../shared", default-features = false, features = ["testing", "wasm-runtime"]} +namada = {path = "../shared", features = ["testing", "wasm-runtime"]} cargo-watch = "7.5.0" bit-set = "0.5.2" # A fork with state machime testing diff --git a/encoding_spec/Cargo.toml b/encoding_spec/Cargo.toml index e4e61a098a..d875bfc1a7 100644 --- a/encoding_spec/Cargo.toml +++ b/encoding_spec/Cargo.toml @@ -9,20 +9,10 @@ resolver = "2" version = "0.7.0" [features] -default = ["ABCI"] - -ABCI = [ - "namada/ABCI", - "namada/ibc-vp-abci", -] - -ABCI-plus-plus = [ - "namada/ABCI-plus-plus", - "namada/ibc-vp", -] +default = [] [dependencies] -namada = {path = "../shared", default-features = false} +namada = {path = "../shared"} borsh = "0.9.0" itertools = "0.10.3" lazy_static = "1.4.0" diff --git a/shared/Cargo.toml b/shared/Cargo.toml index d63acc035f..241fd034da 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -9,7 +9,7 @@ version = "0.7.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["ABCI", "ibc-vp-abci"] +default = [] # NOTE "dev" features that shouldn't be used in live networks are enabled by default for now dev = [] ferveo-tpke = [ @@ -19,30 +19,10 @@ ferveo-tpke = [ "rand_core", "rand", ] -# for integration tests and test utilies -ibc-vp = [ - "ibc", -] -ibc-vp-abci = [ - "ibc-abci", -] ibc-mocks = [ "ibc/mocks", ] -ibc-mocks-abci = [ - "ibc-abci/mocks", -] # for integration tests and test utilies -ABCI = [ - "ibc-proto-abci", - "tendermint-stable", - "tendermint-proto-abci", -] -ABCI-plus-plus = [ - "ibc-proto", - "tendermint", - "tendermint-proto", -] testing = [ "proptest", "rand", @@ -79,10 +59,8 @@ ferveo-common = {git = "https://github.com/anoma/ferveo"} hex = "0.4.3" tpke = {package = "group-threshold-cryptography", optional = true, git = "https://github.com/anoma/ferveo"} # TODO using the same version of tendermint-rs as we do here. -ibc = {git = "https://github.com/heliaxdev/ibc-rs", rev = "30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc", default-features = false, optional = true} -ibc-abci = {package = "ibc", git = "https://github.com/heliaxdev/ibc-rs", branch = "yuji/v0.12.0_tm_v0.23.5", default-features = false, optional = true} -ibc-proto = {git = "https://github.com/heliaxdev/ibc-rs", rev = "30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc", default-features = false, optional = true} -ibc-proto-abci = {package = "ibc-proto", git = "https://github.com/heliaxdev/ibc-rs", branch = "yuji/v0.12.0_tm_v0.23.5", default-features = false, optional = true} +ibc = {git = "https://github.com/heliaxdev/ibc-rs", rev = "30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc", default-features = false} +ibc-proto = {git = "https://github.com/heliaxdev/ibc-rs", rev = "30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc", default-features = false} ics23 = "0.6.7" itertools = "0.10.0" loupe = {version = "0.1.3", optional = true} @@ -103,10 +81,8 @@ sha2 = "0.9.3" sparse-merkle-tree = {git = "https://github.com/heliaxdev/sparse-merkle-tree", branch = "yuji/prost-0.9", default-features = false, features = ["std", "borsh"]} tempfile = {version = "3.2.0", optional = true} # temporarily using fork work-around for https://github.com/informalsystems/tendermint-rs/issues/971 -tendermint = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9", optional = true} -tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9", optional = true} -tendermint-proto-abci = {package = "tendermint-proto", git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5", optional = true} -tendermint-stable = {package = "tendermint", git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5", optional = true} +tendermint = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} +tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} thiserror = "1.0.30" tracing = "0.1.30" wasmer = {version = "=2.2.0", optional = true} diff --git a/tests/Cargo.toml b/tests/Cargo.toml index a4ea87e21e..d513da44ef 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -8,24 +8,12 @@ resolver = "2" version = "0.7.0" [features] -default = ["wasm-runtime", "ABCI"] +default = ["wasm-runtime"] wasm-runtime = ["namada/wasm-runtime"] -ABCI = [ - "namada/ABCI", - "namada/ibc-mocks-abci", - "namada_vm_env/ABCI", -] - -ABCI-plus-plus = [ - "namada/ABCI-plus-plus", - "namada/ibc-mocks", - "namada_vm_env/ABCI-plus-plus", -] - [dependencies] -namada = {path = "../shared", default-features = false, features = ["testing"]} -namada_vm_env = {path = "../vm_env", default-features = false} +namada = {path = "../shared", features = ["testing", "ibc-mocks"]} +namada_vm_env = {path = "../vm_env"} chrono = "0.4.19" concat-idents = "1.1.2" prost = "0.9.0" @@ -33,11 +21,6 @@ serde_json = {version = "1.0.65"} sha2 = "0.9.3" test-log = {version = "0.2.7", default-features = false, features = ["trace"]} tempfile = "3.2.0" -# temporarily using fork work-around -tendermint = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/abcipp-v0.23.5", optional = true} -tendermint-stable = {package = "tendermint", git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5", optional = true} -tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/abcipp-v0.23.5", optional = true} -tendermint-proto-abci = {package = "tendermint-proto", git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5", optional = true} tracing = "0.1.30" tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]} derivative = "2.2.0" diff --git a/tx_prelude/Cargo.toml b/tx_prelude/Cargo.toml index 2f82e6fd8c..a35324da05 100644 --- a/tx_prelude/Cargo.toml +++ b/tx_prelude/Cargo.toml @@ -7,16 +7,8 @@ resolver = "2" version = "0.7.0" [features] -default = ["ABCI"] - -ABCI = [ - "namada_vm_env/ABCI", -] - -ABCI-plus-plus = [ - "namada_vm_env/ABCI-plus-plus", -] +default = [] [dependencies] -namada_vm_env = {path = "../vm_env", default-features = false} +namada_vm_env = {path = "../vm_env"} sha2 = "0.10.1" diff --git a/vm_env/Cargo.toml b/vm_env/Cargo.toml index ac37e33b89..f11d57d1b0 100644 --- a/vm_env/Cargo.toml +++ b/vm_env/Cargo.toml @@ -7,20 +7,10 @@ resolver = "2" version = "0.7.0" [features] -default = ["ABCI"] - -ABCI = [ - "namada/ABCI", - "namada/ibc-vp-abci", -] - -ABCI-plus-plus = [ - "namada/ABCI-plus-plus", - "namada/ibc-vp", -] +default = [] [dependencies] -namada = {path = "../shared", default-features = false} +namada = {path = "../shared"} namada_macros = {path = "../macros"} borsh = "0.9.0" hex = "0.4.3" diff --git a/vp_prelude/Cargo.toml b/vp_prelude/Cargo.toml index c21e2bdd0e..f59c5ed032 100644 --- a/vp_prelude/Cargo.toml +++ b/vp_prelude/Cargo.toml @@ -7,16 +7,8 @@ resolver = "2" version = "0.7.0" [features] -default = ["ABCI"] - -ABCI = [ - "namada_vm_env/ABCI", -] - -ABCI-plus-plus = [ - "namada_vm_env/ABCI-plus-plus", -] +default = [] [dependencies] -namada_vm_env = {path = "../vm_env", default-features = false} +namada_vm_env = {path = "../vm_env"} sha2 = "0.10.1" diff --git a/wasm/tx_template/Cargo.lock b/wasm/tx_template/Cargo.lock index fcda82a6a5..bf9d222920 100644 --- a/wasm/tx_template/Cargo.lock +++ b/wasm/tx_template/Cargo.lock @@ -901,10 +901,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] [[package]] @@ -1069,7 +1067,7 @@ dependencies = [ [[package]] name = "ibc" version = "0.12.0" -source = "git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5#e14560ecfc3f275a63b5702e038cbabd2797b2b6" +source = "git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc#30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc" dependencies = [ "bytes", "derive_more", @@ -1096,7 +1094,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.16.0" -source = "git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5#e14560ecfc3f275a63b5702e038cbabd2797b2b6" +source = "git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc#30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc" dependencies = [ "bytes", "prost", @@ -2371,7 +2369,7 @@ dependencies = [ [[package]] name = "tendermint" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "async-trait", "bytes", @@ -2399,7 +2397,7 @@ dependencies = [ [[package]] name = "tendermint-config" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "flex-error", "serde", @@ -2412,7 +2410,7 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "derive_more", "flex-error", @@ -2425,7 +2423,7 @@ dependencies = [ [[package]] name = "tendermint-proto" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "bytes", "flex-error", @@ -2442,7 +2440,7 @@ dependencies = [ [[package]] name = "tendermint-rpc" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "bytes", "flex-error", @@ -2466,7 +2464,7 @@ dependencies = [ [[package]] name = "tendermint-testgen" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "ed25519-dalek", "gumdrop", diff --git a/wasm/tx_template/Cargo.toml b/wasm/tx_template/Cargo.toml index a0febc6baf..469104ce65 100644 --- a/wasm/tx_template/Cargo.toml +++ b/wasm/tx_template/Cargo.toml @@ -19,8 +19,6 @@ getrandom = { version = "0.2", features = ["custom"] } namada_tests = {path = "../../tests"} [patch.crates-io] -tendermint = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5"} -tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5"} # TODO temp patch for , and more tba. borsh = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"} borsh-derive = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"} diff --git a/wasm/vp_template/Cargo.lock b/wasm/vp_template/Cargo.lock index 3c82e7293e..98f6c7f71c 100644 --- a/wasm/vp_template/Cargo.lock +++ b/wasm/vp_template/Cargo.lock @@ -901,10 +901,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] [[package]] @@ -1069,7 +1067,7 @@ dependencies = [ [[package]] name = "ibc" version = "0.12.0" -source = "git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5#e14560ecfc3f275a63b5702e038cbabd2797b2b6" +source = "git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc#30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc" dependencies = [ "bytes", "derive_more", @@ -1096,7 +1094,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.16.0" -source = "git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5#e14560ecfc3f275a63b5702e038cbabd2797b2b6" +source = "git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc#30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc" dependencies = [ "bytes", "prost", @@ -2371,7 +2369,7 @@ dependencies = [ [[package]] name = "tendermint" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "async-trait", "bytes", @@ -2399,7 +2397,7 @@ dependencies = [ [[package]] name = "tendermint-config" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "flex-error", "serde", @@ -2412,7 +2410,7 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "derive_more", "flex-error", @@ -2425,7 +2423,7 @@ dependencies = [ [[package]] name = "tendermint-proto" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "bytes", "flex-error", @@ -2442,7 +2440,7 @@ dependencies = [ [[package]] name = "tendermint-rpc" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "bytes", "flex-error", @@ -2466,7 +2464,7 @@ dependencies = [ [[package]] name = "tendermint-testgen" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "ed25519-dalek", "gumdrop", diff --git a/wasm/vp_template/Cargo.toml b/wasm/vp_template/Cargo.toml index 5513f52089..125b50d07a 100644 --- a/wasm/vp_template/Cargo.toml +++ b/wasm/vp_template/Cargo.toml @@ -19,8 +19,6 @@ getrandom = { version = "0.2", features = ["custom"] } namada_tests = {path = "../../tests"} [patch.crates-io] -tendermint = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5"} -tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5"} # TODO temp patch for , and more tba. borsh = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"} borsh-derive = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"} diff --git a/wasm/wasm_source/Cargo.lock b/wasm/wasm_source/Cargo.lock index 6b59401588..b7185cc110 100644 --- a/wasm/wasm_source/Cargo.lock +++ b/wasm/wasm_source/Cargo.lock @@ -901,10 +901,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] [[package]] @@ -1069,7 +1067,7 @@ dependencies = [ [[package]] name = "ibc" version = "0.12.0" -source = "git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5#e14560ecfc3f275a63b5702e038cbabd2797b2b6" +source = "git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc#30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc" dependencies = [ "bytes", "derive_more", @@ -1096,7 +1094,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.16.0" -source = "git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5#e14560ecfc3f275a63b5702e038cbabd2797b2b6" +source = "git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc#30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc" dependencies = [ "bytes", "prost", @@ -2397,7 +2395,7 @@ dependencies = [ [[package]] name = "tendermint" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "async-trait", "bytes", @@ -2425,7 +2423,7 @@ dependencies = [ [[package]] name = "tendermint-config" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "flex-error", "serde", @@ -2438,7 +2436,7 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "derive_more", "flex-error", @@ -2451,7 +2449,7 @@ dependencies = [ [[package]] name = "tendermint-proto" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "bytes", "flex-error", @@ -2468,7 +2466,7 @@ dependencies = [ [[package]] name = "tendermint-rpc" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "bytes", "flex-error", @@ -2492,7 +2490,7 @@ dependencies = [ [[package]] name = "tendermint-testgen" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "ed25519-dalek", "gumdrop", diff --git a/wasm/wasm_source/Cargo.toml b/wasm/wasm_source/Cargo.toml index a7202d20c1..ee2234928a 100644 --- a/wasm/wasm_source/Cargo.toml +++ b/wasm/wasm_source/Cargo.toml @@ -50,11 +50,6 @@ tracing = "0.1.30" tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]} [patch.crates-io] -tendermint = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5"} -tendermint-light-client-verifier = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5"} -tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5"} -tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5"} -tendermint-testgen = {git = "https://github.com/heliaxdev/tendermint-rs", branch = "yuji/rebase_v0.23.5"} # TODO temp patch for , and more tba. borsh = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"} borsh-derive = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"} diff --git a/wasm_for_tests/wasm_source/Cargo.lock b/wasm_for_tests/wasm_source/Cargo.lock index 2507c11460..39f70c1787 100644 --- a/wasm_for_tests/wasm_source/Cargo.lock +++ b/wasm_for_tests/wasm_source/Cargo.lock @@ -902,10 +902,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi 0.10.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -1079,7 +1077,7 @@ dependencies = [ [[package]] name = "ibc" version = "0.12.0" -source = "git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5#e14560ecfc3f275a63b5702e038cbabd2797b2b6" +source = "git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc#30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc" dependencies = [ "bytes", "derive_more", @@ -1106,7 +1104,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.16.0" -source = "git+https://github.com/heliaxdev/ibc-rs?branch=yuji/v0.12.0_tm_v0.23.5#e14560ecfc3f275a63b5702e038cbabd2797b2b6" +source = "git+https://github.com/heliaxdev/ibc-rs?rev=30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc#30b3495ac56c6c37c99bc69ef9f2e84c3309c6cc" dependencies = [ "bytes", "prost", @@ -2403,7 +2401,7 @@ dependencies = [ [[package]] name = "tendermint" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "async-trait", "bytes", @@ -2431,7 +2429,7 @@ dependencies = [ [[package]] name = "tendermint-config" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "flex-error", "serde", @@ -2444,7 +2442,7 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "derive_more", "flex-error", @@ -2457,7 +2455,7 @@ dependencies = [ [[package]] name = "tendermint-proto" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "bytes", "flex-error", @@ -2474,7 +2472,7 @@ dependencies = [ [[package]] name = "tendermint-rpc" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "bytes", "flex-error", @@ -2498,7 +2496,7 @@ dependencies = [ [[package]] name = "tendermint-testgen" version = "0.23.5" -source = "git+https://github.com/heliaxdev/tendermint-rs?branch=yuji/rebase_v0.23.5#a1439b37ac64fbcaf508021fc1e1aff07c18147e" +source = "git+https://github.com/heliaxdev/tendermint-rs?rev=95c52476bc37927218374f94ac8e2a19bd35bec9#95c52476bc37927218374f94ac8e2a19bd35bec9" dependencies = [ "ed25519-dalek", "gumdrop", From f5b8ba9ae1fe9303195a53747742ed5765ab4a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 27 Jul 2022 18:33:48 +0200 Subject: [PATCH 05/17] all: remove "ABCI" conditional compilation --- apps/build.rs | 5 - apps/src/lib/cli.rs | 6 - apps/src/lib/client/gossip.rs | 3 - apps/src/lib/client/rpc.rs | 23 +- apps/src/lib/client/signing.rs | 15 +- apps/src/lib/client/tendermint_rpc_types.rs | 10 +- .../lib/client/tendermint_websocket_client.rs | 440 ----------------- apps/src/lib/client/tm_jsonrpc_client.rs | 402 ++++++++------- apps/src/lib/client/tx.rs | 98 +--- apps/src/lib/client/utils.rs | 6 - apps/src/lib/config/mod.rs | 6 - apps/src/lib/node/ledger/broadcaster.rs | 3 - apps/src/lib/node/ledger/events.rs | 53 +- apps/src/lib/node/ledger/mod.rs | 15 - apps/src/lib/node/ledger/rpc.rs | 3 - .../lib/node/ledger/shell/finalize_block.rs | 205 +------- apps/src/lib/node/ledger/shell/init_chain.rs | 9 - apps/src/lib/node/ledger/shell/mod.rs | 80 +-- .../lib/node/ledger/shell/prepare_proposal.rs | 465 +++++++++--------- .../lib/node/ledger/shell/process_proposal.rs | 187 +------ apps/src/lib/node/ledger/shell/queries.rs | 9 - apps/src/lib/node/ledger/shims/abcipp_shim.rs | 70 --- .../node/ledger/shims/abcipp_shim_types.rs | 92 +--- apps/src/lib/node/ledger/tendermint_node.rs | 101 +--- apps/src/lib/node/matchmaker.rs | 18 +- shared/build.rs | 4 - shared/src/ledger/storage/merkle_tree.rs | 3 - shared/src/ledger/storage/mod.rs | 3 - shared/src/lib.rs | 17 +- shared/src/types/hash.rs | 6 - shared/src/types/time.rs | 3 - tests/src/e2e/eth_bridge_tests.rs | 4 +- tests/src/e2e/gossip_tests.rs | 11 +- tests/src/e2e/helpers.rs | 27 +- tests/src/e2e/ledger_tests.rs | 62 +-- tests/src/e2e/setup.rs | 50 +- 36 files changed, 545 insertions(+), 1969 deletions(-) diff --git a/apps/build.rs b/apps/build.rs index 514785c3e0..ae49503e78 100644 --- a/apps/build.rs +++ b/apps/build.rs @@ -12,11 +12,6 @@ const PROTO_SRC: &str = "./proto"; const RUSTFMT_TOOLCHAIN_SRC: &str = "../rust-nightly-version"; fn main() { - #[cfg(all(feature = "ABCI", feature = "ABCI-plus-plus"))] - compile_error!( - "`ABCI` and `ABCI-plus-plus` may not be used at the same time" - ); - // Discover the repository version, if it exists println!("cargo:rerun-if-changed=../.git"); let describe_opts = DescribeOptions::new(); diff --git a/apps/src/lib/cli.rs b/apps/src/lib/cli.rs index 95f7368668..5eef95b34d 100644 --- a/apps/src/lib/cli.rs +++ b/apps/src/lib/cli.rs @@ -1372,14 +1372,8 @@ pub mod args { use namada::types::token; use namada::types::transaction::GasLimit; use serde::Deserialize; - #[cfg(not(feature = "ABCI"))] use tendermint::Timeout; - #[cfg(not(feature = "ABCI"))] use tendermint_config::net::Address as TendermintAddress; - #[cfg(feature = "ABCI")] - use tendermint_config_abci::net::Address as TendermintAddress; - #[cfg(feature = "ABCI")] - use tendermint_stable::Timeout; use super::context::{WalletAddress, WalletKeypair, WalletPublicKey}; use super::utils::*; diff --git a/apps/src/lib/client/gossip.rs b/apps/src/lib/client/gossip.rs index a3f55518d1..2225898ff4 100644 --- a/apps/src/lib/client/gossip.rs +++ b/apps/src/lib/client/gossip.rs @@ -4,10 +4,7 @@ use std::io::Write; use borsh::BorshSerialize; use namada::proto::Signed; use namada::types::intent::{Exchange, FungibleTokenIntent}; -#[cfg(not(feature = "ABCI"))] use tendermint_config::net::Address as TendermintAddress; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::net::Address as TendermintAddress; use super::signing; use crate::cli::{self, args, Context}; diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index 21ccb65433..34652ac825 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -30,30 +30,13 @@ use namada::types::key::*; use namada::types::storage::{Epoch, PrefixValue}; use namada::types::token::{balance_key, Amount}; use namada::types::{address, storage, token}; -#[cfg(not(feature = "ABCI"))] use tendermint::abci::Code; -#[cfg(not(feature = "ABCI"))] use tendermint_config::net::Address as TendermintAddress; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::net::Address as TendermintAddress; -#[cfg(not(feature = "ABCI"))] use tendermint_rpc::error::Error as TError; -#[cfg(not(feature = "ABCI"))] use tendermint_rpc::query::Query; -#[cfg(not(feature = "ABCI"))] -use tendermint_rpc::{Client, HttpClient}; -#[cfg(not(feature = "ABCI"))] -use tendermint_rpc::{Order, SubscriptionClient, WebSocketClient}; -#[cfg(feature = "ABCI")] -use tendermint_rpc_abci::error::Error as TError; -#[cfg(feature = "ABCI")] -use tendermint_rpc_abci::query::Query; -#[cfg(feature = "ABCI")] -use tendermint_rpc_abci::{Client, HttpClient}; -#[cfg(feature = "ABCI")] -use tendermint_rpc_abci::{Order, SubscriptionClient, WebSocketClient}; -#[cfg(feature = "ABCI")] -use tendermint_stable::abci::Code; +use tendermint_rpc::{ + Client, HttpClient, Order, SubscriptionClient, WebSocketClient, +}; use crate::cli::{self, args, Context}; use crate::client::tendermint_rpc_types::TxResponse; diff --git a/apps/src/lib/client/signing.rs b/apps/src/lib/client/signing.rs index 08ba80a6d2..dd86470403 100644 --- a/apps/src/lib/client/signing.rs +++ b/apps/src/lib/client/signing.rs @@ -9,10 +9,7 @@ use namada::types::address::{Address, ImplicitAddress}; use namada::types::key::*; use namada::types::storage::Epoch; use namada::types::transaction::{hash_tx, Fee, WrapperTx}; -#[cfg(not(feature = "ABCI"))] use tendermint_config::net::Address as TendermintAddress; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::net::Address as TendermintAddress; use super::rpc; use crate::cli::context::WalletAddress; @@ -139,18 +136,10 @@ pub async fn sign_wrapper( }; // We use this to determine when the wrapper tx makes it on-chain - let wrapper_hash = if !cfg!(feature = "ABCI") { - hash_tx(&tx.try_to_vec().unwrap()).to_string() - } else { - tx.tx_hash.to_string() - }; + let wrapper_hash = hash_tx(&tx.try_to_vec().unwrap()).to_string(); // We use this to determine when the decrypted inner tx makes it // on-chain - let decrypted_hash = if !cfg!(feature = "ABCI") { - Some(tx.tx_hash.to_string()) - } else { - None - }; + let decrypted_hash = tx.tx_hash.to_string(); TxBroadcastData::Wrapper { tx: tx .sign(keypair) diff --git a/apps/src/lib/client/tendermint_rpc_types.rs b/apps/src/lib/client/tendermint_rpc_types.rs index d910af7bb8..6575c74082 100644 --- a/apps/src/lib/client/tendermint_rpc_types.rs +++ b/apps/src/lib/client/tendermint_rpc_types.rs @@ -5,7 +5,6 @@ use serde::Serialize; use thiserror::Error; use crate::cli::safe_exit; -#[cfg(not(feature = "ABCI"))] use crate::node::ledger::events::Attributes; /// Errors from interacting with Tendermint's jsonrpc endpoint @@ -15,7 +14,6 @@ pub enum Error { Address(String), #[error("Error in sending JSON RPC request to Tendermint")] Send, - #[cfg(not(feature = "ABCI"))] #[error("Received an error response from Tendermint: {0:?}")] Rpc(tendermint_rpc::response_error::ResponseError), #[error("Received malformed JSON response from Tendermint")] @@ -40,7 +38,7 @@ pub enum TxBroadcastData { Wrapper { tx: Tx, wrapper_hash: String, - decrypted_hash: Option, + decrypted_hash: String, }, } @@ -63,9 +61,6 @@ impl TxResponse { let tx_hash_json = serde_json::Value::String(tx_hash.to_string()); let mut selector = jsonpath::selector(&json); let mut index = 0; - #[cfg(feature = "ABCI")] - let evt_key = "applied"; - #[cfg(not(feature = "ABCI"))] let evt_key = "accepted"; // Find the tx with a matching hash let hash = loop { @@ -134,7 +129,6 @@ impl TxResponse { } } -#[cfg(not(feature = "ABCI"))] mod params { use std::convert::TryFrom; use std::time::Duration; @@ -259,7 +253,6 @@ mod params { /// Searches for custom events emitted from the ledger and converts /// them back to thin wrapper around a hashmap for further parsing. /// Returns none if the event is not found. - #[cfg(not(feature = "ABCI"))] pub fn parse(reply: EventReply, tx_hash: &str) -> Option { let mut event = reply .items @@ -339,5 +332,4 @@ mod params { } } -#[cfg(not(feature = "ABCI"))] pub use params::*; diff --git a/apps/src/lib/client/tendermint_websocket_client.rs b/apps/src/lib/client/tendermint_websocket_client.rs index 370c6d51f8..d5af3bcee1 100644 --- a/apps/src/lib/client/tendermint_websocket_client.rs +++ b/apps/src/lib/client/tendermint_websocket_client.rs @@ -6,20 +6,10 @@ use std::sync::{Arc, Mutex}; use std::time::Duration; use async_trait::async_trait; -#[cfg(not(feature = "ABCI"))] use tendermint_config::net::Address; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::net::Address; -#[cfg(not(feature = "ABCI"))] use tendermint_rpc::{ Client, Error as RpcError, Request, Response, SimpleRequest, }; -#[cfg(feature = "ABCI")] -use tendermint_rpc_abci::query::Query; -#[cfg(feature = "ABCI")] -use tendermint_rpc_abci::{ - Client, Error as RpcError, Request, Response, SimpleRequest, -}; use thiserror::Error; use tokio::time::Instant; use websocket::result::WebSocketError; @@ -59,18 +49,9 @@ mod rpc_types { use std::str::FromStr; use serde::{de, Deserialize, Serialize, Serializer}; - #[cfg(not(feature = "ABCI"))] use tendermint_rpc::method::Method; - #[cfg(not(feature = "ABCI"))] use tendermint_rpc::query::{EventType, Query}; - #[cfg(not(feature = "ABCI"))] use tendermint_rpc::{request, response}; - #[cfg(feature = "ABCI")] - use tendermint_rpc_abci::method::Method; - #[cfg(feature = "ABCI")] - use tendermint_rpc_abci::query::{EventType, Query}; - #[cfg(feature = "ABCI")] - use tendermint_rpc_abci::{request, response}; use super::Json; @@ -187,8 +168,6 @@ impl Display for WebSocketAddress { write!(f, "ws://{}:{}/websocket", self.host, self.port) } } -#[cfg(feature = "ABCI")] -use rpc_types::{RpcResponse, RpcSubscription, SubscribeType}; /// We need interior mutability since the `perform` method of the `Client` /// trait from `tendermint_rpc` only takes `&self` as an argument @@ -197,16 +176,8 @@ use rpc_types::{RpcResponse, RpcSubscription, SubscribeType}; type Websocket = Arc>>; type ResponseQueue = Arc>>; -#[cfg(feature = "ABCI")] -struct Subscription { - id: String, - query: Query, -} - pub struct TendermintWebsocketClient { websocket: Websocket, - #[cfg(feature = "ABCI")] - subscribed: Option, received_responses: ResponseQueue, connection_timeout: Duration, } @@ -224,8 +195,6 @@ impl TendermintWebsocketClient { { Ok(websocket) => Ok(Self { websocket: Arc::new(Mutex::new(websocket)), - #[cfg(feature = "ABCI")] - subscribed: None, received_responses: Arc::new(Mutex::new(HashMap::new())), connection_timeout: connection_timeout .unwrap_or_else(|| Duration::new(300, 0)), @@ -238,149 +207,8 @@ impl TendermintWebsocketClient { pub fn close(&mut self) { // Even in the case of errors, this will be shutdown let _ = self.websocket.lock().unwrap().shutdown(); - #[cfg(feature = "ABCI")] - { - self.subscribed = None; - } self.received_responses.lock().unwrap().clear(); } - - /// Subscribes to an event specified by the query argument. - #[cfg(feature = "ABCI")] - pub fn subscribe(&mut self, query: Query) -> Result<(), Error> { - // We do not support more than one subscription currently - // This can be fixed by correlating on ids later - if self.subscribed.is_some() { - return Err(Error::AlreadySubscribed); - } - // send the subscription request - let message = RpcSubscription(SubscribeType::Subscribe, query.clone()) - .into_json(); - let msg_id = get_id(&message).unwrap(); - - self.websocket - .lock() - .unwrap() - .send_message(&Message::text(&message)) - .map_err(Error::Websocket)?; - - // check that the request was received and a success message returned - match self.process_response(|_| Error::Subscribe(message), None) { - Ok(_) => { - self.subscribed = Some(Subscription { id: msg_id, query }); - Ok(()) - } - Err(err) => Err(err), - } - } - - /// Receive a response from the subscribed event or - /// process the response if it has already been received - #[cfg(feature = "ABCI")] - pub fn receive_response(&self) -> Result { - if let Some(Subscription { id, .. }) = &self.subscribed { - let response = self.process_response( - Error::Response, - self.received_responses.lock().unwrap().remove(id), - )?; - Ok(response) - } else { - Err(Error::NotSubscribed) - } - } - - /// Unsubscribe from the currently subscribed event - /// Note that even if an error is returned, the client - /// will return to an unsubscribed state - #[cfg(feature = "ABCI")] - pub fn unsubscribe(&mut self) -> Result<(), Error> { - match self.subscribed.take() { - Some(Subscription { query, .. }) => { - // send the subscription request - let message = - RpcSubscription(SubscribeType::Unsubscribe, query) - .into_json(); - - self.websocket - .lock() - .unwrap() - .send_message(&Message::text(&message)) - .map_err(Error::Websocket)?; - // empty out the message queue. Should be empty already - self.received_responses.lock().unwrap().clear(); - // check that the request was received and a success message - // returned - match self - .process_response(|_| Error::Unsubscribe(message), None) - { - Ok(_) => Ok(()), - Err(err) => Err(err), - } - } - _ => Err(Error::NotSubscribed), - } - } - - /// Process the next response received and handle any exceptions that - /// may have occurred. Takes a function to map response to an error - /// as a parameter. - /// - /// Optionally, the response may have been received earlier while - /// handling a different request. In that case, we process it - /// now. - #[cfg(feature = "ABCI")] - fn process_response( - &self, - f: F, - received: Option, - ) -> Result - where - F: FnOnce(String) -> Error, - { - let resp = match received { - Some(resp) => OwnedMessage::Text(resp), - None => { - let mut websocket = self.websocket.lock().unwrap(); - let start = Instant::now(); - loop { - if Instant::now().duration_since(start) - > self.connection_timeout - { - tracing::error!( - "Websocket connection timed out while waiting for \ - response" - ); - return Err(Error::ConnectionTimeout); - } - match websocket.recv_message().map_err(Error::Websocket)? { - text @ OwnedMessage::Text(_) => break text, - OwnedMessage::Ping(data) => { - tracing::debug!( - "Received websocket Ping, sending Pong" - ); - websocket - .send_message(&OwnedMessage::Pong(data)) - .unwrap(); - continue; - } - OwnedMessage::Pong(_) => { - tracing::debug!( - "Received websocket Pong, ignoring" - ); - continue; - } - other => return Err(Error::UnexpectedResponse(other)), - } - } - } - }; - match resp { - OwnedMessage::Text(raw) => RpcResponse::from_string(raw) - .map(|v| v.0) - .map_err(|e| f(e.to_string())), - other => Err(Error::UnexpectedResponse(other)), - } - } } #[async_trait] @@ -469,271 +297,3 @@ fn get_id(req_json: &str) -> Result { Err(Error::MissingId) } } - -/// The TendermintWebsocketClient has a basic state machine for ensuring -/// at most one subscription at a time. These tests cover that it -/// works as intended. -/// -/// Furthermore, since a client can handle a subscription and a -/// simple request simultaneously, we must test that the correct -/// responses are give for each of the corresponding requests -#[cfg(all(test, feature = "ABCI"))] -mod test_tendermint_websocket_client { - use std::time::Duration; - - use namada::types::transaction::hash_tx as hash_tx_bytes; - use serde::{Deserialize, Serialize}; - #[cfg(feature = "ABCI")] - use tendermint_rpc_abci::endpoint::abci_info::AbciInfo; - #[cfg(feature = "ABCI")] - use tendermint_rpc_abci::query::{EventType, Query}; - #[cfg(feature = "ABCI")] - use tendermint_rpc_abci::Client; - #[cfg(feature = "ABCI")] - use tendermint_stable::abci::transaction; - use websocket::sync::Server; - use websocket::{Message, OwnedMessage}; - - use crate::client::tendermint_websocket_client::{ - TendermintWebsocketClient, WebSocketAddress, - }; - - #[derive(Debug, Deserialize, Serialize)] - #[serde(rename_all = "snake_case")] - pub enum ReqType { - Subscribe, - Unsubscribe, - AbciInfo, - } - - #[derive(Debug, Deserialize, Serialize)] - pub struct RpcRequest { - pub jsonrpc: String, - pub id: String, - pub method: ReqType, - pub params: Option>, - } - - fn address() -> WebSocketAddress { - WebSocketAddress { - host: "localhost".into(), - port: 26657, - } - } - - #[derive(Default)] - struct Handle { - subscription_id: Option, - } - - impl Handle { - /// Mocks responses to queries. Fairly arbitrary with just enough - /// variety to test the TendermintWebsocketClient state machine and - /// message synchronization - fn handle(&mut self, msg: String) -> Vec { - let id = super::get_id(&msg).unwrap(); - let request: RpcRequest = serde_json::from_str(&msg).unwrap(); - match request.method { - ReqType::Unsubscribe => { - self.subscription_id = None; - vec![format!( - r#"{{"jsonrpc": "2.0", "id": {}, "error": "error"}}"#, - id - )] - } - ReqType::Subscribe => { - self.subscription_id = Some(id); - let id = self.subscription_id.as_ref().unwrap(); - if request.params.unwrap()[0] - == Query::from(EventType::NewBlock).to_string() - { - vec![format!( - r#"{{"jsonrpc": "2.0", "id": {}, "error": "error"}}"#, - id - )] - } else { - vec![format!( - r#"{{"jsonrpc": "2.0", "id": {}, "result": {{}}}}"#, - id - )] - } - } - ReqType::AbciInfo => { - // Mock a subscription result returning on the wire before - // the simple request result - let info = AbciInfo { - last_block_app_hash: transaction::Hash::new( - hash_tx_bytes("Testing".as_bytes()).0, - ) - .as_ref() - .into(), - ..AbciInfo::default() - }; - let resp = serde_json::to_string(&info).unwrap(); - if let Some(prev_id) = self.subscription_id.take() { - vec![ - format!( - r#"{{"jsonrpc": "2.0", "id": {}, "result": {{"subscription": "result!"}}}}"#, - prev_id - ), - format!( - r#"{{"jsonrpc": "2.0", "id": {}, "result": {{"response": {}}}}}"#, - id, resp - ), - ] - } else { - vec![format!( - r#"{{"jsonrpc": "2.0", "id": {}, "result": {{"response": {}}}}}"#, - id, resp - )] - } - } - } - } - } - - /// A mock tendermint node. This is just a basic websocket server - /// TODO: When the thread drops from scope, we may get an ignorable - /// panic as we did not shut the loop down. But we should. - fn start() { - let node = Server::bind("localhost:26657").unwrap(); - for connection in node.filter_map(Result::ok) { - std::thread::spawn(move || { - let mut handler = Handle::default(); - let mut client = connection.accept().unwrap(); - loop { - for resp in match client.recv_message().unwrap() { - OwnedMessage::Text(msg) => handler.handle(msg), - _ => panic!("Unexpected request"), - } { - let msg = Message::text(resp); - let _ = client.send_message(&msg); - } - } - }); - } - } - - /// Test that we cannot subscribe to a new event - /// if we have an active subscription - #[test] - fn test_subscribe_twice() { - std::thread::spawn(start); - // need to make sure that the mock tendermint node has time to boot up - std::thread::sleep(std::time::Duration::from_secs(1)); - let mut rpc_client = TendermintWebsocketClient::open( - address(), - Some(Duration::new(10, 0)), - ) - .expect("Client could not start"); - // Check that subscription was successful - rpc_client.subscribe(Query::from(EventType::Tx)).unwrap(); - assert_eq!( - rpc_client.subscribed.as_ref().expect("Test failed").query, - Query::from(EventType::Tx) - ); - // Check that we cannot subscribe while we still have an active - // subscription - assert!(rpc_client.subscribe(Query::from(EventType::Tx)).is_err()); - } - - /// Test that even if there is an error on the protocol layer, - /// the client still unsubscribes and returns control - #[test] - fn test_unsubscribe_even_on_protocol_error() { - std::thread::spawn(start); - // need to make sure that the mock tendermint node has time to boot up - std::thread::sleep(std::time::Duration::from_secs(1)); - let mut rpc_client = TendermintWebsocketClient::open( - address(), - Some(Duration::new(10, 0)), - ) - .expect("Client could not start"); - // Check that subscription was successful - rpc_client.subscribe(Query::from(EventType::Tx)).unwrap(); - assert_eq!( - rpc_client.subscribed.as_ref().expect("Test failed").query, - Query::from(EventType::Tx) - ); - // Check that unsubscribe was successful even though it returned an - // error - assert!(rpc_client.unsubscribe().is_err()); - assert!(rpc_client.subscribed.is_none()); - } - - /// Test that if we unsubscribe from an event, we can - /// reuse the client to subscribe to a new event - #[test] - fn test_subscribe_after_unsubscribe() { - std::thread::spawn(start); - // need to make sure that the mock tendermint node has time to boot up - std::thread::sleep(std::time::Duration::from_secs(1)); - let mut rpc_client = TendermintWebsocketClient::open( - address(), - Some(Duration::new(10, 0)), - ) - .expect("Client could not start"); - // Check that subscription was successful - rpc_client.subscribe(Query::from(EventType::Tx)).unwrap(); - assert_eq!( - rpc_client.subscribed.as_ref().expect("Test failed").query, - Query::from(EventType::Tx) - ); - // Check that unsubscribe was successful - let _ = rpc_client.unsubscribe(); - assert!(rpc_client.subscribed.as_ref().is_none()); - // Check that we can now subscribe to new event - rpc_client.subscribe(Query::from(EventType::Tx)).unwrap(); - assert_eq!( - rpc_client.subscribed.expect("Test failed").query, - Query::from(EventType::Tx) - ); - } - - /// In this test we first subscribe to an event and then - /// make a simple request. - /// - /// The mock node is set up so that while the request is waiting - /// for its response, it receives the response for the subscription. - /// - /// This test checks that methods correctly return the correct - /// responses. - #[test] - fn test_subscription_returns_before_request_handled() { - std::thread::spawn(start); - // need to make sure that the mock tendermint node has time to boot up - std::thread::sleep(std::time::Duration::from_secs(1)); - let mut rpc_client = TendermintWebsocketClient::open( - address(), - Some(Duration::new(10, 0)), - ) - .expect("Client could not start"); - // Check that subscription was successful - rpc_client.subscribe(Query::from(EventType::Tx)).unwrap(); - assert_eq!( - rpc_client.subscribed.as_ref().expect("Test failed").query, - Query::from(EventType::Tx) - ); - // Check that there are no pending subscription responses - assert!(rpc_client.received_responses.lock().unwrap().is_empty()); - // If the wrong response is returned, json deserialization will fail the - // test - let _ = - tokio_test::block_on(rpc_client.abci_info()).expect("Test failed"); - // Check that we received the subscription response and it has been - // stored - assert!( - rpc_client - .received_responses - .lock() - .unwrap() - .contains_key(&rpc_client.subscribed.as_ref().unwrap().id) - ); - - // check that we receive the expected response to the subscription - let response = rpc_client.receive_response().expect("Test failed"); - assert_eq!(response.to_string(), r#"{"subscription":"result!"}"#); - // Check that there are no pending subscription responses - assert!(rpc_client.received_responses.lock().unwrap().is_empty()); - } -} diff --git a/apps/src/lib/client/tm_jsonrpc_client.rs b/apps/src/lib/client/tm_jsonrpc_client.rs index 12bd6d45b3..7372012ff5 100644 --- a/apps/src/lib/client/tm_jsonrpc_client.rs +++ b/apps/src/lib/client/tm_jsonrpc_client.rs @@ -1,225 +1,223 @@ -#[cfg(not(feature = "ABCI"))] -mod tm_jsonrpc { - use std::convert::TryFrom; - use std::fmt::{Display, Formatter}; - use std::ops::{Deref, DerefMut}; +use std::convert::TryFrom; +use std::fmt::{Display, Formatter}; +use std::ops::{Deref, DerefMut}; - use curl::easy::{Easy2, Handler, WriteError}; - use serde::{Deserialize, Serialize}; - use tendermint_config::net::Address as TendermintAddress; - use tendermint_rpc::query::Query; +use curl::easy::{Easy2, Handler, WriteError}; +use serde::{Deserialize, Serialize}; +use tendermint_config::net::Address as TendermintAddress; +use tendermint_rpc::query::Query; - use crate::client::tendermint_rpc_types::{ - parse, Error, EventParams, EventReply, TxResponse, - }; +use crate::client::tendermint_rpc_types::{ + parse, Error, EventParams, EventReply, TxResponse, +}; - /// Maximum number of times we try to send a curl request - const MAX_SEND_ATTEMPTS: u8 = 10; - /// Number of events we request from the events log - const NUM_EVENTS: u64 = 10; +/// Maximum number of times we try to send a curl request +const MAX_SEND_ATTEMPTS: u8 = 10; +/// Number of events we request from the events log +const NUM_EVENTS: u64 = 10; - pub struct JsonRpcAddress<'a> { - host: &'a str, - port: u16, - } +pub struct JsonRpcAddress<'a> { + host: &'a str, + port: u16, +} - impl<'a> TryFrom<&'a TendermintAddress> for JsonRpcAddress<'a> { - type Error = Error; +impl<'a> TryFrom<&'a TendermintAddress> for JsonRpcAddress<'a> { + type Error = Error; - fn try_from(value: &'a TendermintAddress) -> Result { - match value { - TendermintAddress::Tcp { host, port, .. } => Ok(Self { - host: host.as_str(), - port: *port, - }), - _ => Err(Error::Address(value.to_string())), - } + fn try_from(value: &'a TendermintAddress) -> Result { + match value { + TendermintAddress::Tcp { host, port, .. } => Ok(Self { + host: host.as_str(), + port: *port, + }), + _ => Err(Error::Address(value.to_string())), } } +} - impl<'a> Display for JsonRpcAddress<'a> { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{}:{}", self.host, self.port) - } +impl<'a> Display for JsonRpcAddress<'a> { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{}:{}", self.host, self.port) } +} - /// The body of a json rpc request - #[derive(Serialize)] - pub struct Request { - /// Method name - pub method: String, - /// parameters to give the method - params: EventParams, - /// ID of the request - id: u8, - } +/// The body of a json rpc request +#[derive(Serialize)] +pub struct Request { + /// Method name + pub method: String, + /// parameters to give the method + params: EventParams, + /// ID of the request + id: u8, +} - impl From for Request { - fn from(params: EventParams) -> Self { - Request { - method: "events".into(), - params, - id: 1, - } +impl From for Request { + fn from(params: EventParams) -> Self { + Request { + method: "events".into(), + params, + id: 1, } } +} - /// The response we get back from Tendermint - #[derive(Serialize, Deserialize)] - pub struct Response { - /// JSON-RPC version - jsonrpc: String, - /// Identifier included in request - id: u8, - /// Results of request (if successful) - result: Option, - /// Error message if unsuccessful - error: Option, - } +/// The response we get back from Tendermint +#[derive(Serialize, Deserialize)] +pub struct Response { + /// JSON-RPC version + jsonrpc: String, + /// Identifier included in request + id: u8, + /// Results of request (if successful) + result: Option, + /// Error message if unsuccessful + error: Option, +} - impl Response { - /// Convert the response into a result type - pub fn into_result(self) -> Result { - if let Some(e) = self.error { - Err(Error::Rpc(e)) - } else if let Some(result) = self.result { - Ok(result) - } else { - Err(Error::MalformedJson) - } +impl Response { + /// Convert the response into a result type + pub fn into_result(self) -> Result { + if let Some(e) = self.error { + Err(Error::Rpc(e)) + } else if let Some(result) = self.result { + Ok(result) + } else { + Err(Error::MalformedJson) } } +} - /// Holds bytes returned in response to curl request - #[derive(Default)] - pub struct Collector(Vec); +/// Holds bytes returned in response to curl request +#[derive(Default)] +pub struct Collector(Vec); - impl Handler for Collector { - fn write(&mut self, data: &[u8]) -> Result { - self.0.extend_from_slice(data); - Ok(data.len()) - } +impl Handler for Collector { + fn write(&mut self, data: &[u8]) -> Result { + self.0.extend_from_slice(data); + Ok(data.len()) } +} - /// The RPC client - pub struct Client<'a> { - /// The actual curl client - inner: Easy2, - /// Url to send requests to - url: &'a str, - /// The request body - request: Request, - /// The hash of the tx whose corresponding event is being searched for. - hash: &'a str, - } +/// The RPC client +pub struct Client<'a> { + /// The actual curl client + inner: Easy2, + /// Url to send requests to + url: &'a str, + /// The request body + request: Request, + /// The hash of the tx whose corresponding event is being searched for. + hash: &'a str, +} - impl<'a> Deref for Client<'a> { - type Target = Easy2; +impl<'a> Deref for Client<'a> { + type Target = Easy2; - fn deref(&self) -> &Self::Target { - &self.inner - } + fn deref(&self) -> &Self::Target { + &self.inner } +} - impl<'a> DerefMut for Client<'a> { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.inner - } +impl<'a> DerefMut for Client<'a> { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner } +} - impl<'a> Client<'a> { - /// Create a new client - pub fn new(url: &'a str, request: Request, hash: &'a str) -> Self { - let mut client = Self { - inner: Easy2::new(Collector::default()), - url, - request, - hash, - }; - client.initialize(); - client - } +impl<'a> Client<'a> { + /// Create a new client + pub fn new(url: &'a str, request: Request, hash: &'a str) -> Self { + let mut client = Self { + inner: Easy2::new(Collector::default()), + url, + request, + hash, + }; + client.initialize(); + client + } - /// Send a request to Tendermint - /// - /// Takes the 10 newest block header events and searches for - /// the relevant event among them. - pub fn send(&mut self) -> Result { - // send off the request - // this loop is here because if commit timeouts - // become too long, sometimes we get back empty responses. - for attempt in 0..MAX_SEND_ATTEMPTS { - match self.perform() { - Ok(()) => break, - Err(err) => { - tracing::debug!(?attempt, response = ?err, "attempting request") - } + /// Send a request to Tendermint + /// + /// Takes the 10 newest block header events and searches for + /// the relevant event among them. + pub fn send(&mut self) -> Result { + // send off the request + // this loop is here because if commit timeouts + // become too long, sometimes we get back empty responses. + for attempt in 0..MAX_SEND_ATTEMPTS { + match self.perform() { + Ok(()) => break, + Err(err) => { + tracing::debug!(?attempt, response = ?err, "attempting request") } } - if self.get_ref().0.is_empty() { - return Err(Error::Send); - } - - // deserialize response - let response: Response = - serde_json::from_slice(self.get_ref().0.as_slice()) - .map_err(Error::Deserialize)?; - let response = response.into_result()?; - // search for the event in the response and return - // it if found. Else request the next chunk of results - parse(response, self.hash) - .ok_or_else(|| Error::NotFound(self.hash.to_string())) } - - /// Initialize the curl client from the fields of `Client` - fn initialize(&mut self) { - self.inner.reset(); - let url = self.url; - self.url(url).unwrap(); - self.post(true).unwrap(); - - // craft the body of the request - let request_body = serde_json::to_string(&self.request).unwrap(); - self.post_field_size(request_body.as_bytes().len() as u64) - .unwrap(); - // update the request and serialize to bytes - let data = serde_json::to_string(&self.request).unwrap(); - let data = data.as_bytes(); - self.post_fields_copy(data).unwrap(); + if self.get_ref().0.is_empty() { + return Err(Error::Send); } + + // deserialize response + let response: Response = + serde_json::from_slice(self.get_ref().0.as_slice()) + .map_err(Error::Deserialize)?; + let response = response.into_result()?; + // search for the event in the response and return + // it if found. Else request the next chunk of results + parse(response, self.hash) + .ok_or_else(|| Error::NotFound(self.hash.to_string())) } - /// Given a query looking for a particular Anoma event, - /// query the Tendermint's jsonrpc endpoint for the events - /// log. Returns the appropriate event if found in the log. - pub async fn fetch_event( - address: &str, - filter: Query, - tx_hash: &str, - ) -> Result { + /// Initialize the curl client from the fields of `Client` + fn initialize(&mut self) { + self.inner.reset(); + let url = self.url; + self.url(url).unwrap(); + self.post(true).unwrap(); + // craft the body of the request - let request = Request::from(EventParams::new( - filter, - NUM_EVENTS, - std::time::Duration::from_secs(60), - )); - // construct a curl client - let mut client = Client::new(address, request, tx_hash); - // perform the request - client.send() + let request_body = serde_json::to_string(&self.request).unwrap(); + self.post_field_size(request_body.as_bytes().len() as u64) + .unwrap(); + // update the request and serialize to bytes + let data = serde_json::to_string(&self.request).unwrap(); + let data = data.as_bytes(); + self.post_fields_copy(data).unwrap(); } +} - #[cfg(test)] - mod test_rpc_types { - use serde_json::json; +/// Given a query looking for a particular Anoma event, +/// query the Tendermint's jsonrpc endpoint for the events +/// log. Returns the appropriate event if found in the log. +pub async fn fetch_event( + address: &str, + filter: Query, + tx_hash: &str, +) -> Result { + // craft the body of the request + let request = Request::from(EventParams::new( + filter, + NUM_EVENTS, + std::time::Duration::from_secs(60), + )); + // construct a curl client + let mut client = Client::new(address, request, tx_hash); + // perform the request + client.send() +} - use super::*; - use crate::client::tendermint_rpc_types::{EventData, EventItem}; +#[cfg(test)] +mod test_rpc_types { + use serde_json::json; - /// Test that we correctly parse the response from Tendermint - #[test] - fn test_parse_response() { - let resp = r#" + use super::*; + use crate::client::tendermint_rpc_types::{EventData, EventItem}; + + /// Test that we correctly parse the response from Tendermint + #[test] + fn test_parse_response() { + let resp = r#" { "jsonrpc":"2.0", "id":1, @@ -241,27 +239,23 @@ mod tm_jsonrpc { "newest":"16f1b066717b4261-0060" } }"#; - let response: Response = - serde_json::from_str(resp).expect("Test failed"); - let items = response.into_result().expect("Test failed").items; - assert_eq!( - items, - vec![EventItem { - cursor: String::from("16f1b066717b4261-0060").into(), - event: "NewRoundStep".to_string(), - data: EventData { - r#type: "tendermint/event/RoundState".to_string(), - value: json!({ - "height":"17416", - "round":0, - "step":"RoundStepCommit" - }), - } - }] - ) - } + let response: Response = + serde_json::from_str(resp).expect("Test failed"); + let items = response.into_result().expect("Test failed").items; + assert_eq!( + items, + vec![EventItem { + cursor: String::from("16f1b066717b4261-0060").into(), + event: "NewRoundStep".to_string(), + data: EventData { + r#type: "tendermint/event/RoundState".to_string(), + value: json!({ + "height":"17416", + "round":0, + "step":"RoundStepCommit" + }), + } + }] + ) } } - -#[cfg(not(feature = "ABCI"))] -pub use tm_jsonrpc::*; diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index 5335f7d450..6f1fd96707 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -25,38 +25,22 @@ use namada::types::transaction::nft::{CreateNft, MintNft}; use namada::types::transaction::{pos, InitAccount, InitValidator, UpdateVp}; use namada::types::{address, token}; use namada::{ledger, vm}; -#[cfg(not(feature = "ABCI"))] use tendermint_config::net::Address as TendermintAddress; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::net::Address as TendermintAddress; -#[cfg(not(feature = "ABCI"))] use tendermint_rpc::endpoint::broadcast::tx_sync::Response; -#[cfg(not(feature = "ABCI"))] use tendermint_rpc::query::{EventType, Query}; -#[cfg(not(feature = "ABCI"))] use tendermint_rpc::{Client, HttpClient}; -#[cfg(feature = "ABCI")] -use tendermint_rpc_abci::endpoint::broadcast::tx_sync::Response; -#[cfg(feature = "ABCI")] -use tendermint_rpc_abci::query::{EventType, Query}; -#[cfg(feature = "ABCI")] -use tendermint_rpc_abci::{Client, HttpClient}; use super::rpc; use crate::cli::context::WalletAddress; use crate::cli::{args, safe_exit, Context}; use crate::client::signing::{find_keypair, sign_tx}; -#[cfg(not(feature = "ABCI"))] -use crate::client::tendermint_rpc_types::Error; -use crate::client::tendermint_rpc_types::{TxBroadcastData, TxResponse}; +use crate::client::tendermint_rpc_types::{Error, TxBroadcastData, TxResponse}; use crate::client::tendermint_websocket_client::{ Error as WsError, TendermintWebsocketClient, WebSocketAddress, }; -#[cfg(not(feature = "ABCI"))] use crate::client::tm_jsonrpc_client::{fetch_event, JsonRpcAddress}; use crate::node::ledger::tendermint_node; -#[cfg(not(feature = "ABCI"))] const ACCEPTED_QUERY_KEY: &str = "accepted.hash"; const APPLIED_QUERY_KEY: &str = "applied.hash"; const TX_INIT_ACCOUNT_WASM: &str = "tx_init_account.wasm"; @@ -1149,13 +1133,10 @@ pub async fn broadcast_tx( println!("Transaction added to mempool: {:?}", response); // Print the transaction identifiers to enable the extraction of // acceptance/application results later - #[cfg(not(feature = "ABCI"))] { println!("Wrapper transaction hash: {:?}", wrapper_tx_hash); println!("Inner transaction hash: {:?}", _decrypted_tx_hash); } - #[cfg(feature = "ABCI")] - println!("Transaction hash: {:?}", wrapper_tx_hash); Ok(response) } else { Err(WsError::Response(response.log.to_string())) @@ -1170,7 +1151,6 @@ pub async fn broadcast_tx( /// 3. The decrypted payload of the tx has been included on the blockchain. /// /// In the case of errors in any of those stages, an error message is returned -#[cfg(not(feature = "ABCI"))] pub async fn submit_tx( address: TendermintAddress, to_broadcast: TxBroadcastData, @@ -1192,7 +1172,7 @@ pub async fn submit_tx( let wrapper_query = Query::from(EventType::NewBlockHeader) .and_eq(ACCEPTED_QUERY_KEY, wrapper_hash.as_str()); let tx_query = Query::from(EventType::NewBlockHeader) - .and_eq(APPLIED_QUERY_KEY, decrypted_hash.as_ref().unwrap().as_str()); + .and_eq(APPLIED_QUERY_KEY, decrypted_hash.as_str()); // broadcast the tx if let Err(err) = broadcast_tx(address, &to_broadcast).await { @@ -1212,12 +1192,8 @@ pub async fn submit_tx( // and applied if response.code == 0.to_string() { // get the event for the inner tx - let response = fetch_event( - &url, - tx_query, - decrypted_hash.as_ref().unwrap().as_str(), - ) - .await?; + let response = + fetch_event(&url, tx_query, decrypted_hash.as_str()).await?; println!( "Transaction applied with result: {}", serde_json::to_string_pretty(&response).unwrap() @@ -1231,69 +1207,3 @@ pub async fn submit_tx( Ok(response) } } - -/// Broadcast a transaction to be included in the blockchain. -/// -/// Checks that -/// 1. The tx has been successfully included into the mempool of a validator -/// 2. The tx with encrypted payload has been included on the blockchain -/// 3. The decrypted payload of the tx has been included on the blockchain. -/// -/// In the case of errors in any of those stages, an error message is returned -#[cfg(feature = "ABCI")] -pub async fn submit_tx( - address: TendermintAddress, - to_broadcast: TxBroadcastData, -) -> Result { - let (_, wrapper_hash, _decrypted_hash) = match &to_broadcast { - TxBroadcastData::Wrapper { - tx, - wrapper_hash, - decrypted_hash, - } => (tx, wrapper_hash, decrypted_hash), - _ => panic!("Cannot broadcast a dry-run transaction"), - }; - - let websocket_timeout = - if let Ok(val) = env::var(ENV_VAR_ANOMA_TENDERMINT_WEBSOCKET_TIMEOUT) { - if let Ok(timeout) = val.parse::() { - Duration::new(timeout, 0) - } else { - Duration::new(300, 0) - } - } else { - Duration::new(300, 0) - }; - - let mut wrapper_tx_subscription = TendermintWebsocketClient::open( - WebSocketAddress::try_from(address.clone())?, - Some(websocket_timeout), - )?; - - // It is better to subscribe to the transaction before it is broadcast - // - // Note that the `APPLIED_QUERY_KEY` key comes from a custom event - // created by the shell - let query = Query::from(EventType::NewBlock) - .and_eq(APPLIED_QUERY_KEY, wrapper_hash.as_str()); - wrapper_tx_subscription.subscribe(query)?; - - // Broadcast the supplied transaction - broadcast_tx(address, &to_broadcast).await?; - - let parsed = { - let parsed = TxResponse::find_tx( - wrapper_tx_subscription.receive_response()?, - wrapper_hash, - ); - println!( - "Transaction applied with result: {}", - serde_json::to_string_pretty(&parsed).unwrap() - ); - Ok(parsed) - }; - - wrapper_tx_subscription.unsubscribe()?; - wrapper_tx_subscription.close(); - parsed -} diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index d16e80e8d3..c377648b65 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -18,14 +18,8 @@ use rand::prelude::ThreadRng; use rand::thread_rng; use serde_json::json; use sha2::{Digest, Sha256}; -#[cfg(not(feature = "ABCI"))] use tendermint::node::Id as TendermintNodeId; -#[cfg(not(feature = "ABCI"))] use tendermint_config::net::Address as TendermintAddress; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::net::Address as TendermintAddress; -#[cfg(feature = "ABCI")] -use tendermint_stable::node::Id as TendermintNodeId; use crate::cli::context::ENV_VAR_WASM_DIR; use crate::cli::{self, args}; diff --git a/apps/src/lib/config/mod.rs b/apps/src/lib/config/mod.rs index b81430fc3b..987077d5cd 100644 --- a/apps/src/lib/config/mod.rs +++ b/apps/src/lib/config/mod.rs @@ -19,14 +19,8 @@ use namada::types::chain::ChainId; use namada::types::time::Rfc3339String; use regex::Regex; use serde::{de, Deserialize, Serialize}; -#[cfg(not(feature = "ABCI"))] use tendermint::Timeout; -#[cfg(not(feature = "ABCI"))] use tendermint_config::net::Address as TendermintAddress; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::net::Address as TendermintAddress; -#[cfg(feature = "ABCI")] -use tendermint_stable::Timeout; use thiserror::Error; use crate::cli; diff --git a/apps/src/lib/node/ledger/broadcaster.rs b/apps/src/lib/node/ledger/broadcaster.rs index 662291b1d5..94aec1a00c 100644 --- a/apps/src/lib/node/ledger/broadcaster.rs +++ b/apps/src/lib/node/ledger/broadcaster.rs @@ -1,7 +1,4 @@ -#[cfg(not(feature = "ABCI"))] use tendermint_rpc::{Client, HttpClient}; -#[cfg(feature = "ABCI")] -use tendermint_rpc_abci::{Client, HttpClient}; use tokio::sync::mpsc::UnboundedReceiver; /// A service for broadcasting txs via an HTTP client. diff --git a/apps/src/lib/node/ledger/events.rs b/apps/src/lib/node/ledger/events.rs index 9751d3b8b6..493c4855da 100644 --- a/apps/src/lib/node/ledger/events.rs +++ b/apps/src/lib/node/ledger/events.rs @@ -7,10 +7,7 @@ use borsh::BorshSerialize; use namada::ledger::governance::utils::ProposalEvent; use namada::types::ibc::IbcEvent; use namada::types::transaction::{hash_tx, TxType}; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::EventAttribute; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::abci::EventAttribute; use thiserror::Error; /// Indicates if an event is emitted do to @@ -43,7 +40,6 @@ pub enum EventType { Proposal, } -#[cfg(not(feature = "ABCI"))] impl Display for EventType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -56,19 +52,6 @@ impl Display for EventType { } } -#[cfg(feature = "ABCI")] -impl Display for EventType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - EventType::Accepted => write!(f, "applied"), - EventType::Applied => write!(f, "applied"), - EventType::Ibc(t) => write!(f, "{}", t), - EventType::Proposal => write!(f, "proposal"), - }?; - Ok(()) - } -} - impl Event { /// Creates a new event with the hash and height of the transaction /// already filled in @@ -80,16 +63,12 @@ impl Event { level: EventLevel::Tx, attributes: HashMap::new(), }; - event["hash"] = if !cfg!(feature = "ABCI") { - hash_tx( - &wrapper - .try_to_vec() - .expect("Serializing wrapper should not fail"), - ) - .to_string() - } else { - wrapper.tx_hash.to_string() - }; + event["hash"] = hash_tx( + &wrapper + .try_to_vec() + .expect("Serializing wrapper should not fail"), + ) + .to_string(); event } TxType::Decrypted(decrypted) => { @@ -170,7 +149,6 @@ impl From for Event { } } -#[cfg(not(feature = "ABCI"))] /// Convert our custom event into the necessary tendermint proto type impl From for tendermint_proto::abci::Event { fn from(event: Event) -> Self { @@ -189,25 +167,6 @@ impl From for tendermint_proto::abci::Event { } } -#[cfg(feature = "ABCI")] -/// Convert our custom event into the necessary tendermint proto type -impl From for tendermint_proto_abci::abci::Event { - fn from(event: Event) -> Self { - Self { - r#type: event.event_type.to_string(), - attributes: event - .attributes - .into_iter() - .map(|(key, value)| EventAttribute { - key: key.into_bytes(), - value: value.into_bytes(), - index: true, - }) - .collect(), - } - } -} - /// A thin wrapper around a HashMap for parsing event JSONs /// returned in tendermint subscription responses. #[derive(Debug)] diff --git a/apps/src/lib/node/ledger/mod.rs b/apps/src/lib/node/ledger/mod.rs index 03f5aa36c7..e84674b059 100644 --- a/apps/src/lib/node/ledger/mod.rs +++ b/apps/src/lib/node/ledger/mod.rs @@ -18,15 +18,9 @@ use namada::ledger::governance::storage as gov_storage; use namada::types::storage::Key; use once_cell::unsync::Lazy; use sysinfo::{RefreshKind, System, SystemExt}; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::CheckTxType; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::abci::CheckTxType; use tower::ServiceBuilder; -#[cfg(not(feature = "ABCI"))] use tower_abci::{response, split, Server}; -#[cfg(feature = "ABCI")] -use tower_abci_old::{response, split, Server}; use self::shims::abcipp_shim::AbciService; use crate::config::utils::num_of_threads; @@ -96,30 +90,21 @@ impl Shell { } Request::Info(_) => Ok(Response::Info(self.last_state())), Request::Query(query) => Ok(Response::Query(self.query(query))), - #[cfg(not(feature = "ABCI"))] Request::PrepareProposal(block) => { Ok(Response::PrepareProposal(self.prepare_proposal(block))) } Request::VerifyHeader(_req) => { Ok(Response::VerifyHeader(self.verify_header(_req))) } - #[cfg(not(feature = "ABCI"))] Request::ProcessProposal(block) => { Ok(Response::ProcessProposal(self.process_proposal(block))) } - #[cfg(feature = "ABCI")] - Request::DeliverTx(deliver_tx) => Ok(Response::DeliverTx( - self.process_and_decode_proposal(deliver_tx), - )), - #[cfg(not(feature = "ABCI"))] Request::RevertProposal(_req) => { Ok(Response::RevertProposal(self.revert_proposal(_req))) } - #[cfg(not(feature = "ABCI"))] Request::ExtendVote(_req) => { Ok(Response::ExtendVote(self.extend_vote(_req))) } - #[cfg(not(feature = "ABCI"))] Request::VerifyVoteExtension(_req) => Ok( Response::VerifyVoteExtension(self.verify_vote_extension(_req)), ), diff --git a/apps/src/lib/node/ledger/rpc.rs b/apps/src/lib/node/ledger/rpc.rs index 3836a11f97..ce3cbd592d 100644 --- a/apps/src/lib/node/ledger/rpc.rs +++ b/apps/src/lib/node/ledger/rpc.rs @@ -5,10 +5,7 @@ use std::str::FromStr; use namada::types::address::Address; use namada::types::storage; -#[cfg(not(feature = "ABCI"))] use tendermint::abci::Path as AbciPath; -#[cfg(feature = "ABCI")] -use tendermint_stable::abci::Path as AbciPath; use thiserror::Error; /// RPC query path diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index c7ba3177b4..6afba892e1 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -10,14 +10,8 @@ use namada::ledger::treasury::ADDRESS as treasury_address; use namada::types::address::{xan as m1t, Address}; use namada::types::governance::TallyResult; use namada::types::storage::{BlockHash, Epoch, Header}; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::Misbehavior as Evidence; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::crypto::PublicKey as TendermintPublicKey; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::abci::Evidence; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::crypto::PublicKey as TendermintPublicKey; use super::*; use crate::node::ledger::events::EventType; @@ -302,16 +296,12 @@ where let mut tx_event = match &tx_type { TxType::Wrapper(_wrapper) => { - if !cfg!(feature = "ABCI") { - self.storage.tx_queue.push(_wrapper.clone()); - } + self.storage.tx_queue.push(_wrapper.clone()); Event::new_tx_event(&tx_type, height.0) } TxType::Decrypted(inner) => { // We remove the corresponding wrapper tx from the queue - if !cfg!(feature = "ABCI") { - self.storage.tx_queue.pop(); - } + self.storage.tx_queue.pop(); let mut event = Event::new_tx_event(&tx_type, height.0); if let DecryptedTx::Undecryptable(_) = inner { event["log"] = @@ -525,7 +515,6 @@ mod test_finalize_block { FinalizeBlock, ProcessedTx, }; - #[cfg(not(feature = "ABCI"))] /// Check that if a wrapper tx was rejected by [`process_proposal`], /// check that the correct event is returned. Check that it does /// not appear in the queue of txs to be decrypted @@ -600,62 +589,6 @@ mod test_finalize_block { assert_eq!(counter, 3); } - #[cfg(feature = "ABCI")] - /// Check that if a wrapper tx was rejected by [`process_proposal`], - /// check that the correct event is returned. - #[test] - fn test_process_proposal_rejected_wrapper_tx() { - let (mut shell, _) = setup(); - let keypair = gen_keypair(); - let mut processed_txs = vec![]; - // create some wrapper txs - for i in 1..5 { - let raw_tx = Tx::new( - "wasm_code".as_bytes().to_owned(), - Some(format!("transaction data: {}", i).as_bytes().to_owned()), - ); - let wrapper = WrapperTx::new( - Fee { - amount: i.into(), - token: xan(), - }, - &keypair, - Epoch(0), - 0.into(), - raw_tx.clone(), - Default::default(), - ); - let tx = wrapper.sign(&keypair).expect("Test failed"); - if i > 1 { - processed_txs.push(ProcessedTx { - tx: tx.to_bytes(), - result: TxResult { - code: u32::try_from(i.rem_euclid(2)) - .expect("Test failed"), - info: "".into(), - }, - }); - } - } - - // check that the correct events were created - for (index, event) in shell - .finalize_block(FinalizeBlock { - txs: processed_txs.clone(), - ..Default::default() - }) - .expect("Test failed") - .iter() - .enumerate() - { - assert_eq!(event.event_type.to_string(), String::from("applied")); - let code = - event.attributes.get("code").expect("Test failed").clone(); - assert_eq!(code, index.rem_euclid(2).to_string()); - } - } - - #[cfg(not(feature = "ABCI"))] /// Check that if a decrypted tx was rejected by [`process_proposal`], /// check that the correct event is returned. Check that it is still /// removed from the queue of txs to be included in the next block @@ -706,43 +639,6 @@ mod test_finalize_block { assert!(shell.next_wrapper().is_none()); } - #[cfg(feature = "ABCI")] - /// Check that if a decrypted tx was rejected by [`process_proposal`], - /// check that the correct event is returned. - #[test] - fn test_process_proposal_rejected_decrypted_tx() { - let (mut shell, _) = setup(); - let raw_tx = Tx::new( - "wasm_code".as_bytes().to_owned(), - Some(String::from("transaction data").as_bytes().to_owned()), - ); - let processed_tx = ProcessedTx { - tx: Tx::from(TxType::Decrypted(DecryptedTx::Decrypted(raw_tx))) - .to_bytes(), - result: TxResult { - code: ErrorCodes::InvalidTx.into(), - info: "".into(), - }, - }; - - // check that the decrypted tx was not applied - for event in shell - .finalize_block(FinalizeBlock { - txs: vec![processed_tx], - ..Default::default() - }) - .expect("Test failed") - { - assert_eq!(event.event_type.to_string(), String::from("applied")); - let code = - event.attributes.get("code").expect("Test failed").as_str(); - assert_eq!(code, String::from(ErrorCodes::InvalidTx).as_str()); - } - // check that the corresponding wrapper tx was removed from the queue - assert!(shell.next_wrapper().is_none()); - } - - #[cfg(not(feature = "ABCI"))] /// Test that if a tx is undecryptable, it is applied /// but the tx result contains the appropriate error code. #[test] @@ -799,63 +695,6 @@ mod test_finalize_block { assert!(shell.next_wrapper().is_none()); } - #[cfg(feature = "ABCI")] - /// Test that if a tx is undecryptable, it is applied - /// but the tx result contains the appropriate error code. - #[test] - fn test_undecryptable_returns_error_code() { - let (mut shell, _) = setup(); - - let keypair = crate::wallet::defaults::daewon_keypair(); - let pubkey = EncryptionKey::default(); - // not valid tx bytes - let tx = "garbage data".as_bytes().to_owned(); - let inner_tx = - namada::types::transaction::encrypted::EncryptedTx::encrypt( - &tx, pubkey, - ); - let wrapper = WrapperTx { - fee: Fee { - amount: 0.into(), - token: xan(), - }, - pk: keypair.ref_to(), - epoch: Epoch(0), - gas_limit: 0.into(), - inner_tx, - tx_hash: hash_tx(&tx), - }; - let processed_tx = ProcessedTx { - tx: Tx::from(TxType::Decrypted(DecryptedTx::Undecryptable( - wrapper, - ))) - .to_bytes(), - result: TxResult { - code: ErrorCodes::Ok.into(), - info: "".into(), - }, - }; - - // check that correct error message is returned - for event in shell - .finalize_block(FinalizeBlock { - txs: vec![processed_tx], - ..Default::default() - }) - .expect("Test failed") - { - assert_eq!(event.event_type.to_string(), String::from("applied")); - let code = - event.attributes.get("code").expect("Test failed").as_str(); - assert_eq!(code, String::from(ErrorCodes::Undecryptable).as_str()); - - let log = event.attributes.get("log").expect("Test failed").clone(); - assert!(log.contains("Transaction could not be decrypted.")) - } - // check that the corresponding wrapper tx was removed from the queue - assert!(shell.next_wrapper().is_none()); - } - /// Test that the wrapper txs are queued in the order they /// are received from the block. Tests that the previously /// decrypted txs are de-queued. @@ -946,17 +785,10 @@ mod test_finalize_block { { if index < 2 { // these should be accepted wrapper txs - if !cfg!(feature = "ABCI") { - assert_eq!( - event.event_type.to_string(), - String::from("accepted") - ); - } else { - assert_eq!( - event.event_type.to_string(), - String::from("applied") - ); - } + assert_eq!( + event.event_type.to_string(), + String::from("accepted") + ); let code = event.attributes.get("code").expect("Test failed").as_str(); assert_eq!(code, String::from(ErrorCodes::Ok).as_str()); @@ -972,21 +804,18 @@ mod test_finalize_block { } } - #[cfg(not(feature = "ABCI"))] - { - // check that the applied decrypted txs were dequeued and the - // accepted wrappers were enqueued in correct order - let mut txs = valid_txs.iter(); + // check that the applied decrypted txs were dequeued and the + // accepted wrappers were enqueued in correct order + let mut txs = valid_txs.iter(); - let mut counter = 0; - while let Some(wrapper) = shell.next_wrapper() { - assert_eq!( - wrapper.tx_hash, - txs.next().expect("Test failed").tx_hash - ); - counter += 1; - } - assert_eq!(counter, 2); + let mut counter = 0; + while let Some(wrapper) = shell.next_wrapper() { + assert_eq!( + wrapper.tx_hash, + txs.next().expect("Test failed").tx_hash + ); + counter += 1; } + assert_eq!(counter, 2); } } diff --git a/apps/src/lib/node/ledger/shell/init_chain.rs b/apps/src/lib/node/ledger/shell/init_chain.rs index 347c3bff53..a989338751 100644 --- a/apps/src/lib/node/ledger/shell/init_chain.rs +++ b/apps/src/lib/node/ledger/shell/init_chain.rs @@ -5,18 +5,9 @@ use std::hash::Hash; use namada::types::key::*; #[cfg(not(feature = "dev"))] use sha2::{Digest, Sha256}; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::abci; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::crypto::PublicKey as TendermintPublicKey; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::google::protobuf; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::abci; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::crypto::PublicKey as TendermintPublicKey; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::google::protobuf; use super::*; use crate::wasm_loader; diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index f72dcf615a..2d6134dbb1 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -7,7 +7,6 @@ //! More info in . mod finalize_block; mod init_chain; -#[cfg(not(feature = "ABCI"))] mod prepare_proposal; mod process_proposal; mod queries; @@ -45,29 +44,16 @@ use namada::vm::wasm::{TxCache, VpCache}; use namada::vm::WasmCacheRwAccess; use num_derive::{FromPrimitive, ToPrimitive}; use num_traits::{FromPrimitive, ToPrimitive}; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::response_verify_vote_extension::VerifyStatus; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::{ Misbehavior as Evidence, MisbehaviorType as EvidenceType, RequestPrepareProposal, ValidatorUpdate, }; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::crypto::public_key; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::types::ConsensusParams; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::abci::ConsensusParams; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::abci::{Evidence, EvidenceType, ValidatorUpdate}; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::crypto::public_key; use thiserror::Error; use tokio::sync::mpsc::UnboundedSender; -#[cfg(not(feature = "ABCI"))] use tower_abci::{request, response}; -#[cfg(feature = "ABCI")] -use tower_abci_old::{request, response}; use super::rpc; use crate::config::{genesis, TendermintMode}; @@ -331,17 +317,10 @@ where } /// Iterate lazily over the wrapper txs in order - #[cfg(not(feature = "ABCI"))] fn next_wrapper(&mut self) -> Option<&WrapperTx> { self.storage.tx_queue.lazy_next() } - /// Iterate lazily over the wrapper txs in order - #[cfg(feature = "ABCI")] - fn next_wrapper(&mut self) -> Option { - self.storage.tx_queue.pop() - } - /// If we reject the decrypted txs because they were out of /// order, reset the iterator. pub fn reset_tx_queue_iter(&mut self) { @@ -517,7 +496,6 @@ where } } - #[cfg(not(feature = "ABCI"))] /// INVARIANT: This method must be stateless. pub fn extend_vote( &self, @@ -526,7 +504,6 @@ where Default::default() } - #[cfg(not(feature = "ABCI"))] /// INVARIANT: This method must be stateless. pub fn verify_vote_extension( &self, @@ -621,7 +598,6 @@ where /// Lookup a validator's keypair for their established account from their /// wallet. If the node is not validator, this function returns None - #[cfg(not(feature = "ABCI"))] #[allow(dead_code)] fn get_account_keypair(&self) -> Option> { let wallet_path = &self.base_dir.join(self.chain_id.as_str()); @@ -672,14 +648,8 @@ mod test_utils { use namada::types::storage::{BlockHash, Epoch, Header}; use namada::types::transaction::Fee; use tempfile::tempdir; - #[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::{RequestInitChain, RequestProcessProposal}; - #[cfg(not(feature = "ABCI"))] use tendermint_proto::google::protobuf::Timestamp; - #[cfg(feature = "ABCI")] - use tendermint_proto_abci::abci::{RequestDeliverTx, RequestInitChain}; - #[cfg(feature = "ABCI")] - use tendermint_proto_abci::google::protobuf::Timestamp; use tokio::sync::mpsc::UnboundedReceiver; use super::*; @@ -786,39 +756,23 @@ mod test_utils { &mut self, req: ProcessProposal, ) -> std::result::Result, TestError> { - #[cfg(not(feature = "ABCI"))] - { - let resp = - self.shell.process_proposal(RequestProcessProposal { - txs: req.txs.clone(), - ..Default::default() - }); - let results = resp - .tx_results - .iter() - .zip(req.txs.into_iter()) - .map(|(res, tx_bytes)| ProcessedTx { - result: res.into(), - tx: tx_bytes, - }) - .collect(); - if resp.status != 1 { - Err(TestError::RejectProposal(results)) - } else { - Ok(results) - } - } - #[cfg(feature = "ABCI")] - { - Ok(req - .txs - .into_iter() - .map(|tx_bytes| { - self.process_and_decode_proposal(RequestDeliverTx { - tx: tx_bytes, - }) - }) - .collect()) + let resp = self.shell.process_proposal(RequestProcessProposal { + txs: req.txs.clone(), + ..Default::default() + }); + let results = resp + .tx_results + .iter() + .zip(req.txs.into_iter()) + .map(|(res, tx_bytes)| ProcessedTx { + result: res.into(), + tx: tx_bytes, + }) + .collect(); + if resp.status != 1 { + Err(TestError::RejectProposal(results)) + } else { + Ok(results) } } diff --git a/apps/src/lib/node/ledger/shell/prepare_proposal.rs b/apps/src/lib/node/ledger/shell/prepare_proposal.rs index c175a49a44..001d2eb6b3 100644 --- a/apps/src/lib/node/ledger/shell/prepare_proposal.rs +++ b/apps/src/lib/node/ledger/shell/prepare_proposal.rs @@ -1,221 +1,164 @@ //! Implementation of the [`PrepareProposal`] ABCI++ method for the Shell -#[cfg(not(feature = "ABCI"))] -mod prepare_block { - use tendermint_proto::abci::TxRecord; +use tendermint_proto::abci::TxRecord; - use super::super::*; - use crate::node::ledger::shims::abcipp_shim_types::shim::TxBytes; +use super::*; +use crate::node::ledger::shims::abcipp_shim_types::shim::TxBytes; - impl Shell - where - D: DB + for<'iter> DBIter<'iter> + Sync + 'static, - H: StorageHasher + Sync + 'static, - { - /// Begin a new block. - /// - /// We include half of the new wrapper txs given to us from the mempool - /// by tendermint. The rest of the block is filled with decryptions - /// of the wrapper txs from the previously committed block. - /// - /// INVARIANT: Any changes applied in this method must be reverted if - /// the proposal is rejected (unless we can simply overwrite - /// them in the next block). - pub fn prepare_proposal( - &mut self, - req: RequestPrepareProposal, - ) -> response::PrepareProposal { - // We can safely reset meter, because if the block is rejected, - // we'll reset again on the next proposal, until the - // proposal is accepted - self.gas_meter.reset(); - let txs = if let ShellMode::Validator { .. } = self.mode { - // TODO: This should not be hardcoded - let privkey = ::G2Affine::prime_subgroup_generator(); +impl Shell +where + D: DB + for<'iter> DBIter<'iter> + Sync + 'static, + H: StorageHasher + Sync + 'static, +{ + /// Begin a new block. + /// + /// We include half of the new wrapper txs given to us from the mempool + /// by tendermint. The rest of the block is filled with decryptions + /// of the wrapper txs from the previously committed block. + /// + /// INVARIANT: Any changes applied in this method must be reverted if + /// the proposal is rejected (unless we can simply overwrite + /// them in the next block). + pub fn prepare_proposal( + &mut self, + req: RequestPrepareProposal, + ) -> response::PrepareProposal { + // We can safely reset meter, because if the block is rejected, + // we'll reset again on the next proposal, until the + // proposal is accepted + self.gas_meter.reset(); + let txs = if let ShellMode::Validator { .. } = self.mode { + // TODO: This should not be hardcoded + let privkey = ::G2Affine::prime_subgroup_generator(); - // TODO: Craft the Ethereum state update tx - // filter in half of the new txs from Tendermint, only keeping - // wrappers - let number_of_new_txs = 1 + req.txs.len() / 2; - let mut txs: Vec = req - .txs - .into_iter() - .take(number_of_new_txs) - .map(|tx_bytes| { - if let Ok(Ok(TxType::Wrapper(_))) = - Tx::try_from(tx_bytes.as_slice()).map(process_tx) - { - record::keep(tx_bytes) - } else { - record::remove(tx_bytes) - } - }) - .collect(); + // TODO: Craft the Ethereum state update tx + // filter in half of the new txs from Tendermint, only keeping + // wrappers + let number_of_new_txs = 1 + req.txs.len() / 2; + let mut txs: Vec = req + .txs + .into_iter() + .take(number_of_new_txs) + .map(|tx_bytes| { + if let Ok(Ok(TxType::Wrapper(_))) = + Tx::try_from(tx_bytes.as_slice()).map(process_tx) + { + record::keep(tx_bytes) + } else { + record::remove(tx_bytes) + } + }) + .collect(); - // decrypt the wrapper txs included in the previous block - let mut decrypted_txs = self - .storage - .tx_queue - .iter() - .map(|tx| { - Tx::from(match tx.decrypt(privkey) { - Ok(tx) => DecryptedTx::Decrypted(tx), - _ => DecryptedTx::Undecryptable(tx.clone()), - }) - .to_bytes() + // decrypt the wrapper txs included in the previous block + let mut decrypted_txs = self + .storage + .tx_queue + .iter() + .map(|tx| { + Tx::from(match tx.decrypt(privkey) { + Ok(tx) => DecryptedTx::Decrypted(tx), + _ => DecryptedTx::Undecryptable(tx.clone()), }) - .map(record::add) - .collect(); + .to_bytes() + }) + .map(record::add) + .collect(); - txs.append(&mut decrypted_txs); - txs - } else { - vec![] - }; + txs.append(&mut decrypted_txs); + txs + } else { + vec![] + }; - response::PrepareProposal { - tx_records: txs, - ..Default::default() - } + response::PrepareProposal { + tx_records: txs, + ..Default::default() } } +} - /// Functions for creating the appropriate TxRecord given the - /// numeric code - pub(super) mod record { - use tendermint_proto::abci::tx_record::TxAction; +/// Functions for creating the appropriate TxRecord given the +/// numeric code +pub(super) mod record { + use tendermint_proto::abci::tx_record::TxAction; - use super::*; + use super::*; - /// Keep this transaction in the proposal - pub fn keep(tx: TxBytes) -> TxRecord { - TxRecord { - action: TxAction::Unmodified as i32, - tx, - } + /// Keep this transaction in the proposal + pub fn keep(tx: TxBytes) -> TxRecord { + TxRecord { + action: TxAction::Unmodified as i32, + tx, } + } - /// A transaction added to the proposal not provided by - /// Tendermint from the mempool - pub fn add(tx: TxBytes) -> TxRecord { - TxRecord { - action: TxAction::Added as i32, - tx, - } + /// A transaction added to the proposal not provided by + /// Tendermint from the mempool + pub fn add(tx: TxBytes) -> TxRecord { + TxRecord { + action: TxAction::Added as i32, + tx, } + } - /// Remove this transaction from the set provided - /// by Tendermint from the mempool - pub fn remove(tx: TxBytes) -> TxRecord { - TxRecord { - action: TxAction::Removed as i32, - tx, - } + /// Remove this transaction from the set provided + /// by Tendermint from the mempool + pub fn remove(tx: TxBytes) -> TxRecord { + TxRecord { + action: TxAction::Removed as i32, + tx, } } +} - #[cfg(test)] - mod test_prepare_proposal { - use namada::types::address::xan; - use namada::types::storage::Epoch; - use namada::types::transaction::Fee; - use tendermint_proto::abci::tx_record::TxAction; - - use super::*; - use crate::node::ledger::shell::test_utils::{gen_keypair, TestShell}; - - /// Test that if a tx from the mempool is not a - /// WrapperTx type, it is not included in the - /// proposed block. - #[test] - fn test_prepare_proposal_rejects_non_wrapper_tx() { - let (mut shell, _) = TestShell::new(); - let tx = Tx::new( - "wasm_code".as_bytes().to_owned(), - Some("transaction_data".as_bytes().to_owned()), - ); - let req = RequestPrepareProposal { - txs: vec![tx.to_bytes()], - max_tx_bytes: 0, - ..Default::default() - }; - assert_eq!( - shell.prepare_proposal(req).tx_records, - vec![record::remove(tx.to_bytes())] - ); - } +#[cfg(test)] +mod test_prepare_proposal { + use namada::types::address::xan; + use namada::types::storage::Epoch; + use namada::types::transaction::Fee; + use tendermint_proto::abci::tx_record::TxAction; - /// Test that if an error is encountered while - /// trying to process a tx from the mempool, - /// we simply exclude it from the proposal - #[test] - fn test_error_in_processing_tx() { - let (mut shell, _) = TestShell::new(); - let keypair = gen_keypair(); - let tx = Tx::new( - "wasm_code".as_bytes().to_owned(), - Some("transaction_data".as_bytes().to_owned()), - ); - // an unsigned wrapper will cause an error in processing - let wrapper = Tx::new( - "".as_bytes().to_owned(), - Some( - WrapperTx::new( - Fee { - amount: 0.into(), - token: xan(), - }, - &keypair, - Epoch(0), - 0.into(), - tx, - Default::default(), - ) - .try_to_vec() - .expect("Test failed"), - ), - ) - .to_bytes(); - let req = RequestPrepareProposal { - txs: vec![wrapper.clone()], - max_tx_bytes: 0, - ..Default::default() - }; - assert_eq!( - shell.prepare_proposal(req).tx_records, - vec![record::remove(wrapper)] - ); - } + use super::*; + use crate::node::ledger::shell::test_utils::{gen_keypair, TestShell}; - /// Test that the decrypted txs are included - /// in the proposal in the same order as their - /// corresponding wrappers - #[test] - fn test_decrypted_txs_in_correct_order() { - let (mut shell, _) = TestShell::new(); - let keypair = gen_keypair(); - let mut expected_wrapper = vec![]; - let mut expected_decrypted = vec![]; + /// Test that if a tx from the mempool is not a + /// WrapperTx type, it is not included in the + /// proposed block. + #[test] + fn test_prepare_proposal_rejects_non_wrapper_tx() { + let (mut shell, _) = TestShell::new(); + let tx = Tx::new( + "wasm_code".as_bytes().to_owned(), + Some("transaction_data".as_bytes().to_owned()), + ); + let req = RequestPrepareProposal { + txs: vec![tx.to_bytes()], + max_tx_bytes: 0, + ..Default::default() + }; + assert_eq!( + shell.prepare_proposal(req).tx_records, + vec![record::remove(tx.to_bytes())] + ); + } - let mut req = RequestPrepareProposal { - txs: vec![], - max_tx_bytes: 0, - ..Default::default() - }; - // create a request with two new wrappers from mempool and - // two wrappers from the previous block to be decrypted - for i in 0..2 { - let tx = Tx::new( - "wasm_code".as_bytes().to_owned(), - Some( - format!("transaction data: {}", i) - .as_bytes() - .to_owned(), - ), - ); - expected_decrypted - .push(Tx::from(DecryptedTx::Decrypted(tx.clone()))); - let wrapper_tx = WrapperTx::new( + /// Test that if an error is encountered while + /// trying to process a tx from the mempool, + /// we simply exclude it from the proposal + #[test] + fn test_error_in_processing_tx() { + let (mut shell, _) = TestShell::new(); + let keypair = gen_keypair(); + let tx = Tx::new( + "wasm_code".as_bytes().to_owned(), + Some("transaction_data".as_bytes().to_owned()), + ); + // an unsigned wrapper will cause an error in processing + let wrapper = Tx::new( + "".as_bytes().to_owned(), + Some( + WrapperTx::new( Fee { amount: 0.into(), token: xan(), @@ -225,51 +168,97 @@ mod prepare_block { 0.into(), tx, Default::default(), - ); - let wrapper = wrapper_tx.sign(&keypair).expect("Test failed"); - shell.enqueue_tx(wrapper_tx); - expected_wrapper.push(wrapper.clone()); - req.txs.push(wrapper.to_bytes()); - } - // we extract the inner data from the txs for testing - // equality since otherwise changes in timestamps would - // fail the test - expected_wrapper.append(&mut expected_decrypted); - let expected_txs: Vec> = expected_wrapper - .iter() - .map(|tx| tx.data.clone().expect("Test failed")) - .collect(); - - let received: Vec> = shell - .prepare_proposal(req) - .tx_records - .iter() - .filter_map( - |TxRecord { - tx: tx_bytes, - action, - }| { - if *action == (TxAction::Unmodified as i32) - || *action == (TxAction::Added as i32) - { - Some( - Tx::try_from(tx_bytes.as_slice()) - .expect("Test failed") - .data - .expect("Test failed"), - ) - } else { - None - } - }, ) - .collect(); - // check that the order of the txs is correct - assert_eq!(received, expected_txs); + .try_to_vec() + .expect("Test failed"), + ), + ) + .to_bytes(); + let req = RequestPrepareProposal { + txs: vec![wrapper.clone()], + max_tx_bytes: 0, + ..Default::default() + }; + assert_eq!( + shell.prepare_proposal(req).tx_records, + vec![record::remove(wrapper)] + ); + } + + /// Test that the decrypted txs are included + /// in the proposal in the same order as their + /// corresponding wrappers + #[test] + fn test_decrypted_txs_in_correct_order() { + let (mut shell, _) = TestShell::new(); + let keypair = gen_keypair(); + let mut expected_wrapper = vec![]; + let mut expected_decrypted = vec![]; + + let mut req = RequestPrepareProposal { + txs: vec![], + max_tx_bytes: 0, + ..Default::default() + }; + // create a request with two new wrappers from mempool and + // two wrappers from the previous block to be decrypted + for i in 0..2 { + let tx = Tx::new( + "wasm_code".as_bytes().to_owned(), + Some(format!("transaction data: {}", i).as_bytes().to_owned()), + ); + expected_decrypted + .push(Tx::from(DecryptedTx::Decrypted(tx.clone()))); + let wrapper_tx = WrapperTx::new( + Fee { + amount: 0.into(), + token: xan(), + }, + &keypair, + Epoch(0), + 0.into(), + tx, + Default::default(), + ); + let wrapper = wrapper_tx.sign(&keypair).expect("Test failed"); + shell.enqueue_tx(wrapper_tx); + expected_wrapper.push(wrapper.clone()); + req.txs.push(wrapper.to_bytes()); } + // we extract the inner data from the txs for testing + // equality since otherwise changes in timestamps would + // fail the test + expected_wrapper.append(&mut expected_decrypted); + let expected_txs: Vec> = expected_wrapper + .iter() + .map(|tx| tx.data.clone().expect("Test failed")) + .collect(); + + let received: Vec> = shell + .prepare_proposal(req) + .tx_records + .iter() + .filter_map( + |TxRecord { + tx: tx_bytes, + action, + }| { + if *action == (TxAction::Unmodified as i32) + || *action == (TxAction::Added as i32) + { + Some( + Tx::try_from(tx_bytes.as_slice()) + .expect("Test failed") + .data + .expect("Test failed"), + ) + } else { + None + } + }, + ) + .collect(); + // check that the order of the txs is correct + assert_eq!(received, expected_txs); } } - -#[allow(unused_imports)] -#[cfg(not(feature = "ABCI"))] -pub use prepare_block::*; diff --git a/apps/src/lib/node/ledger/shell/process_proposal.rs b/apps/src/lib/node/ledger/shell/process_proposal.rs index 9e41db598b..1108663372 100644 --- a/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -1,13 +1,9 @@ //! Implementation of the ['VerifyHeader`], [`ProcessProposal`], //! and [`RevertProposal`] ABCI++ methods for the Shell -#[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::response_process_proposal::ProposalStatus; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::{ ExecTxResult, RequestProcessProposal, ResponseProcessProposal, }; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::abci::RequestDeliverTx; use super::*; @@ -28,7 +24,6 @@ where /// but we only reject the entire block if the order of the /// included txs violates the order decided upon in the previous /// block. - #[cfg(not(feature = "ABCI"))] pub fn process_proposal( &mut self, req: RequestProcessProposal, @@ -174,89 +169,6 @@ where } } - /// If we are not using ABCI++, we check the wrapper, - /// decode it, and check the decoded payload all at once - #[cfg(feature = "ABCI")] - pub fn process_and_decode_proposal( - &mut self, - req: RequestDeliverTx, - ) -> shim::request::ProcessedTx { - // check the wrapper tx - let req_tx = match Tx::try_from(req.tx.as_ref()) { - Ok(tx) => tx, - Err(_) => { - return shim::request::ProcessedTx { - result: TxResult { - code: ErrorCodes::InvalidTx.into(), - info: "The submitted transaction was not \ - deserializable" - .into(), - }, - // this ensures that emitted events are of the correct type - tx: req.tx, - }; - } - }; - match process_tx(req_tx.clone()) { - Ok(TxType::Wrapper(_)) => {} - Ok(TxType::Protocol(_)) => { - let result = self.process_single_tx(&req.tx); - return shim::request::ProcessedTx { tx: req.tx, result }; - } - Ok(_) => { - return shim::request::ProcessedTx { - result: TxResult { - code: ErrorCodes::InvalidTx.into(), - info: "Transaction rejected: Non-encrypted \ - transactions are not supported" - .into(), - }, - // this ensures that emitted events are of the correct type - tx: req.tx, - }; - } - Err(_) => { - // This will be caught later - } - } - - let wrapper_resp = self.process_single_tx(&req.tx); - let privkey = ::G2Affine::prime_subgroup_generator(); - - if wrapper_resp.code == 0 { - // if the wrapper passed, decode it - if let Ok(TxType::Wrapper(wrapper)) = process_tx(req_tx) { - let decoded = Tx::from(match wrapper.decrypt(privkey) { - Ok(tx) => DecryptedTx::Decrypted(tx), - _ => DecryptedTx::Undecryptable(wrapper.clone()), - }) - .to_bytes(); - // we are not checking that txs are out of order - self.storage.tx_queue.push(wrapper); - // check the decoded tx - let decoded_resp = self.process_single_tx(&decoded); - // this ensures that the tx queue is empty even if an error - // happened in [`process_proposal`]. - self.storage.tx_queue.pop(); - shim::request::ProcessedTx { - // this ensures that emitted events are of the correct type - tx: decoded, - result: decoded_resp, - } - } else { - // This was checked above - unreachable!() - } - } else { - shim::request::ProcessedTx { - // this ensures that emitted events are of the correct type - tx: req.tx, - result: wrapper_resp, - } - } - } - - #[cfg(not(feature = "ABCI"))] pub fn revert_proposal( &mut self, _req: shim::request::RevertProposal, @@ -278,20 +190,12 @@ mod test_process_proposal { use namada::types::token::Amount; use namada::types::transaction::encrypted::EncryptedTx; use namada::types::transaction::{EncryptionKey, Fee}; - #[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::RequestInitChain; - #[cfg(not(feature = "ABCI"))] use tendermint_proto::google::protobuf::Timestamp; - #[cfg(feature = "ABCI")] - use tendermint_proto_abci::abci::RequestInitChain; - #[cfg(feature = "ABCI")] - use tendermint_proto_abci::google::protobuf::Timestamp; use super::*; - #[cfg(not(feature = "ABCI"))] - use crate::node::ledger::shell::test_utils::TestError; use crate::node::ledger::shell::test_utils::{ - gen_keypair, ProcessProposal, TestShell, + gen_keypair, ProcessProposal, TestError, TestShell, }; /// Test that if a wrapper tx is not signed, it is rejected @@ -339,11 +243,6 @@ mod test_process_proposal { response.result.info, String::from("Wrapper transactions must be signed") ); - #[cfg(feature = "ABCI")] - { - assert_eq!(response.tx, tx); - assert!(shell.shell.storage.tx_queue.is_empty()) - } } /// Test that a wrapper tx with invalid signature is rejected @@ -426,11 +325,6 @@ mod test_process_proposal { response.result.info, expected_error ); - #[cfg(feature = "ABCI")] - { - assert_eq!(response.tx, new_tx.to_bytes()); - assert!(shell.shell.storage.tx_queue.is_empty()) - } } /// Test that if the account submitting the tx is not known and the fee is @@ -474,11 +368,6 @@ mod test_process_proposal { "The address given does not have sufficient balance to pay fee" .to_string(), ); - #[cfg(feature = "ABCI")] - { - assert_eq!(response.tx, wrapper.to_bytes()); - assert!(shell.shell.storage.tx_queue.is_empty()) - } } /// Test that if the account submitting the tx does @@ -535,14 +424,8 @@ mod test_process_proposal { "The address given does not have sufficient balance to pay fee" ) ); - #[cfg(feature = "ABCI")] - { - assert_eq!(response.tx, wrapper.to_bytes()); - assert!(shell.shell.storage.tx_queue.is_empty()) - } } - #[cfg(not(feature = "ABCI"))] /// Test that if the expected order of decrypted txs is /// validated, [`process_proposal`] rejects it #[test] @@ -608,7 +491,6 @@ mod test_process_proposal { ); } - #[cfg(not(feature = "ABCI"))] /// Test that a tx incorrectly labelled as undecryptable /// is rejected by [`process_proposal`] #[test] @@ -692,15 +574,11 @@ mod test_process_proposal { ); wrapper.tx_hash = Hash([0; 32]); - let tx = if !cfg!(feature = "ABCI") { - shell.enqueue_tx(wrapper.clone()); - Tx::from(TxType::Decrypted(DecryptedTx::Undecryptable( - #[allow(clippy::redundant_clone)] - wrapper.clone(), - ))) - } else { - wrapper.sign(&keypair).expect("Test failed") - }; + shell.enqueue_tx(wrapper.clone()); + let tx = Tx::from(TxType::Decrypted(DecryptedTx::Undecryptable( + #[allow(clippy::redundant_clone)] + wrapper.clone(), + ))); let request = ProcessProposal { txs: vec![tx.to_bytes()], @@ -715,23 +593,6 @@ mod test_process_proposal { panic!("Test failed") }; assert_eq!(response.result.code, u32::from(ErrorCodes::Ok)); - #[cfg(feature = "ABCI")] - { - match process_tx( - Tx::try_from(response.tx.as_ref()).expect("Test failed"), - ) - .expect("Test failed") - { - TxType::Decrypted(DecryptedTx::Undecryptable(inner)) => { - assert_eq!( - hash_tx(inner.try_to_vec().unwrap().as_ref()), - hash_tx(wrapper.try_to_vec().unwrap().as_ref()) - ); - assert!(shell.shell.storage.tx_queue.is_empty()) - } - _ => panic!("Test failed"), - } - } } /// Test that if a wrapper tx contains garbage bytes @@ -765,15 +626,11 @@ mod test_process_proposal { tx_hash: hash_tx(&tx), }; - let signed = if !cfg!(feature = "ABCI") { - shell.enqueue_tx(wrapper.clone()); - Tx::from(TxType::Decrypted(DecryptedTx::Undecryptable( - #[allow(clippy::redundant_clone)] - wrapper.clone(), - ))) - } else { - wrapper.sign(&keypair).expect("Test failed") - }; + shell.enqueue_tx(wrapper.clone()); + let signed = Tx::from(TxType::Decrypted(DecryptedTx::Undecryptable( + #[allow(clippy::redundant_clone)] + wrapper.clone(), + ))); let request = ProcessProposal { txs: vec![signed.to_bytes()], }; @@ -787,26 +644,8 @@ mod test_process_proposal { panic!("Test failed") }; assert_eq!(response.result.code, u32::from(ErrorCodes::Ok)); - #[cfg(feature = "ABCI")] - { - match process_tx( - Tx::try_from(response.tx.as_ref()).expect("Test failed"), - ) - .expect("Test failed") - { - TxType::Decrypted(DecryptedTx::Undecryptable(inner)) => { - assert_eq!( - hash_tx(inner.try_to_vec().unwrap().as_ref()), - hash_tx(wrapper.try_to_vec().unwrap().as_ref()) - ); - assert!(shell.shell.storage.tx_queue.is_empty()); - } - _ => panic!("Test failed"), - } - } } - #[cfg(not(feature = "ABCI"))] /// Test that if more decrypted txs are submitted to /// [`process_proposal`] than expected, they are rejected #[test] @@ -871,9 +710,5 @@ mod test_process_proposal { supported" ), ); - #[cfg(feature = "ABCI")] - { - assert_eq!(response.tx, tx.to_bytes()); - } } } diff --git a/apps/src/lib/node/ledger/shell/queries.rs b/apps/src/lib/node/ledger/shell/queries.rs index 71ad018a2f..a643501d9e 100644 --- a/apps/src/lib/node/ledger/shell/queries.rs +++ b/apps/src/lib/node/ledger/shell/queries.rs @@ -10,18 +10,9 @@ use namada::types::key; use namada::types::key::dkg_session_keys::DkgPublicKey; use namada::types::storage::{Key, PrefixValue}; use namada::types::token::{self, Amount}; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::crypto::{ProofOp, ProofOps}; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::google::protobuf; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::types::EvidenceParams; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::crypto::{ProofOp, ProofOps}; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::google::protobuf; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::types::EvidenceParams; use super::*; use crate::node::ledger::response; diff --git a/apps/src/lib/node/ledger/shims/abcipp_shim.rs b/apps/src/lib/node/ledger/shims/abcipp_shim.rs index 99ed7e1ad8..59abc3d1a9 100644 --- a/apps/src/lib/node/ledger/shims/abcipp_shim.rs +++ b/apps/src/lib/node/ledger/shims/abcipp_shim.rs @@ -5,24 +5,12 @@ use std::pin::Pin; use std::task::{Context, Poll}; use futures::future::FutureExt; -#[cfg(feature = "ABCI")] -use namada::types::hash::Hash; -#[cfg(feature = "ABCI")] -use namada::types::storage::BlockHash; -#[cfg(feature = "ABCI")] -use namada::types::transaction::hash_tx; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::abci::RequestBeginBlock; use tokio::sync::mpsc::UnboundedSender; use tower::Service; -#[cfg(not(feature = "ABCI"))] use tower_abci::{BoxError, Request as Req, Response as Resp}; -#[cfg(feature = "ABCI")] -use tower_abci_old::{BoxError, Request as Req, Response as Resp}; use super::super::Shell; use super::abcipp_shim_types::shim::request::{FinalizeBlock, ProcessedTx}; -#[cfg(not(feature = "ABCI"))] use super::abcipp_shim_types::shim::response::TxResult; use super::abcipp_shim_types::shim::{Error, Request, Response}; use crate::config; @@ -33,8 +21,6 @@ use crate::config; #[derive(Debug)] pub struct AbcippShim { service: Shell, - #[cfg(feature = "ABCI")] - begin_block_request: Option, processed_txs: Vec, shell_recv: std::sync::mpsc::Receiver<( Req, @@ -66,8 +52,6 @@ impl AbcippShim { vp_wasm_compilation_cache, tx_wasm_compilation_cache, ), - #[cfg(feature = "ABCI")] - begin_block_request: None, processed_txs: vec![], shell_recv, }, @@ -75,23 +59,11 @@ impl AbcippShim { ) } - #[cfg(feature = "ABCI")] - /// Get the hash of the txs in the block - pub fn get_hash(&self) -> Hash { - let bytes: Vec = self - .processed_txs - .iter() - .flat_map(|processed| processed.tx.clone()) - .collect(); - hash_tx(bytes.as_slice()) - } - /// Run the shell's blocking loop that receives messages from the /// [`AbciService`]. pub fn run(mut self) { while let Ok((req, resp_sender)) = self.shell_recv.recv() { let resp = match req { - #[cfg(not(feature = "ABCI"))] Req::ProcessProposal(proposal) => { let txs = proposal.txs.clone(); self.service @@ -113,7 +85,6 @@ impl AbcippShim { _ => unreachable!(), }) } - #[cfg(not(feature = "ABCI"))] Req::FinalizeBlock(block) => { let mut txs = vec![]; std::mem::swap(&mut txs, &mut self.processed_txs); @@ -129,47 +100,6 @@ impl AbcippShim { _ => Err(Error::ConvertResp(res)), }) } - #[cfg(feature = "ABCI")] - Req::BeginBlock(block) => { - // we save this data to be forwarded to finalize later - self.begin_block_request = Some(block); - Ok(Resp::BeginBlock(Default::default())) - } - #[cfg(feature = "ABCI")] - Req::DeliverTx(deliver_tx) => { - // We call [`process_single_tx`] to report back the validity - // of the tx to tendermint. - self.service - .call(Request::DeliverTx(deliver_tx)) - .map_err(Error::from) - .and_then(|res| match res { - Response::DeliverTx(resp) => { - self.processed_txs.push(resp); - Ok(Resp::DeliverTx(Default::default())) - } - _ => unreachable!(), - }) - } - #[cfg(feature = "ABCI")] - Req::EndBlock(_) => { - let mut txs = vec![]; - std::mem::swap(&mut txs, &mut self.processed_txs); - let mut end_block_request: FinalizeBlock = - self.begin_block_request.take().unwrap().into(); - let hash = self.get_hash(); - end_block_request.hash = BlockHash::from(hash.clone()); - end_block_request.header.hash = hash; - end_block_request.txs = txs; - self.service - .call(Request::FinalizeBlock(end_block_request)) - .map_err(Error::from) - .and_then(|res| match res { - Response::FinalizeBlock(resp) => { - Ok(Resp::EndBlock(resp.into())) - } - _ => Err(Error::ConvertResp(res)), - }) - } _ => match Request::try_from(req.clone()) { Ok(request) => self .service diff --git a/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs b/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs index 7e7395fd78..bea7ba56af 100644 --- a/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs +++ b/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs @@ -1,12 +1,8 @@ -#[cfg(not(feature = "ABCI"))] use tower_abci::{Request, Response}; -#[cfg(feature = "ABCI")] -use tower_abci_old::{Request, Response}; pub mod shim { use std::convert::TryFrom; - #[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::{ RequestApplySnapshotChunk, RequestCheckTx, RequestCommit, RequestEcho, RequestExtendVote, RequestFlush, RequestInfo, RequestInitChain, @@ -19,16 +15,6 @@ pub mod shim { ResponsePrepareProposal, ResponseProcessProposal, ResponseQuery, ResponseVerifyVoteExtension, }; - #[cfg(feature = "ABCI")] - use tendermint_proto_abci::abci::{ - RequestApplySnapshotChunk, RequestCheckTx, RequestCommit, - RequestDeliverTx, RequestEcho, RequestFlush, RequestInfo, - RequestInitChain, RequestListSnapshots, RequestLoadSnapshotChunk, - RequestOfferSnapshot, RequestQuery, ResponseApplySnapshotChunk, - ResponseCheckTx, ResponseCommit, ResponseEcho, ResponseEndBlock, - ResponseFlush, ResponseInfo, ResponseInitChain, ResponseListSnapshots, - ResponseLoadSnapshotChunk, ResponseOfferSnapshot, ResponseQuery, - }; use thiserror::Error; use super::{Request as Req, Response as Resp}; @@ -65,20 +51,13 @@ pub mod shim { InitChain(RequestInitChain), Info(RequestInfo), Query(RequestQuery), - #[cfg(not(feature = "ABCI"))] PrepareProposal(RequestPrepareProposal), #[allow(dead_code)] VerifyHeader(request::VerifyHeader), - #[cfg(not(feature = "ABCI"))] ProcessProposal(RequestProcessProposal), - #[cfg(feature = "ABCI")] - DeliverTx(RequestDeliverTx), #[allow(dead_code)] - #[cfg(not(feature = "ABCI"))] RevertProposal(request::RevertProposal), - #[cfg(not(feature = "ABCI"))] ExtendVote(RequestExtendVote), - #[cfg(not(feature = "ABCI"))] VerifyVoteExtension(RequestVerifyVoteExtension), FinalizeBlock(request::FinalizeBlock), Commit(RequestCommit), @@ -103,9 +82,7 @@ pub mod shim { Req::Commit(inner) => Ok(Request::Commit(inner)), Req::Flush(inner) => Ok(Request::Flush(inner)), Req::Echo(inner) => Ok(Request::Echo(inner)), - #[cfg(not(feature = "ABCI"))] Req::ExtendVote(inner) => Ok(Request::ExtendVote(inner)), - #[cfg(not(feature = "ABCI"))] Req::VerifyVoteExtension(inner) => { Ok(Request::VerifyVoteExtension(inner)) } @@ -118,7 +95,6 @@ pub mod shim { Req::ApplySnapshotChunk(inner) => { Ok(Request::ApplySnapshotChunk(inner)) } - #[cfg(not(feature = "ABCI"))] Req::PrepareProposal(inner) => { Ok(Request::PrepareProposal(inner)) } @@ -135,22 +111,13 @@ pub mod shim { InitChain(ResponseInitChain), Info(ResponseInfo), Query(ResponseQuery), - #[cfg(not(feature = "ABCI"))] PrepareProposal(ResponsePrepareProposal), VerifyHeader(response::VerifyHeader), - #[cfg(not(feature = "ABCI"))] ProcessProposal(ResponseProcessProposal), - #[cfg(feature = "ABCI")] - DeliverTx(request::ProcessedTx), - #[cfg(not(feature = "ABCI"))] RevertProposal(response::RevertProposal), - #[cfg(not(feature = "ABCI"))] ExtendVote(ResponseExtendVote), - #[cfg(not(feature = "ABCI"))] VerifyVoteExtension(ResponseVerifyVoteExtension), FinalizeBlock(response::FinalizeBlock), - #[cfg(feature = "ABCI")] - EndBlock(ResponseEndBlock), Commit(ResponseCommit), Flush(ResponseFlush), Echo(ResponseEcho), @@ -186,13 +153,10 @@ pub mod shim { Response::ApplySnapshotChunk(inner) => { Ok(Resp::ApplySnapshotChunk(inner)) } - #[cfg(not(feature = "ABCI"))] Response::PrepareProposal(inner) => { Ok(Resp::PrepareProposal(inner)) } - #[cfg(not(feature = "ABCI"))] Response::ExtendVote(inner) => Ok(Resp::ExtendVote(inner)), - #[cfg(not(feature = "ABCI"))] Response::VerifyVoteExtension(inner) => { Ok(Resp::VerifyVoteExtension(inner)) } @@ -208,16 +172,12 @@ pub mod shim { use namada::types::hash::Hash; use namada::types::storage::{BlockHash, Header}; use namada::types::time::DateTimeUtc; - #[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::{ Misbehavior as Evidence, RequestFinalizeBlock, }; - #[cfg(feature = "ABCI")] - use tendermint_proto_abci::abci::{Evidence, RequestBeginBlock}; pub struct VerifyHeader; - #[cfg(not(feature = "ABCI"))] pub struct RevertProposal; /// A Tx and the result of calling Process Proposal on it @@ -234,7 +194,6 @@ pub mod shim { pub txs: Vec, } - #[cfg(not(feature = "ABCI"))] impl From for FinalizeBlock { fn from(req: RequestFinalizeBlock) -> FinalizeBlock { FinalizeBlock { @@ -252,48 +211,17 @@ pub mod shim { } } } - - #[cfg(feature = "ABCI")] - impl From for FinalizeBlock { - fn from(req: RequestBeginBlock) -> FinalizeBlock { - let header = req.header.unwrap(); - FinalizeBlock { - hash: BlockHash::default(), - header: Header { - hash: Hash::default(), - time: DateTimeUtc::try_from(header.time.unwrap()) - .unwrap(), - next_validators_hash: Hash::try_from( - header.next_validators_hash.as_slice(), - ) - .unwrap(), - }, - byzantine_validators: req.byzantine_validators, - txs: vec![], - } - } - } } /// Custom types for response payloads pub mod response { - #[cfg(not(feature = "ABCI"))] use tendermint_proto::abci::{ Event as TmEvent, ExecTxResult, ResponseFinalizeBlock, ValidatorUpdate, }; - #[cfg(not(feature = "ABCI"))] use tendermint_proto::types::ConsensusParams; - #[cfg(feature = "ABCI")] - use tendermint_proto_abci::abci::ConsensusParams; - #[cfg(feature = "ABCI")] - use tendermint_proto_abci::abci::{Event as TmEvent, ValidatorUpdate}; - #[cfg(feature = "ABCI")] - use tower_abci_old::response; - use crate::node::ledger::events::Event; - #[cfg(not(feature = "ABCI"))] - use crate::node::ledger::events::EventLevel; + use crate::node::ledger::events::{Event, EventLevel}; #[derive(Debug, Default)] pub struct VerifyHeader; @@ -304,7 +232,6 @@ pub mod shim { pub info: String, } - #[cfg(not(feature = "ABCI"))] impl From for ExecTxResult { fn from(TxResult { code, info }: TxResult) -> Self { ExecTxResult { @@ -315,7 +242,6 @@ pub mod shim { } } - #[cfg(not(feature = "ABCI"))] impl From<&ExecTxResult> for TxResult { fn from(ExecTxResult { code, info, .. }: &ExecTxResult) -> Self { TxResult { @@ -335,7 +261,6 @@ pub mod shim { pub consensus_param_updates: Option, } - #[cfg(not(feature = "ABCI"))] impl From for ResponseFinalizeBlock { fn from(resp: FinalizeBlock) -> Self { ResponseFinalizeBlock { @@ -374,20 +299,5 @@ pub mod shim { } } } - - #[cfg(feature = "ABCI")] - impl From for response::EndBlock { - fn from(resp: FinalizeBlock) -> Self { - Self { - events: resp - .events - .into_iter() - .map(TmEvent::from) - .collect(), - validator_updates: resp.validator_updates, - consensus_param_updates: resp.consensus_param_updates, - } - } - } } } diff --git a/apps/src/lib/node/ledger/tendermint_node.rs b/apps/src/lib/node/ledger/tendermint_node.rs index c38146cd35..136f925df4 100644 --- a/apps/src/lib/node/ledger/tendermint_node.rs +++ b/apps/src/lib/node/ledger/tendermint_node.rs @@ -9,22 +9,9 @@ use namada::types::chain::ChainId; use namada::types::key::*; use namada::types::time::DateTimeUtc; use serde_json::json; -#[cfg(not(feature = "ABCI"))] use tendermint::Genesis; -#[cfg(not(feature = "ABCI"))] use tendermint_config::net::Address as TendermintAddress; -#[cfg(not(feature = "ABCI"))] -use tendermint_config::Error as TendermintError; -#[cfg(not(feature = "ABCI"))] -use tendermint_config::TendermintConfig; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::net::Address as TendermintAddress; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::Error as TendermintError; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::TendermintConfig; -#[cfg(feature = "ABCI")] -use tendermint_stable::Genesis; +use tendermint_config::{Error as TendermintError, TendermintConfig}; use thiserror::Error; use tokio::fs::{self, File, OpenOptions}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -97,19 +84,11 @@ pub async fn run( }; // init and run a tendermint node child process - let output = if !cfg!(feature = "ABCI") { - Command::new(&tendermint_path) - .args(&["init", &mode, "--home", &home_dir_string]) - .output() - .await - .map_err(Error::Init)? - } else { - Command::new(&tendermint_path) - .args(&["init", "--home", &home_dir_string]) - .output() - .await - .map_err(Error::Init)? - }; + let output = Command::new(&tendermint_path) + .args(&["init", &mode, "--home", &home_dir_string]) + .output() + .await + .map_err(Error::Init)?; if !output.status.success() { panic!("Tendermint failed to initialize with {:#?}", output); } @@ -135,37 +114,20 @@ pub async fn run( .await; } } - #[cfg(not(feature = "ABCI"))] - { - write_tm_genesis(&home_dir, chain_id, genesis_time, &config).await; - } - #[cfg(feature = "ABCI")] - { - write_tm_genesis(&home_dir, chain_id, genesis_time).await; - } + write_tm_genesis(&home_dir, chain_id, genesis_time, &config).await; update_tendermint_config(&home_dir, config).await?; let mut tendermint_node = Command::new(&tendermint_path); - if !cfg!(feature = "ABCI") { - tendermint_node.args(&[ - "start", - "--mode", - &mode, - "--proxy-app", - &ledger_address, - "--home", - &home_dir_string, - ]) - } else { - tendermint_node.args(&[ - "start", - "--proxy_app", - &ledger_address, - "--home", - &home_dir_string, - ]) - }; + tendermint_node.args(&[ + "start", + "--mode", + &mode, + "--proxy-app", + &ledger_address, + "--home", + &home_dir_string, + ]); let log_stdout = match env::var(ENV_VAR_TM_STDOUT) { Ok(val) => val.to_ascii_lowercase().trim() == "true", @@ -218,7 +180,6 @@ pub fn reset(tendermint_dir: impl AsRef) -> Result<()> { let tendermint_path = from_env_or_default()?; let tendermint_dir = tendermint_dir.as_ref().to_string_lossy(); // reset all the Tendermint state, if any - #[cfg(not(feature = "ABCI"))] std::process::Command::new(tendermint_path) .args(&[ "reset", @@ -230,17 +191,6 @@ pub fn reset(tendermint_dir: impl AsRef) -> Result<()> { ]) .output() .expect("Failed to reset tendermint node's data"); - #[cfg(feature = "ABCI")] - std::process::Command::new(tendermint_path) - .args(&[ - "unsafe-reset-all", - // NOTE: log config: https://docs.tendermint.com/master/nodes/logging.html#configuring-log-levels - // "--log-level=\"*debug\"", - "--home", - &tendermint_dir, - ]) - .output() - .expect("Failed to reset tendermint node's data"); std::fs::remove_dir_all(format!("{}/config", tendermint_dir,)) .expect("Failed to reset tendermint node's config"); Ok(()) @@ -360,19 +310,10 @@ async fn update_tendermint_config( config.p2p.persistent_peers = tendermint_config.p2p_persistent_peers; config.p2p.pex = tendermint_config.p2p_pex; config.p2p.allow_duplicate_ip = tendermint_config.p2p_allow_duplicate_ip; - #[cfg(feature = "ABCI")] - { - config.p2p.addr_book_strict = tendermint_config.p2p_addr_book_strict; - } // In "dev", only produce blocks when there are txs or when the AppHash // changes config.consensus.create_empty_blocks = true; // !cfg!(feature = "dev"); - #[cfg(feature = "ABCI")] - { - config.consensus.timeout_commit = - tendermint_config.consensus_timeout_commit; - } // We set this to true as we don't want any invalid tx be re-applied. This // also implies that it's not possible for an invalid tx to become valid @@ -395,7 +336,6 @@ async fn update_tendermint_config( tendermint_config.instrumentation_namespace; // setup the events log - #[cfg(not(feature = "ABCI"))] { // keep events for one minute config.rpc.event_log_window_size = @@ -421,7 +361,7 @@ async fn write_tm_genesis( home_dir: impl AsRef, chain_id: ChainId, genesis_time: DateTimeUtc, - #[cfg(not(feature = "ABCI"))] config: &config::Tendermint, + config: &config::Tendermint, ) { let home_dir = home_dir.as_ref(); let path = home_dir.join("config").join("genesis.json"); @@ -442,11 +382,8 @@ async fn write_tm_genesis( genesis.genesis_time = genesis_time .try_into() .expect("Couldn't convert DateTimeUtc to Tendermint Time"); - #[cfg(not(feature = "ABCI"))] - { - genesis.consensus_params.timeout.commit = - config.consensus_timeout_commit.into() - } + genesis.consensus_params.timeout.commit = + config.consensus_timeout_commit.into(); let mut file = OpenOptions::new() .write(true) diff --git a/apps/src/lib/node/matchmaker.rs b/apps/src/lib/node/matchmaker.rs index 3813569391..0a01528b00 100644 --- a/apps/src/lib/node/matchmaker.rs +++ b/apps/src/lib/node/matchmaker.rs @@ -14,14 +14,8 @@ use namada::types::intent::{IntentTransfers, MatchedExchanges}; use namada::types::key::*; use namada::types::matchmaker::AddIntentResult; use namada::types::transaction::{hash_tx, Fee, WrapperTx}; -#[cfg(not(feature = "ABCI"))] use tendermint_config::net; -#[cfg(not(feature = "ABCI"))] use tendermint_config::net::Address as TendermintAddress; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::net; -#[cfg(feature = "ABCI")] -use tendermint_config_abci::net::Address as TendermintAddress; use super::gossip::rpc::matchmakers::{ ClientDialer, ClientListener, MsgFromClient, MsgFromServer, @@ -331,17 +325,9 @@ impl ResultHandler { // TODO: Actually use the fetched encryption key Default::default(), ); - let wrapper_hash = if !cfg!(feature = "ABCI") { - hash_tx(&tx.try_to_vec().unwrap()).to_string() - } else { - tx.tx_hash.to_string() - }; + let wrapper_hash = hash_tx(&tx.try_to_vec().unwrap()).to_string(); - let decrypted_hash = if !cfg!(feature = "ABCI") { - Some(tx.tx_hash.to_string()) - } else { - None - }; + let decrypted_hash = tx.tx_hash.to_string(); TxBroadcastData::Wrapper { tx: tx .sign(&self.tx_signing_key) diff --git a/shared/build.rs b/shared/build.rs index d87f7a918f..3c5ffb41f1 100644 --- a/shared/build.rs +++ b/shared/build.rs @@ -9,10 +9,6 @@ const PROTO_SRC: &str = "./proto"; const RUSTFMT_TOOLCHAIN_SRC: &str = "../rust-nightly-version"; fn main() { - #[cfg(all(feature = "ABCI", feature = "ABCI-plus-plus"))] - compile_error!( - "`ABCI` and `ABCI-plus-plus` may not be used at the same time" - ); if let Ok(val) = env::var("COMPILE_PROTO") { if val.to_ascii_lowercase() == "false" { // Skip compiling proto files diff --git a/shared/src/ledger/storage/merkle_tree.rs b/shared/src/ledger/storage/merkle_tree.rs index 183fa457b0..fa0f4a011f 100644 --- a/shared/src/ledger/storage/merkle_tree.rs +++ b/shared/src/ledger/storage/merkle_tree.rs @@ -16,10 +16,7 @@ use sparse_merkle_tree::default_store::DefaultStore; use sparse_merkle_tree::error::Error as SmtError; use sparse_merkle_tree::traits::Hasher; use sparse_merkle_tree::{SparseMerkleTree, H256}; -#[cfg(not(feature = "ABCI"))] use tendermint::merkle::proof::{Proof, ProofOp}; -#[cfg(feature = "ABCI")] -use tendermint_stable::merkle::proof::{Proof, ProofOp}; use thiserror::Error; use crate::bytes::ByteBuf; diff --git a/shared/src/ledger/storage/mod.rs b/shared/src/ledger/storage/mod.rs index 56e9862eb9..0b3d19a742 100644 --- a/shared/src/ledger/storage/mod.rs +++ b/shared/src/ledger/storage/mod.rs @@ -8,10 +8,7 @@ pub mod write_log; use core::fmt::Debug; -#[cfg(not(feature = "ABCI"))] use tendermint::merkle::proof::Proof; -#[cfg(feature = "ABCI")] -use tendermint_stable::merkle::proof::Proof; use thiserror::Error; use super::parameters; diff --git a/shared/src/lib.rs b/shared/src/lib.rs index 5199e120a6..5c2d2fe4d7 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -6,22 +6,7 @@ #![deny(rustdoc::broken_intra_doc_links)] #![deny(rustdoc::private_intra_doc_links)] -#[cfg(not(feature = "ABCI"))] -pub use ibc; -#[cfg(feature = "ABCI")] -pub use ibc_abci as ibc; -#[cfg(not(feature = "ABCI"))] -pub use ibc_proto; -#[cfg(feature = "ABCI")] -pub use ibc_proto_abci as ibc_proto; -#[cfg(not(feature = "ABCI"))] -pub use tendermint; -#[cfg(not(feature = "ABCI"))] -pub use tendermint_proto; -#[cfg(feature = "ABCI")] -pub use tendermint_proto_abci as tendermint_proto; -#[cfg(feature = "ABCI")] -pub use tendermint_stable as tendermint; +pub use {ibc, ibc_proto, tendermint, tendermint_proto}; pub mod bytes; pub mod ledger; diff --git a/shared/src/types/hash.rs b/shared/src/types/hash.rs index 6e2198ceb6..e2fed30379 100644 --- a/shared/src/types/hash.rs +++ b/shared/src/types/hash.rs @@ -6,14 +6,8 @@ use std::ops::Deref; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; -#[cfg(not(feature = "ABCI"))] use tendermint::abci::transaction; -#[cfg(not(feature = "ABCI"))] use tendermint::Hash as TmHash; -#[cfg(feature = "ABCI")] -use tendermint_stable::abci::transaction; -#[cfg(feature = "ABCI")] -use tendermint_stable::Hash as TmHash; use thiserror::Error; /// The length of the transaction hash string diff --git a/shared/src/types/time.rs b/shared/src/types/time.rs index 47cdbb36ff..ec91ff5b14 100644 --- a/shared/src/types/time.rs +++ b/shared/src/types/time.rs @@ -6,10 +6,7 @@ use std::ops::{Add, Sub}; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; pub use chrono::{DateTime, Duration, TimeZone, Utc}; -#[cfg(not(feature = "ABCI"))] use tendermint_proto::google::protobuf; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::google::protobuf; use crate::tendermint::time::Time; use crate::tendermint::Error as TendermintError; diff --git a/tests/src/e2e/eth_bridge_tests.rs b/tests/src/e2e/eth_bridge_tests.rs index 70e753e813..b276dd409e 100644 --- a/tests/src/e2e/eth_bridge_tests.rs +++ b/tests/src/e2e/eth_bridge_tests.rs @@ -76,9 +76,7 @@ fn everything() { .unwrap(); if !dry_run { - if !cfg!(feature = "ABCI") { - anomac_tx.exp_string("Transaction accepted").unwrap(); - } + anomac_tx.exp_string("Transaction accepted").unwrap(); anomac_tx.exp_string("Transaction applied").unwrap(); } // TODO: we should check here explicitly with the ledger via a diff --git a/tests/src/e2e/gossip_tests.rs b/tests/src/e2e/gossip_tests.rs index feb0e88324..5da19c0758 100644 --- a/tests/src/e2e/gossip_tests.rs +++ b/tests/src/e2e/gossip_tests.rs @@ -182,15 +182,8 @@ fn match_intents() -> Result<()> { let validator_one_gossiper = get_gossiper_mm_server(&test, &Who::Validator(0)); - // The RPC port is either 27660 for ABCI or 28660 for ABCI++ (see - // `setup::network`) - let rpc_port = (27660 - + if cfg!(feature = "ABCI") { - 0 - } else { - setup::ABCI_PLUS_PLUS_PORT_OFFSET - }) - .to_string(); + // The RPC port starts at 27660 (see `setup::network`) + let rpc_port = 27660; let rpc_address = format!("127.0.0.1:{}", rpc_port); // Start intent gossiper node diff --git a/tests/src/e2e/helpers.rs b/tests/src/e2e/helpers.rs index f72044b80a..cc0c45cf8c 100644 --- a/tests/src/e2e/helpers.rs +++ b/tests/src/e2e/helpers.rs @@ -173,26 +173,13 @@ pub fn generate_bin_command(bin_name: &str, manifest_path: &Path) -> Command { }; if !use_prebuilt_binaries { - let build_cmd = if !cfg!(feature = "ABCI") { - CargoBuild::new() - .package(APPS_PACKAGE) - .manifest_path(manifest_path) - .no_default_features() - .features("ABCI-plus-plus") - // Explicitly disable dev, in case it's enabled when a test is - // invoked - .env("ANOMA_DEV", "false") - .bin(bin_name) - } else { - CargoBuild::new() - .package(APPS_PACKAGE) - .manifest_path(manifest_path) - .features("ABCI") - // Explicitly disable dev, in case it's enabled when a test is - // invoked - .env("ANOMA_DEV", "false") - .bin(bin_name) - }; + let build_cmd = CargoBuild::new() + .package(APPS_PACKAGE) + .manifest_path(manifest_path) + // Explicitly disable dev, in case it's enabled when a test is + // invoked + .env("ANOMA_DEV", "false") + .bin(bin_name); let build_cmd = if run_debug { build_cmd diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index a83d3f54ca..c453c13cf4 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -52,11 +52,7 @@ fn run_ledger() -> Result<()> { let mut ledger = run_as!(test, Who::NonValidator, Bin::Node, args, Some(40))?; ledger.exp_string("Anoma ledger node started")?; - if !cfg!(feature = "ABCI") { - ledger.exp_string("This node is a fullnode")?; - } else { - ledger.exp_string("This node is not a validator")?; - } + ledger.exp_string("This node is a fullnode")?; } Ok(()) @@ -66,8 +62,8 @@ fn run_ledger() -> Result<()> { /// 1. Run 2 genesis validator ledger nodes and 1 non-validator node /// 2. Submit a valid token transfer tx /// 3. Check that all the nodes processed the tx with the same result -/// TODO: run this test for ABCI-plus-plus once https://github.com/tendermint/tendermint/issues/8840 is fixed -#[cfg(not(feature = "ABCI-plus-plus"))] +/// TODO: run this test once https://github.com/tendermint/tendermint/issues/8840 is fixed +#[ignore] #[test] fn test_node_connectivity() -> Result<()> { // Setup 2 genesis validator nodes @@ -87,11 +83,7 @@ fn test_node_connectivity() -> Result<()> { let mut non_validator = run_as!(test, Who::NonValidator, Bin::Node, args, Some(40))?; non_validator.exp_string("Anoma ledger node started")?; - if !cfg!(feature = "ABCI") { - non_validator.exp_string("This node is a fullnode")?; - } else { - non_validator.exp_string("This node is not a validator")?; - } + non_validator.exp_string("This node is a fullnode")?; // 2. Submit a valid token transfer tx let validator_one_rpc = get_actor_rpc(&test, &Who::Validator(0)); @@ -342,9 +334,7 @@ fn ledger_txs_and_queries() -> Result<()> { let mut client = run!(test, Bin::Client, tx_args, Some(40))?; if !dry_run { - if !cfg!(feature = "ABCI") { - client.exp_string("Transaction accepted")?; - } + client.exp_string("Transaction accepted")?; client.exp_string("Transaction applied")?; } client.exp_string("Transaction is valid.")?; @@ -460,9 +450,7 @@ fn invalid_transactions() -> Result<()> { ]; let mut client = run!(test, Bin::Client, tx_args, Some(40))?; - if !cfg!(feature = "ABCI") { - client.exp_string("Transaction accepted")?; - } + client.exp_string("Transaction accepted")?; client.exp_string("Transaction applied")?; client.exp_string("Transaction is invalid")?; client.exp_string(r#""code": "1"#)?; @@ -519,9 +507,7 @@ fn invalid_transactions() -> Result<()> { ]; let mut client = run!(test, Bin::Client, tx_args, Some(40))?; - if !cfg!(feature = "ABCI") { - client.exp_string("Transaction accepted")?; - } + client.exp_string("Transaction accepted")?; client.exp_string("Transaction applied")?; client.exp_string("Error trying to apply a transaction")?; @@ -967,9 +953,7 @@ fn ledger_many_txs_in_a_block() -> Result<()> { let mut args = (*tx_args).clone(); args.push(&*validator_one_rpc); let mut client = run!(*test, Bin::Client, args, Some(40))?; - if !cfg!(feature = "ABCI") { - client.exp_string("Transaction accepted")?; - } + client.exp_string("Transaction accepted")?; client.exp_string("Transaction applied")?; client.exp_string("Transaction is valid.")?; client.assert_success(); @@ -1516,8 +1500,8 @@ fn generate_proposal_json( /// 3. Setup and start the 2 genesis validator nodes and a non-validator node /// 4. Submit a valid token transfer tx from one validator to the other /// 5. Check that all the nodes processed the tx with the same result -/// TODO: run this test for ABCI-plus-plus once https://github.com/tendermint/tendermint/issues/8840 is fixed -#[cfg(not(feature = "ABCI-plus-plus"))] +/// TODO: run this test once https://github.com/tendermint/tendermint/issues/8840 is fixed +#[ignore] #[test] fn test_genesis_validators() -> Result<()> { use std::collections::HashMap; @@ -1550,17 +1534,7 @@ fn test_genesis_validators() -> Result<()> { let net_address_port_0 = net_address_0.port(); // Find the first port (ledger P2P) that should be used for a validator at // the given index - let get_first_port = |ix: u8| { - net_address_port_0 - + 6 * (ix as u16 + 1) - + if cfg!(feature = "ABCI") { - 0 - } else { - // The ABCI++ ports at `26670 + ABCI_PLUS_PLUS_PORT_OFFSET`, - // see `network` - setup::ABCI_PLUS_PLUS_PORT_OFFSET - } - }; + let get_first_port = |ix: u8| net_address_port_0 + 6 * (ix as u16 + 1); // 1. Setup 2 genesis validators let validator_0_alias = "validator-0"; @@ -1773,13 +1747,7 @@ fn test_genesis_validators() -> Result<()> { // We have to update the ports in the configs again, because the ones from // `join-network` use the defaults let update_config = |ix: u8, mut config: Config| { - let first_port = net_address_port_0 - + 6 * (ix as u16 + 1) - + if cfg!(feature = "ABCI") { - 0 - } else { - setup::ABCI_PLUS_PLUS_PORT_OFFSET - }; + let first_port = net_address_port_0 + 6 * (ix as u16 + 1); config.ledger.tendermint.p2p_address.set_port(first_port); config .ledger @@ -1829,11 +1797,7 @@ fn test_genesis_validators() -> Result<()> { let mut non_validator = run_as!(test, Who::NonValidator, Bin::Node, args, Some(40))?; non_validator.exp_string("Anoma ledger node started")?; - if !cfg!(feature = "ABCI") { - non_validator.exp_string("This node is a fullnode")?; - } else { - non_validator.exp_string("This node is not a validator")?; - } + non_validator.exp_string("This node is a fullnode")?; // 4. Submit a valid token transfer tx let validator_one_rpc = get_actor_rpc(&test, &Who::Validator(0)); diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index 28f1cf1825..b7e4c60e9c 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -55,10 +55,6 @@ pub struct Network { pub chain_id: ChainId, } -/// Offset the ports used in the network configuration by 1000 for ABCI++ to -/// avoid shared resources -pub const ABCI_PLUS_PLUS_PORT_OFFSET: u16 = 1000; - /// Add `num` validators to the genesis config. Note that called from inside /// the [`network`]'s first argument's closure, there is 1 validator already /// present to begin with, so e.g. `add_validators(1, _)` will configure a @@ -86,15 +82,7 @@ pub fn add_validators(num: u8, mut genesis: GenesisConfig) -> GenesisConfig { validator.intent_gossip_seed = None; let mut net_address = net_address_0; // 6 ports for each validator - let first_port = net_address_port_0 - + 6 * (ix as u16 + 1) - + if cfg!(feature = "ABCI") { - 0 - } else { - // The ABCI++ ports at `26670 + ABCI_PLUS_PLUS_PORT_OFFSET`, - // see `network` - ABCI_PLUS_PLUS_PORT_OFFSET - }; + let first_port = net_address_port_0 + 6 * (ix as u16 + 1); net_address.set_port(first_port); validator.net_address = Some(net_address.to_string()); let name = format!("validator-{}", ix + 1); @@ -122,23 +110,10 @@ pub fn network( let test_dir = TestDir::new(); // Open the source genesis file - let mut genesis = genesis_config::open_genesis_config( + let genesis = genesis_config::open_genesis_config( working_dir.join(SINGLE_NODE_NET_GENESIS), ); - if !cfg!(feature = "ABCI") { - // The ABCI ports start at `26670`, ABCI++ at `26670 + - // ABCI_PLUS_PLUS_PORT_OFFSET`to avoid using shared resources with ABCI - // feature if running at the same time. - let validator_0 = genesis.validator.get_mut("validator-0").unwrap(); - let mut net_address_0 = - SocketAddr::from_str(validator_0.net_address.as_ref().unwrap()) - .unwrap(); - let current_port = net_address_0.port(); - net_address_0.set_port(current_port + ABCI_PLUS_PLUS_PORT_OFFSET); - validator_0.net_address = Some(net_address_0.to_string()); - }; - // Run the provided function on it let genesis = update_genesis(genesis); @@ -429,16 +404,17 @@ impl Test { pub fn working_dir() -> PathBuf { let working_dir = fs::canonicalize("..").unwrap(); - if cfg!(feature = "ABCI") { - // Check that tendermint is on $PATH - Command::new("which").arg("tendermint").assert().success(); - std::env::var("TENDERMINT") - .expect_err("The env variable TENDERMINT must **not** be set"); - } else { - std::env::var("TENDERMINT").expect( - "The env variable TENDERMINT must be set and point to a local \ - build of the tendermint abci++ branch", - ); + // Check that tendermint is either on $PATH or `TENDERMINT` env var is set + if std::env::var("TENDERMINT").is_err() { + Command::new("which") + .arg("tendermint") + .assert() + .try_success() + .expect( + "The env variable TENDERMINT must be set and point to a local \ + build of the tendermint abci++ branch, or the tendermint \ + binary must be on PATH", + ); } working_dir } From 87f162fe1ebd175433bff71db3858e6149d4202b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 27 Jul 2022 18:37:17 +0200 Subject: [PATCH 06/17] make: remove "*-abci-plus-plus" --- Makefile | 93 ++------------------------------------------------------ 1 file changed, 2 insertions(+), 91 deletions(-) diff --git a/Makefile b/Makefile index ea42642e83..3474f6c8e6 100644 --- a/Makefile +++ b/Makefile @@ -19,20 +19,11 @@ audit-ignores += RUSTSEC-2021-0076 build: $(cargo) build -build-abci-plus-plus: - $(cargo) build --no-default-features --features "ABCI-plus-plus" - build-test: $(cargo) build --tests -build-test-abci-plus-plus: - $(cargo) build --tests --no-default-features --features "ABCI-plus-plus" - build-release: - ANOMA_DEV=false $(cargo) build --release --package namada_apps --manifest-path Cargo.toml --features "ABCI" - -build-release-abci-plus-plus: - ANOMA_DEV=false $(cargo) build --release --package namada_apps --no-default-features --features "ABCI-plus-plus" + ANOMA_DEV=false $(cargo) build --release --package namada_apps --manifest-path Cargo.toml check-release: ANOMA_DEV=false $(cargo) check --release --package namada_apps @@ -56,43 +47,14 @@ check: make -C $(wasms_for_tests) check && \ $(foreach wasm,$(wasm_templates),$(check-wasm) && ) true -check-abci-plus-plus: - $(cargo) check --no-default-features --features "ABCI-plus-plus" - clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets -- -D warnings -clippy-wasm-abci-plus-plus = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets --no-default-features --features "ABCI-plus-plus" -- -D warnings - clippy: ANOMA_DEV=false $(cargo) +$(nightly) clippy --all-targets -- -D warnings && \ make -C $(wasms) clippy && \ make -C $(wasms_for_tests) clippy && \ $(foreach wasm,$(wasm_templates),$(clippy-wasm) && ) true -clippy-abci-plus-plus: - ANOMA_DEV=false $(cargo) +$(nightly) clippy --all-targets \ - --manifest-path ./apps/Cargo.toml \ - --no-default-features \ - --features "std testing ABCI-plus-plus" && \ - $(cargo) +$(nightly) clippy --all-targets \ - --manifest-path ./proof_of_stake/Cargo.toml \ - --features "testing" && \ - $(cargo) +$(nightly) clippy --all-targets \ - --manifest-path ./shared/Cargo.toml \ - --no-default-features \ - --features "testing wasm-runtime ABCI-plus-plus ibc-mocks" && \ - $(cargo) +$(nightly) clippy --all-targets \ - --manifest-path ./tests/Cargo.toml \ - --no-default-features \ - --features "wasm-runtime ABCI-plus-plus namada_apps/ABCI-plus-plus" && \ - $(cargo) +$(nightly) clippy \ - --all-targets \ - --manifest-path ./vm_env/Cargo.toml \ - --no-default-features \ - --features "ABCI-plus-plus" && \ - make -C $(wasms) clippy && \ - $(foreach wasm,$(wasm_templates),$(clippy-wasm) && ) true - clippy-fix: $(cargo) +$(nightly) clippy --fix -Z unstable-options --all-targets --allow-dirty --allow-staged @@ -106,10 +68,6 @@ run-ledger: # runs the node $(cargo) run --bin namadan -- ledger run -run-ledger-abci-plus-plus: - # runs the node - $(cargo) run --bin namadan --no-default-features --features "ABCI-plus-plus" -- ledger run - run-gossip: # runs the node gossip node $(cargo) run --bin namadan -- gossip run @@ -118,10 +76,6 @@ reset-ledger: # runs the node $(cargo) run --bin namadan -- ledger reset -reset-ledger-abci-plus-plus: - # runs the node - $(cargo) run --bin namadan --no-default-features --features "ABCI-plus-plus" -- ledger reset - audit: $(cargo) audit $(foreach ignore,$(audit-ignores), --ignore $(ignore)) @@ -133,51 +87,8 @@ test-e2e: --test-threads=1 \ -Z unstable-options --report-time -test-e2e-abci-plus-plus: - RUST_BACKTRACE=1 $(cargo) test e2e \ - --manifest-path ./tests/Cargo.toml \ - --no-default-features \ - --features "wasm-runtime ABCI-plus-plus namada_apps/ABCI-plus-plus" \ - -- \ - --test-threads=1 \ - -Z unstable-options --report-time - -test-unit-abci-plus-plus: - $(cargo) test \ - --manifest-path ./apps/Cargo.toml \ - --no-default-features \ - --features "testing std ABCI-plus-plus" \ - -- \ - -Z unstable-options --report-time && \ - $(cargo) test \ - --manifest-path \ - ./proof_of_stake/Cargo.toml \ - --features "testing" \ - -- \ - -Z unstable-options --report-time && \ - $(cargo) test \ - --manifest-path ./shared/Cargo.toml \ - --no-default-features \ - --features "testing wasm-runtime ABCI-plus-plus ibc-mocks" \ - -- \ - -Z unstable-options --report-time && \ - $(cargo) test \ - --manifest-path ./tests/Cargo.toml \ - --no-default-features \ - --features "wasm-runtime ABCI-plus-plus namada_apps/ABCI-plus-plus" \ - -- \ - --skip e2e \ - -Z unstable-options --report-time && \ - $(cargo) test \ - --manifest-path ./vm_env/Cargo.toml \ - --no-default-features \ - --features "ABCI-plus-plus" \ - -- \ - -Z unstable-options --report-time - test-unit: - $(cargo) test --no-default-features \ - --features "wasm-runtime ABCI ibc-mocks-abci" \ + $(cargo) test \ -- \ --skip e2e \ -Z unstable-options --report-time From f4092ac4aa8c30eff2e99aea7f3f94ba2cf070bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 28 Jul 2022 15:44:29 +0200 Subject: [PATCH 07/17] shell: process transaction when `ProcessProposal` hasn't (non-validator) --- .../lib/node/ledger/shell/process_proposal.rs | 17 +++-- apps/src/lib/node/ledger/shims/abcipp_shim.rs | 70 +++++++++++++++++-- 2 files changed, 74 insertions(+), 13 deletions(-) diff --git a/apps/src/lib/node/ledger/shell/process_proposal.rs b/apps/src/lib/node/ledger/shell/process_proposal.rs index 1108663372..f12b16d9eb 100644 --- a/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -28,13 +28,7 @@ where &mut self, req: RequestProcessProposal, ) -> ResponseProcessProposal { - let tx_results: Vec = req - .txs - .iter() - .map(|tx_bytes| { - ExecTxResult::from(self.process_single_tx(tx_bytes)) - }) - .collect(); + let tx_results = self.process_txs(&req.txs); ResponseProcessProposal { status: if tx_results.iter().any(|res| res.code > 3) { @@ -47,6 +41,15 @@ where } } + /// Check all the given txs. + pub fn process_txs(&mut self, txs: &[Vec]) -> Vec { + txs.iter() + .map(|tx_bytes| { + ExecTxResult::from(self.process_single_tx(tx_bytes)) + }) + .collect() + } + /// Checks if the Tx can be deserialized from bytes. Checks the fees and /// signatures of the fee payer for a transaction if it is a wrapper tx. /// diff --git a/apps/src/lib/node/ledger/shims/abcipp_shim.rs b/apps/src/lib/node/ledger/shims/abcipp_shim.rs index 59abc3d1a9..f52459741d 100644 --- a/apps/src/lib/node/ledger/shims/abcipp_shim.rs +++ b/apps/src/lib/node/ledger/shims/abcipp_shim.rs @@ -5,6 +5,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use futures::future::FutureExt; +use tendermint_proto::abci::ResponseFinalizeBlock; use tokio::sync::mpsc::UnboundedSender; use tower::Service; use tower_abci::{BoxError, Request as Req, Response as Resp}; @@ -21,7 +22,9 @@ use crate::config; #[derive(Debug)] pub struct AbcippShim { service: Shell, - processed_txs: Vec, + /// This is `Some` only when `ProcessProposal` request is received before + /// `FinalizeBlock`, which is optional for non-validator nodes. + processed_txs: Option>, shell_recv: std::sync::mpsc::Receiver<( Req, tokio::sync::oneshot::Sender>, @@ -52,7 +55,7 @@ impl AbcippShim { vp_wasm_compilation_cache, tx_wasm_compilation_cache, ), - processed_txs: vec![], + processed_txs: None, shell_recv, }, AbciService { shell_send }, @@ -71,13 +74,17 @@ impl AbcippShim { .map_err(Error::from) .and_then(|res| match res { Response::ProcessProposal(resp) => { + self.processed_txs = + Some(Vec::with_capacity(txs.len())); + let processed_txs = + self.processed_txs.as_mut().unwrap(); for (result, tx) in resp .tx_results .iter() .map(TxResult::from) .zip(txs.into_iter()) { - self.processed_txs + processed_txs .push(ProcessedTx { tx, result }); } Ok(Resp::ProcessProposal(resp)) @@ -86,16 +93,67 @@ impl AbcippShim { }) } Req::FinalizeBlock(block) => { - let mut txs = vec![]; - std::mem::swap(&mut txs, &mut self.processed_txs); + let (txs, processing_results) = + match self.processed_txs.take() { + Some(processed_txs) => { + // When there are processed_txs from + // `ProcessProposal`, we don't need to add + // processing + // results again + (processed_txs, None) + } + None => { + // When there are no processed txs, it means + // that `ProcessProposal` request has not been + // received and so we need to process + // transactions first in the same way as + // `ProcessProposal`. + let unprocessed_txs = block.txs.clone(); + let processing_results = + self.service.process_txs(&block.txs); + let mut txs = + Vec::with_capacity(unprocessed_txs.len()); + for (result, tx) in processing_results + .iter() + .map(TxResult::from) + .zip(unprocessed_txs.into_iter()) + { + txs.push(ProcessedTx { tx, result }); + } + // Then we also have to add the processing + // result events to the `FinalizeBlock` + // tx_results + (txs, Some(processing_results)) + } + }; + let mut finalize_req: FinalizeBlock = block.into(); finalize_req.txs = txs; + self.service .call(Request::FinalizeBlock(finalize_req)) .map_err(Error::from) .and_then(|res| match res { Response::FinalizeBlock(resp) => { - Ok(Resp::FinalizeBlock(resp.into())) + let mut resp: ResponseFinalizeBlock = + resp.into(); + + // Add processing results, if any + if let Some(processing_results) = + processing_results + { + for (tx_result, processing_result) in resp + .tx_results + .iter_mut() + .zip(processing_results) + { + tx_result + .events + .extend(processing_result.events); + } + } + + Ok(Resp::FinalizeBlock(resp)) } _ => Err(Error::ConvertResp(res)), }) From 7c32a5febdcbe2c516fea05d4b1d6b9cb1a562f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 28 Jul 2022 16:00:54 +0200 Subject: [PATCH 08/17] test/e2e/ledger: enable ignored tests for ABCI++ workaround --- tests/src/e2e/ledger_tests.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index c453c13cf4..552e675e67 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -62,8 +62,6 @@ fn run_ledger() -> Result<()> { /// 1. Run 2 genesis validator ledger nodes and 1 non-validator node /// 2. Submit a valid token transfer tx /// 3. Check that all the nodes processed the tx with the same result -/// TODO: run this test once https://github.com/tendermint/tendermint/issues/8840 is fixed -#[ignore] #[test] fn test_node_connectivity() -> Result<()> { // Setup 2 genesis validator nodes @@ -85,6 +83,10 @@ fn test_node_connectivity() -> Result<()> { non_validator.exp_string("Anoma ledger node started")?; non_validator.exp_string("This node is a fullnode")?; + let bg_validator_0 = validator_0.background(); + let bg_validator_1 = validator_1.background(); + let bg_non_validator = non_validator.background(); + // 2. Submit a valid token transfer tx let validator_one_rpc = get_actor_rpc(&test, &Who::Validator(0)); let tx_args = [ @@ -111,6 +113,10 @@ fn test_node_connectivity() -> Result<()> { client.assert_success(); // 3. Check that all the nodes processed the tx with the same result + let mut validator_0 = bg_validator_0.foreground(); + let mut validator_1 = bg_validator_1.foreground(); + let mut non_validator = bg_non_validator.foreground(); + let expected_result = "all VPs accepted transaction"; validator_0.exp_string(expected_result)?; validator_1.exp_string(expected_result)?; @@ -1500,8 +1506,6 @@ fn generate_proposal_json( /// 3. Setup and start the 2 genesis validator nodes and a non-validator node /// 4. Submit a valid token transfer tx from one validator to the other /// 5. Check that all the nodes processed the tx with the same result -/// TODO: run this test once https://github.com/tendermint/tendermint/issues/8840 is fixed -#[ignore] #[test] fn test_genesis_validators() -> Result<()> { use std::collections::HashMap; @@ -1799,6 +1803,10 @@ fn test_genesis_validators() -> Result<()> { non_validator.exp_string("Anoma ledger node started")?; non_validator.exp_string("This node is a fullnode")?; + let bg_validator_0 = validator_0.background(); + let bg_validator_1 = validator_1.background(); + let bg_non_validator = non_validator.background(); + // 4. Submit a valid token transfer tx let validator_one_rpc = get_actor_rpc(&test, &Who::Validator(0)); let tx_args = [ @@ -1826,6 +1834,10 @@ fn test_genesis_validators() -> Result<()> { client.assert_success(); // 3. Check that all the nodes processed the tx with the same result + let mut validator_0 = bg_validator_0.foreground(); + let mut validator_1 = bg_validator_1.foreground(); + let mut non_validator = bg_non_validator.foreground(); + let expected_result = "all VPs accepted transaction"; validator_0.exp_string(expected_result)?; validator_1.exp_string(expected_result)?; From c856157e34edc41aafcbe486add85951fbda53ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 28 Jul 2022 16:14:30 +0200 Subject: [PATCH 09/17] scripts/get_tendermint: update for ABCI++ temp fork release --- scripts/get_tendermint.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/get_tendermint.sh b/scripts/get_tendermint.sh index 8ad0498304..8e74d3f851 100755 --- a/scripts/get_tendermint.sh +++ b/scripts/get_tendermint.sh @@ -4,11 +4,13 @@ set -Eo pipefail # an examplary download-url # https://github.com/tendermint/tendermint/releases/download/v0.34.13/tendermint_0.34.13_linux_amd64.tar.gz -TM_MAJORMINOR="0.34" -TM_PATCH="13" -TM_REPO="https://github.com/tendermint/tendermint" +# https://github.com/heliaxdev/tendermint/releases/download/v0.1.1-abcipp/tendermint_0.1.0-abcipp_darwin_amd64.tar.gz +TM_MAJORMINOR="0.1" +TM_PATCH="1" +TM_SUFFIX="-abcipp" +TM_REPO="https://github.com/heliaxdev/tendermint" -TM_VERSION="${TM_MAJORMINOR}.${TM_PATCH}" +TM_VERSION="${TM_MAJORMINOR}.${TM_PATCH}${TM_SUFFIX}" TARGET_PATH="/usr/local/bin" TMP_PATH="/tmp" From 67eee8c17165ead6476272b97a49149e7816c994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 29 Jul 2022 14:41:28 +0200 Subject: [PATCH 10/17] ledger: refactor tx_queue --- .../lib/node/ledger/shell/finalize_block.rs | 9 +++--- apps/src/lib/node/ledger/shell/mod.rs | 14 +++----- .../lib/node/ledger/shell/process_proposal.rs | 15 ++++++--- shared/src/types/storage.rs | 32 +++---------------- 4 files changed, 24 insertions(+), 46 deletions(-) diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index 6afba892e1..5db7e8b38d 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -399,7 +399,6 @@ where } response.events.push(tx_event); } - self.reset_tx_queue_iter(); if new_epoch { self.update_epoch(&mut response); @@ -577,7 +576,7 @@ mod test_finalize_block { // verify that the queue of wrapper txs to be processed is correct let mut valid_tx = valid_wrappers.iter(); let mut counter = 0; - while let Some(wrapper) = shell.next_wrapper() { + for wrapper in shell.iter_tx_queue() { // we cannot easily implement the PartialEq trait for WrapperTx // so we check the hashes of the inner txs for equality assert_eq!( @@ -636,7 +635,7 @@ mod test_finalize_block { assert_eq!(code, &String::from(ErrorCodes::InvalidTx)); } // check that the corresponding wrapper tx was removed from the queue - assert!(shell.next_wrapper().is_none()); + assert!(shell.storage.tx_queue.is_empty()); } /// Test that if a tx is undecryptable, it is applied @@ -692,7 +691,7 @@ mod test_finalize_block { assert!(log.contains("Transaction could not be decrypted.")) } // check that the corresponding wrapper tx was removed from the queue - assert!(shell.next_wrapper().is_none()); + assert!(shell.storage.tx_queue.is_empty()); } /// Test that the wrapper txs are queued in the order they @@ -809,7 +808,7 @@ mod test_finalize_block { let mut txs = valid_txs.iter(); let mut counter = 0; - while let Some(wrapper) = shell.next_wrapper() { + for wrapper in shell.iter_tx_queue() { assert_eq!( wrapper.tx_hash, txs.next().expect("Test failed").tx_hash diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index 2d6134dbb1..d93ec23c56 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -316,15 +316,10 @@ where } } - /// Iterate lazily over the wrapper txs in order - fn next_wrapper(&mut self) -> Option<&WrapperTx> { - self.storage.tx_queue.lazy_next() - } - - /// If we reject the decrypted txs because they were out of - /// order, reset the iterator. - pub fn reset_tx_queue_iter(&mut self) { - self.storage.tx_queue.rewind() + /// Iterate over the wrapper txs in order + #[allow(dead_code)] + fn iter_tx_queue(&mut self) -> impl Iterator { + self.storage.tx_queue.iter() } /// Load the Merkle root hash and the height of the last committed block, if @@ -793,7 +788,6 @@ mod test_utils { #[cfg(test)] pub fn enqueue_tx(&mut self, wrapper: WrapperTx) { self.shell.storage.tx_queue.push(wrapper); - self.shell.reset_tx_queue_iter(); } } diff --git a/apps/src/lib/node/ledger/shell/process_proposal.rs b/apps/src/lib/node/ledger/shell/process_proposal.rs index f12b16d9eb..ac09f8863a 100644 --- a/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -42,10 +42,13 @@ where } /// Check all the given txs. - pub fn process_txs(&mut self, txs: &[Vec]) -> Vec { + pub fn process_txs(&self, txs: &[Vec]) -> Vec { + let mut tx_queue_iter = self.storage.tx_queue.iter(); txs.iter() .map(|tx_bytes| { - ExecTxResult::from(self.process_single_tx(tx_bytes)) + ExecTxResult::from( + self.process_single_tx(tx_bytes, &mut tx_queue_iter), + ) }) .collect() } @@ -68,7 +71,11 @@ where /// INVARIANT: Any changes applied in this method must be reverted if the /// proposal is rejected (unless we can simply overwrite them in the /// next block). - pub(crate) fn process_single_tx(&mut self, tx_bytes: &[u8]) -> TxResult { + pub(crate) fn process_single_tx<'a>( + &self, + tx_bytes: &[u8], + tx_queue_iter: &mut impl Iterator, + ) -> TxResult { let tx = match Tx::try_from(tx_bytes) { Ok(tx) => tx, Err(_) => { @@ -102,7 +109,7 @@ where is coming soon to a blockchain near you. Patience." .into(), }, - TxType::Decrypted(tx) => match self.next_wrapper() { + TxType::Decrypted(tx) => match tx_queue_iter.next() { Some(wrapper) => { if wrapper.tx_hash != tx.hash_commitment() { TxResult { diff --git a/shared/src/types/storage.rs b/shared/src/types/storage.rs index 028d46470c..fc87bc8d51 100644 --- a/shared/src/types/storage.rs +++ b/shared/src/types/storage.rs @@ -681,51 +681,29 @@ impl Epochs { #[cfg(feature = "ferveo-tpke")] #[derive(Default, Debug, Clone, BorshDeserialize, BorshSerialize)] /// Wrapper txs to be decrypted in the next block proposal -pub struct TxQueue { - /// Index of next wrapper_tx to fetch from storage - next_wrapper: usize, - /// The actual wrappers - queue: std::collections::VecDeque, -} +pub struct TxQueue(std::collections::VecDeque); #[cfg(feature = "ferveo-tpke")] impl TxQueue { /// Add a new wrapper at the back of the queue pub fn push(&mut self, wrapper: WrapperTx) { - self.queue.push_back(wrapper); + self.0.push_back(wrapper); } /// Remove the wrapper at the head of the queue pub fn pop(&mut self) -> Option { - self.queue.pop_front() - } - - /// Iterate lazily over the queue. Finds the next value and advances the - /// lazy iterator. - #[allow(dead_code)] - pub fn lazy_next(&mut self) -> Option<&WrapperTx> { - let next = self.queue.get(self.next_wrapper); - if self.next_wrapper < self.queue.len() { - self.next_wrapper += 1; - } - next - } - - /// Reset the iterator to the head of the queue - pub fn rewind(&mut self) { - self.next_wrapper = 0; + self.0.pop_front() } /// Get an iterator over the queue - #[allow(dead_code)] pub fn iter(&self) -> impl std::iter::Iterator { - self.queue.iter() + self.0.iter() } /// Check if there are any txs in the queue #[allow(dead_code)] pub fn is_empty(&self) -> bool { - self.queue.is_empty() + self.0.is_empty() } } From 43aa815b84a2a29b0ef62e994f7acf26455ed9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 29 Jul 2022 14:42:24 +0200 Subject: [PATCH 11/17] ledger: make prepare_proposal and process_proposal stateless --- .../lib/node/ledger/shell/finalize_block.rs | 3 + .../lib/node/ledger/shell/prepare_proposal.rs | 10 +- .../lib/node/ledger/shell/process_proposal.rs | 2 +- apps/src/lib/node/ledger/shims/abcipp_shim.rs | 105 ++++++------------ 4 files changed, 38 insertions(+), 82 deletions(-) diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index 5db7e8b38d..1f758a2f2e 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -45,6 +45,9 @@ where &mut self, req: shim::request::FinalizeBlock, ) -> Result { + // reset gas meter before we start + self.gas_meter.reset(); + let mut response = shim::response::FinalizeBlock::default(); // begin the next block and check if a new epoch began let (height, new_epoch) = diff --git a/apps/src/lib/node/ledger/shell/prepare_proposal.rs b/apps/src/lib/node/ledger/shell/prepare_proposal.rs index 001d2eb6b3..7c15180d2c 100644 --- a/apps/src/lib/node/ledger/shell/prepare_proposal.rs +++ b/apps/src/lib/node/ledger/shell/prepare_proposal.rs @@ -20,13 +20,9 @@ where /// the proposal is rejected (unless we can simply overwrite /// them in the next block). pub fn prepare_proposal( - &mut self, + &self, req: RequestPrepareProposal, ) -> response::PrepareProposal { - // We can safely reset meter, because if the block is rejected, - // we'll reset again on the next proposal, until the - // proposal is accepted - self.gas_meter.reset(); let txs = if let ShellMode::Validator { .. } = self.mode { // TODO: This should not be hardcoded let privkey = ::G2Affine::prime_subgroup_generator(); @@ -127,7 +123,7 @@ mod test_prepare_proposal { /// proposed block. #[test] fn test_prepare_proposal_rejects_non_wrapper_tx() { - let (mut shell, _) = TestShell::new(); + let (shell, _) = TestShell::new(); let tx = Tx::new( "wasm_code".as_bytes().to_owned(), Some("transaction_data".as_bytes().to_owned()), @@ -148,7 +144,7 @@ mod test_prepare_proposal { /// we simply exclude it from the proposal #[test] fn test_error_in_processing_tx() { - let (mut shell, _) = TestShell::new(); + let (shell, _) = TestShell::new(); let keypair = gen_keypair(); let tx = Tx::new( "wasm_code".as_bytes().to_owned(), diff --git a/apps/src/lib/node/ledger/shell/process_proposal.rs b/apps/src/lib/node/ledger/shell/process_proposal.rs index ac09f8863a..25375244ba 100644 --- a/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -25,7 +25,7 @@ where /// included txs violates the order decided upon in the previous /// block. pub fn process_proposal( - &mut self, + &self, req: RequestProcessProposal, ) -> ResponseProcessProposal { let tx_results = self.process_txs(&req.txs); diff --git a/apps/src/lib/node/ledger/shims/abcipp_shim.rs b/apps/src/lib/node/ledger/shims/abcipp_shim.rs index f52459741d..ffe90c1d61 100644 --- a/apps/src/lib/node/ledger/shims/abcipp_shim.rs +++ b/apps/src/lib/node/ledger/shims/abcipp_shim.rs @@ -22,9 +22,6 @@ use crate::config; #[derive(Debug)] pub struct AbcippShim { service: Shell, - /// This is `Some` only when `ProcessProposal` request is received before - /// `FinalizeBlock`, which is optional for non-validator nodes. - processed_txs: Option>, shell_recv: std::sync::mpsc::Receiver<( Req, tokio::sync::oneshot::Sender>, @@ -55,7 +52,6 @@ impl AbcippShim { vp_wasm_compilation_cache, tx_wasm_compilation_cache, ), - processed_txs: None, shell_recv, }, AbciService { shell_send }, @@ -67,65 +63,30 @@ impl AbcippShim { pub fn run(mut self) { while let Ok((req, resp_sender)) = self.shell_recv.recv() { let resp = match req { - Req::ProcessProposal(proposal) => { - let txs = proposal.txs.clone(); - self.service - .call(Request::ProcessProposal(proposal)) - .map_err(Error::from) - .and_then(|res| match res { - Response::ProcessProposal(resp) => { - self.processed_txs = - Some(Vec::with_capacity(txs.len())); - let processed_txs = - self.processed_txs.as_mut().unwrap(); - for (result, tx) in resp - .tx_results - .iter() - .map(TxResult::from) - .zip(txs.into_iter()) - { - processed_txs - .push(ProcessedTx { tx, result }); - } - Ok(Resp::ProcessProposal(resp)) - } - _ => unreachable!(), - }) - } + Req::ProcessProposal(proposal) => self + .service + .call(Request::ProcessProposal(proposal)) + .map_err(Error::from) + .and_then(|res| match res { + Response::ProcessProposal(resp) => { + Ok(Resp::ProcessProposal(resp)) + } + _ => unreachable!(), + }), Req::FinalizeBlock(block) => { - let (txs, processing_results) = - match self.processed_txs.take() { - Some(processed_txs) => { - // When there are processed_txs from - // `ProcessProposal`, we don't need to add - // processing - // results again - (processed_txs, None) - } - None => { - // When there are no processed txs, it means - // that `ProcessProposal` request has not been - // received and so we need to process - // transactions first in the same way as - // `ProcessProposal`. - let unprocessed_txs = block.txs.clone(); - let processing_results = - self.service.process_txs(&block.txs); - let mut txs = - Vec::with_capacity(unprocessed_txs.len()); - for (result, tx) in processing_results - .iter() - .map(TxResult::from) - .zip(unprocessed_txs.into_iter()) - { - txs.push(ProcessedTx { tx, result }); - } - // Then we also have to add the processing - // result events to the `FinalizeBlock` - // tx_results - (txs, Some(processing_results)) - } - }; + // Process transactions first in the same way as + // `ProcessProposal`. + let unprocessed_txs = block.txs.clone(); + let processing_results = + self.service.process_txs(&block.txs); + let mut txs = Vec::with_capacity(unprocessed_txs.len()); + for (result, tx) in processing_results + .iter() + .map(TxResult::from) + .zip(unprocessed_txs.into_iter()) + { + txs.push(ProcessedTx { tx, result }); + } let mut finalize_req: FinalizeBlock = block.into(); finalize_req.txs = txs; @@ -138,19 +99,15 @@ impl AbcippShim { let mut resp: ResponseFinalizeBlock = resp.into(); - // Add processing results, if any - if let Some(processing_results) = - processing_results + // Add processing results + for (tx_result, processing_result) in resp + .tx_results + .iter_mut() + .zip(processing_results) { - for (tx_result, processing_result) in resp - .tx_results - .iter_mut() - .zip(processing_results) - { - tx_result - .events - .extend(processing_result.events); - } + tx_result + .events + .extend(processing_result.events); } Ok(Resp::FinalizeBlock(resp)) From 84ab5441ae8f89f1abffb69f1d0bf7281b5b6251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 29 Jul 2022 14:42:49 +0200 Subject: [PATCH 12/17] ledger: debug log some ABCI++ requests --- apps/src/lib/node/ledger/mod.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/src/lib/node/ledger/mod.rs b/apps/src/lib/node/ledger/mod.rs index e84674b059..f71e73ea74 100644 --- a/apps/src/lib/node/ledger/mod.rs +++ b/apps/src/lib/node/ledger/mod.rs @@ -86,17 +86,20 @@ impl Shell { fn call(&mut self, req: Request) -> Result { match req { Request::InitChain(init) => { + tracing::debug!("Request InitChain"); self.init_chain(init).map(Response::InitChain) } Request::Info(_) => Ok(Response::Info(self.last_state())), Request::Query(query) => Ok(Response::Query(self.query(query))), Request::PrepareProposal(block) => { + tracing::debug!("Request PrepareProposal"); Ok(Response::PrepareProposal(self.prepare_proposal(block))) } Request::VerifyHeader(_req) => { Ok(Response::VerifyHeader(self.verify_header(_req))) } Request::ProcessProposal(block) => { + tracing::debug!("Request ProcessProposal"); Ok(Response::ProcessProposal(self.process_proposal(block))) } Request::RevertProposal(_req) => { @@ -105,14 +108,21 @@ impl Shell { Request::ExtendVote(_req) => { Ok(Response::ExtendVote(self.extend_vote(_req))) } - Request::VerifyVoteExtension(_req) => Ok( - Response::VerifyVoteExtension(self.verify_vote_extension(_req)), - ), + Request::VerifyVoteExtension(_req) => { + tracing::debug!("Request VerifyVoteExtension"); + Ok(Response::VerifyVoteExtension( + self.verify_vote_extension(_req), + )) + } Request::FinalizeBlock(finalize) => { + tracing::debug!("Request FinalizeBlock"); self.load_proposals(); self.finalize_block(finalize).map(Response::FinalizeBlock) } - Request::Commit(_) => Ok(Response::Commit(self.commit())), + Request::Commit(_) => { + tracing::debug!("Request Commit"); + Ok(Response::Commit(self.commit())) + } Request::Flush(_) => Ok(Response::Flush(Default::default())), Request::Echo(msg) => Ok(Response::Echo(response::Echo { message: msg.message, From 855d0db1fc1e36e97b35135b05c0beba74e8c79b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 29 Jul 2022 13:12:40 +0000 Subject: [PATCH 13/17] [ci] wasm checksums update --- wasm/checksums.json | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/wasm/checksums.json b/wasm/checksums.json index 1495d6f6f5..5d670022b7 100644 --- a/wasm/checksums.json +++ b/wasm/checksums.json @@ -1,19 +1,19 @@ { - "tx_bond.wasm": "tx_bond.302172cc7d0a7e2278ce58299809875f354925364b25c9b64e92461995c51950.wasm", - "tx_from_intent.wasm": "tx_from_intent.19099ad11a5f59272bd5dbd8b7bc7093ae66ae7a2b25034300f1b34d3e37ffd1.wasm", - "tx_ibc.wasm": "tx_ibc.9aec1969a37705f9ae5d6e95d13126e0f37e78171ef37c2f0fdd0eb16ac49270.wasm", - "tx_init_account.wasm": "tx_init_account.7a45233a98978c67ff005bf8a1fb8f3f7689a75f98684c1735617776f98fabad.wasm", - "tx_init_nft.wasm": "tx_init_nft.b0dd29e0e982c3bd04c7a8c4dcd0184d9d827df6a4211794dd74fbdced1e7430.wasm", - "tx_init_proposal.wasm": "tx_init_proposal.45be75dc2c22048dce23ae346c895b2be19737a39844416436aac62914847388.wasm", - "tx_init_validator.wasm": "tx_init_validator.5a7c9a3a115883359246a4145af11f748ded043b5b36d1cb71e54fb3ef169183.wasm", - "tx_mint_nft.wasm": "tx_mint_nft.fd8932515db71638263193930f60c14cec54c11e72e6ab40d8201d0247db0c1a.wasm", - "tx_transfer.wasm": "tx_transfer.9e51e5b48ba3ddee699fed334e14fe9a81b7e299b0cfcbf10482b9f784c092c2.wasm", - "tx_unbond.wasm": "tx_unbond.020d22fa306850b0a4aade96f711087d03568ed45276fff60226a80de47cc455.wasm", + "tx_bond.wasm": "tx_bond.71acaf1ff3a4ac1ce6550c4ce594cf70d684213769f45641be5cdb4b7321184e.wasm", + "tx_from_intent.wasm": "tx_from_intent.e18907b1fb0e1c4e4946228c0ec57838a783a5d88c6b3129d44935386693cee8.wasm", + "tx_ibc.wasm": "tx_ibc.38ee97db63b765f1639ee24dd3e7f264139f146a56f7c06edafde63eaecedade.wasm", + "tx_init_account.wasm": "tx_init_account.6be05f8ca240d9e978dfe6a1566b3860e07fa3aee334003fc5d85a5a1ae99cf7.wasm", + "tx_init_nft.wasm": "tx_init_nft.5f710b641c38cbe7822c2359bf7a764e864e952f4660ccff9b58b97fbaa4b3a2.wasm", + "tx_init_proposal.wasm": "tx_init_proposal.25666fc8fbf251bd4ad478cb968f1d50a8100a0a7aae0e3ee5e50e28304e8e3e.wasm", + "tx_init_validator.wasm": "tx_init_validator.2b1a4c947242ddddf94a491b8c571185f649913606bfa7d37f668ddc86fe1049.wasm", + "tx_mint_nft.wasm": "tx_mint_nft.9af8eea9219db09161b98405c18ea3c82db03b982f69a66ce1d117e64a715c3c.wasm", + "tx_transfer.wasm": "tx_transfer.87e4fba9d2476388e0f2b1d4bc00c396ac7b8b7b38d5079735fe53bc5984b583.wasm", + "tx_unbond.wasm": "tx_unbond.61f2ac46e7680ec35aba367ec908ac63aa43d6765cd07da932aa9ea45d77be46.wasm", "tx_update_vp.wasm": "tx_update_vp.00d828bdf510d92d971ca59015945c8c00f285a802a655451cc5ee87c5ee99bc.wasm", - "tx_vote_proposal.wasm": "tx_vote_proposal.b8aa22d6d22c31fa6c1f4619a81eaa43aa40c8865b91f71449a5f3c65b84eacf.wasm", - "tx_withdraw.wasm": "tx_withdraw.b8538e5acfc2945e98b76cc17eb11a03c545021e8f70cf6e5b436219e749b559.wasm", - "vp_nft.wasm": "vp_nft.d272e0c50f17c020fe806e03278e83377ec45b81e88432316ce836ee24605f6e.wasm", - "vp_testnet_faucet.wasm": "vp_testnet_faucet.79c1da702d67f464453af0b145872bba28913b029508f1257b4a22f69123ec1e.wasm", - "vp_token.wasm": "vp_token.04482a8132e91ab726b4a9027f44a84c885c36e3d608e9c4e153d0cfe4f88449.wasm", - "vp_user.wasm": "vp_user.e390d55fc2e797fcc4c43bd40b93ea1c3d58544d5f086301a0dbc38bd93388ba.wasm" + "tx_vote_proposal.wasm": "tx_vote_proposal.92ed628aca7856e2b0fe461c0a0a65c6f7c1f585ac542c10feceef0e4b9ce611.wasm", + "tx_withdraw.wasm": "tx_withdraw.fb54d108a6fe7c6db16e573110c4a9f52158ec993e04e5a06e1425b8dd676c54.wasm", + "vp_nft.wasm": "vp_nft.3421840146f8d2e6c3ce3a0d94bbb0dad6ef296c50e9d00744179d290f32745b.wasm", + "vp_testnet_faucet.wasm": "vp_testnet_faucet.1b37ab6939280fbb54512918053362fae34e3db74f029ef31c9f08e767539afb.wasm", + "vp_token.wasm": "vp_token.08dcec2d3ecb0942d0a244bbd176f9a42424ec09544120db1b30c0d97ed7dbb1.wasm", + "vp_user.wasm": "vp_user.404f089f0c73fcf906f7d6059d74c6bab3e2e3d3a108394503bbc22588ff95b9.wasm" } \ No newline at end of file From 818a36a6c10d858b3fcde09d76e6e42243fa0770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 1 Aug 2022 17:28:01 +0200 Subject: [PATCH 14/17] update the changelog config to namada repo --- .changelog/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/config.toml b/.changelog/config.toml index fdc4671ed2..551bae0e61 100644 --- a/.changelog/config.toml +++ b/.changelog/config.toml @@ -1,4 +1,4 @@ -project_url = 'https://github.com/anoma/anoma' +project_url = 'https://github.com/anoma/namada' # Settings related to components/sub-modules. Only relevant if you make use of # components/sub-modules. From 80fa394fa711dc4d51376edbd466ca7f0ac3af26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 25 Jul 2022 12:49:18 +0200 Subject: [PATCH 15/17] shell: remove TM consensus evidence parameters --- .../lib/node/ledger/shell/finalize_block.rs | 12 --------- apps/src/lib/node/ledger/shell/init_chain.rs | 9 ------- apps/src/lib/node/ledger/shell/mod.rs | 3 +-- apps/src/lib/node/ledger/shell/queries.rs | 27 ------------------- 4 files changed, 1 insertion(+), 50 deletions(-) diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index 1f758a2f2e..592b5d6cf8 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -488,18 +488,6 @@ where let update = ValidatorUpdate { pub_key, power }; response.validator_updates.push(update); }); - - // Update evidence parameters - let (epoch_duration, _gas) = - parameters::read_epoch_parameter(&self.storage) - .expect("Couldn't read epoch duration parameters"); - let pos_params = self.storage.read_pos_params(); - let evidence_params = - self.get_evidence_params(&epoch_duration, &pos_params); - response.consensus_param_updates = Some(ConsensusParams { - evidence: Some(evidence_params), - ..response.consensus_param_updates.take().unwrap_or_default() - }); } } diff --git a/apps/src/lib/node/ledger/shell/init_chain.rs b/apps/src/lib/node/ledger/shell/init_chain.rs index a989338751..a86681fbb5 100644 --- a/apps/src/lib/node/ledger/shell/init_chain.rs +++ b/apps/src/lib/node/ledger/shell/init_chain.rs @@ -257,15 +257,6 @@ where ); ibc::init_genesis_storage(&mut self.storage); - let evidence_params = self.get_evidence_params( - &genesis.parameters.epoch_duration, - &genesis.pos_params, - ); - response.consensus_params = Some(ConsensusParams { - evidence: Some(evidence_params), - ..response.consensus_params.unwrap_or_default() - }); - // Set the initial validator set for validator in genesis.validators { let mut abci_validator = abci::ValidatorUpdate::default(); diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index d93ec23c56..16690c9e17 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -29,7 +29,7 @@ use namada::ledger::storage::write_log::WriteLog; use namada::ledger::storage::{ DBIter, Sha256Hasher, Storage, StorageHasher, DB, }; -use namada::ledger::{ibc, parameters, pos}; +use namada::ledger::{ibc, pos}; use namada::proto::{self, Tx}; use namada::types::chain::ChainId; use namada::types::key::*; @@ -50,7 +50,6 @@ use tendermint_proto::abci::{ RequestPrepareProposal, ValidatorUpdate, }; use tendermint_proto::crypto::public_key; -use tendermint_proto::types::ConsensusParams; use thiserror::Error; use tokio::sync::mpsc::UnboundedSender; use tower_abci::{request, response}; diff --git a/apps/src/lib/node/ledger/shell/queries.rs b/apps/src/lib/node/ledger/shell/queries.rs index a643501d9e..d50dd2405e 100644 --- a/apps/src/lib/node/ledger/shell/queries.rs +++ b/apps/src/lib/node/ledger/shell/queries.rs @@ -1,18 +1,13 @@ //! Shell methods for querying state -use std::cmp::max; use borsh::{BorshDeserialize, BorshSerialize}; use ferveo_common::TendermintValidator; -use namada::ledger::parameters::EpochDuration; -use namada::ledger::pos::PosParams; use namada::types::address::Address; use namada::types::key; use namada::types::key::dkg_session_keys::DkgPublicKey; use namada::types::storage::{Key, PrefixValue}; use namada::types::token::{self, Amount}; use tendermint_proto::crypto::{ProofOp, ProofOps}; -use tendermint_proto::google::protobuf; -use tendermint_proto::types::EvidenceParams; use super::*; use crate::node::ledger::response; @@ -263,28 +258,6 @@ where } } - pub fn get_evidence_params( - &self, - epoch_duration: &EpochDuration, - pos_params: &PosParams, - ) -> EvidenceParams { - // Minimum number of epochs before tokens are unbonded and can be - // withdrawn - let len_before_unbonded = max(pos_params.unbonding_len as i64 - 1, 0); - let max_age_num_blocks: i64 = - epoch_duration.min_num_of_blocks as i64 * len_before_unbonded; - let min_duration_secs = epoch_duration.min_duration.0 as i64; - let max_age_duration = Some(protobuf::Duration { - seconds: min_duration_secs * len_before_unbonded, - nanos: 0, - }); - EvidenceParams { - max_age_num_blocks, - max_age_duration, - ..EvidenceParams::default() - } - } - /// Lookup data about a validator from their protocol signing key #[allow(dead_code)] pub fn get_validator_from_protocol_pk( From cbcda142cbc9b5567423e16f0248f68fe93b5c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 25 Jul 2022 12:50:14 +0200 Subject: [PATCH 16/17] shell: skip and log outdated evidence in the shell --- apps/src/lib/node/ledger/shell/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index 16690c9e17..b4143cb970 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -410,6 +410,13 @@ where continue; } }; + if evidence_epoch + pos_params.unbonding_len <= current_epoch { + tracing::info!( + "Skipping outdated evidence from epoch \ + {evidence_epoch}" + ); + continue; + } let slash_type = match EvidenceType::from_i32(evidence.r#type) { Some(r#type) => match r#type { EvidenceType::DuplicateVote => { From 80e9916d12562f70d92575a73a916e348d4b9d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 25 Jul 2022 12:54:05 +0200 Subject: [PATCH 17/17] changelog: add #1248 --- .../unreleased/improvements/1248-remove-evidence-params.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/unreleased/improvements/1248-remove-evidence-params.md diff --git a/.changelog/unreleased/improvements/1248-remove-evidence-params.md b/.changelog/unreleased/improvements/1248-remove-evidence-params.md new file mode 100644 index 0000000000..97297a93e1 --- /dev/null +++ b/.changelog/unreleased/improvements/1248-remove-evidence-params.md @@ -0,0 +1,3 @@ +- Replace Tendermint consensus evidence parameters with + application level evidence filter for outdated evidence. + ([#1248](https://github.com/anoma/anoma/pull/1248)) \ No newline at end of file