Skip to content

Commit

Permalink
Add a trigger migration to enable a bug in ABCI error decoding (#321)
Browse files Browse the repository at this point in the history
This bug is needed to allow legacy behaviour while replaying old blocks.
It requires a new migration type to allow for modern behaviour to be
enabled by default, which we want moving forward.

---------

Co-authored-by: Felix C. Morency <[email protected]>
  • Loading branch information
hansl and fmorency authored Mar 2, 2023
1 parent d8fa144 commit 64eee77
Show file tree
Hide file tree
Showing 37 changed files with 527 additions and 159 deletions.
9 changes: 8 additions & 1 deletion Cargo.Bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2434,6 +2434,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
name = "ledger"
version = "0.1.0"
dependencies = [
"anyhow",
"clap 3.2.23",
"crc-any",
"hex",
Expand All @@ -2443,7 +2444,6 @@ dependencies = [
"lazy_static",
"many-cli-helpers",
"many-client",
"many-error",
"many-identity",
"many-identity-dsa",
"many-identity-hsm",
Expand Down Expand Up @@ -2625,6 +2625,7 @@ dependencies = [
"cbor-diag",
"clap 3.2.23",
"coset",
"either",
"hex",
"many-cli-helpers",
"many-client",
Expand Down Expand Up @@ -2660,19 +2661,22 @@ dependencies = [
"itertools",
"json5",
"lazy_static",
"linkme",
"many-cli-helpers",
"many-client",
"many-error",
"many-identity",
"many-identity-dsa",
"many-identity-webauthn",
"many-migration",
"many-modules",
"many-protocol",
"many-server",
"many-types",
"minicbor",
"num-integer",
"reqwest",
"serde_json",
"sha2 0.10.6",
"signal-hook",
"smol",
Expand All @@ -2689,8 +2693,11 @@ dependencies = [
name = "many-cli-helpers"
version = "0.1.0"
dependencies = [
"anyhow",
"clap 3.2.23",
"log-panics",
"many-error",
"minicbor",
"syslog-tracing",
"tracing",
"tracing-subscriber",
Expand Down
9 changes: 8 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"src/ledger-db",
"src/many",
"src/many-abci",
"src/many-cli-helpers",
"src/many-client",
"src/many-client-macros",
"src/many-error",
Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
## RUST SECTION ##
http_archive(
name = "rules_rust",
sha256 = "2466e5b2514772e84f9009010797b9cd4b51c1e6445bbd5b5e24848d90e6fb2e",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.18.0/rules_rust-v0.18.0.tar.gz"],
sha256 = "d125fb75432dc3b20e9b5a19347b45ec607fabe75f98c6c4ba9badaab9c193ce",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.17.0/rules_rust-v0.17.0.tar.gz"],
)

load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
Expand Down
26 changes: 25 additions & 1 deletion cargo-bazel-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "29c477db0ddbd26efaf43fc17fd1ad938aaabe8ef562107771b50dfda940092f",
"checksum": "4a8ec3192d1cce70eedb9f5b134da9a16bedce9424f0a77c724b58f803cfb799",
"crates": {
"addr2line 0.19.0": {
"name": "addr2line",
Expand Down Expand Up @@ -12145,6 +12145,10 @@
],
"deps": {
"common": [
{
"id": "anyhow 1.0.69",
"target": "anyhow"
},
{
"id": "clap 3.2.23",
"target": "clap"
Expand Down Expand Up @@ -13147,6 +13151,10 @@
"id": "coset 0.3.4",
"target": "coset"
},
{
"id": "either 1.8.1",
"target": "either"
},
{
"id": "hex 0.4.3",
"target": "hex"
Expand Down Expand Up @@ -13259,6 +13267,10 @@
"id": "lazy_static 1.4.0",
"target": "lazy_static"
},
{
"id": "linkme 0.3.7",
"target": "linkme"
},
{
"id": "many-abci 0.1.0",
"target": "build_script_build"
Expand All @@ -13275,6 +13287,10 @@
"id": "reqwest 0.11.14",
"target": "reqwest"
},
{
"id": "serde_json 1.0.93",
"target": "serde_json"
},
{
"id": "sha2 0.10.6",
"target": "sha2"
Expand Down Expand Up @@ -13364,6 +13380,10 @@
],
"deps": {
"common": [
{
"id": "anyhow 1.0.69",
"target": "anyhow"
},
{
"id": "clap 3.2.23",
"target": "clap"
Expand All @@ -13372,6 +13392,10 @@
"id": "log-panics 2.1.0",
"target": "log_panics"
},
{
"id": "minicbor 0.18.0",
"target": "minicbor"
},
{
"id": "syslog-tracing 0.1.0",
"target": "syslog_tracing"
Expand Down
1 change: 1 addition & 0 deletions docker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ filegroup(
"generate-allow-addrs.sh",
"update_config.sh",
"//staging:ledger-staging",
"//tests:abci-ledger-migrations",
"//tests:ledger-migrations",
],
)
Expand Down
10 changes: 10 additions & 0 deletions docker/Makefile.ledger
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
MIGRATIONS ?=
ABCI_MIGRATIONS ?=
ALLOW_ADDRS ?= false
STATE ?= "../staging/ledger_state.json5"

ENABLE_MIGRATIONS := false
ifdef MIGRATIONS
ENABLE_MIGRATIONS := true
endif
ENABLE_ABCI_MIGRATIONS := false
ifdef ABCI_MIGRATIONS
ENABLE_ABCI_MIGRATIONS := true
endif

include Makefile.common

Expand Down Expand Up @@ -41,6 +46,7 @@ genfiles-ledger/docker-compose.json: genfiles-common/jsonnet-docker docker-compo
--tla-code user=$$(id -u) \
--tla-code id_with_balances=\"$(ID_WITH_BALANCES)\" \
--tla-code enable_migrations=$(ENABLE_MIGRATIONS) \
--tla-code abci_migrations=$(ENABLE_ABCI_MIGRATIONS) \
--tla-code allow_addrs=$(ALLOW_ADDRS) \
-o /$@

Expand All @@ -56,8 +62,12 @@ genfiles-ledger/generate-tendermint-e2e-config:
genfiles-ledger/node%: genfiles-common/tendermint-docker genfiles-common/openssl-docker
mkdir -p "$@/tendermint"
rm -f "$@/migrations.json"
rm -f "$@/abci_migrations.json"
ifdef MIGRATIONS
cp "$(MIGRATIONS)" "$@/migrations.json"
endif
ifdef ABCI_MIGRATIONS
cp "$(ABCI_MIGRATIONS)" "$@/abci_migrations.json"
endif
docker run --user $$(id -u) --rm -v "${PWD}/$@/tendermint:/tendermint" bazel/docker:tendermint_image init validator
docker run --user $$(id -u) --rm -v ${PWD}/$@/:/export bazel/docker:openssl_image genpkey -algorithm Ed25519 -out /export/ledger.pem
Expand Down
15 changes: 11 additions & 4 deletions docker/docker-compose-ledger.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ local load_migrations(enable_migrations) =
else
[];

local load_abci_migrations(abci_migrations) =
if abci_migrations then
["--migrations-config=/genfiles/abci_migrations.json"]
else
[];

local generate_allow_addrs_flag(allow_addrs) =
if allow_addrs then
["--allow-addrs=/genfiles/allow_addrs.json5"]
else
[];

local abci(i, user, allow_addrs) = {
local abci(i, user, allow_addrs, abci_migrations) = {
image: "bazel/src/many-abci:many-abci-image",
ports: [ (8000 + i) + ":8000" ],
volumes: [ "./node" + i + ":/genfiles:ro" ],
Expand All @@ -38,7 +44,8 @@ local abci(i, user, allow_addrs) = {
"--many-pem", "/genfiles/abci.pem",
"--abci", "0.0.0.0:26658",
"--tendermint", "http://tendermint-" + i + ":26657/"
] + generate_allow_addrs_flag(allow_addrs),
] + load_abci_migrations(abci_migrations)
+ generate_allow_addrs_flag(allow_addrs),
depends_on: [ "ledger-" + i ],
};

Expand Down Expand Up @@ -74,10 +81,10 @@ local tendermint(i, user) = {
ports: [ "" + (26600 + i) + ":26600" ],
};

function(nb_nodes=4, user=1000, id_with_balances="", allow_addrs=false, enable_migrations=false) {
function(nb_nodes=4, user=1000, id_with_balances="", allow_addrs=false, enable_migrations=false, abci_migrations=false) {
version: '3',
services: {
["abci-" + i]: abci(i, user, allow_addrs) for i in std.range(0, nb_nodes - 1)
["abci-" + i]: abci(i, user, allow_addrs, abci_migrations) for i in std.range(0, nb_nodes - 1)
} + {
["ledger-" + i]: ledger(i, user, id_with_balances, enable_migrations) for i in std.range(0, nb_nodes - 1)
} + {
Expand Down
4 changes: 1 addition & 3 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ main() {
}

tmux new-session -s "$tmux_name" -n tendermint-ledger -d "TMHOME=\"$root_dir/ledger\" tendermint start 2>&1 | tee \"$root_dir/tendermint-ledger.log\""
tmux new-window -t "$tmux_name" -n tendermint-kvstore "TMHOME=\"$root_dir/kvstore\" tendermint start 2>&1 | tee \"$root_dir/tendermint-kvstore.log\""
# This makes sure the sessions remain opened when the command exits.
tmux setw remain-on-exit on
tmux new-window -t "$tmux_name" -n tendermint-kvstore -e SHELL=bash "TMHOME=\"$root_dir/kvstore\" tendermint start 2>&1 | tee \"$root_dir/tendermint-kvstore.log\""

tmux new-window -t "$tmux_name" -n ledger -e SHELL=bash "./target/debug/many-ledger -v -v --abci --addr 127.0.0.1:8001 --pem \"$pem_root/id1.pem\" --state ./staging/ledger_state.json5 --persistent \"$root_dir/ledger.db\" 2>&1 | tee \"$root_dir/many-ledger.log\""
tmux new-window -t "$tmux_name" -n ledger-abci "./target/debug/many-abci -v -v --many 127.0.0.1:8000 --many-app http://localhost:8001 --many-pem \"$pem_root/id2.pem\" --abci 127.0.0.1:26658 --tendermint http://127.0.0.1:26657/ 2>&1 | tee \"$root_dir/many-abci-ledger.log\""
Expand Down
1 change: 0 additions & 1 deletion src/ledger/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ rust_binary(
) + [
"//src/many-cli-helpers",
"//src/many-client",
"//src/many-error",
"//src/many-identity",
"//src/many-identity-dsa",
"//src/many-identity-hsm",
Expand Down
2 changes: 1 addition & 1 deletion src/ledger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ name = "ledger"
doc = false

[dependencies]
anyhow = "1.0.69"
clap = { version = "3.0.0", features = ["derive"] }
crc-any = "2.4.0"
hex = "0.4.3"
Expand All @@ -28,7 +29,6 @@ minicbor = { version = "0.18.0", features = ["derive", "std"] }
num-bigint = "0.4.3"
many-cli-helpers = { path = "../many-cli-helpers", version = "0.1.0" }
many-client = { path = "../many-client", version = "0.1.0" }
many-error = { path = "../many-error", version = "0.1.0" }
many-identity = { path = "../many-identity", version = "0.1.0", features = ["serde"] }
many-identity-dsa = { path = "../many-identity-dsa", version = "0.1.0", features = ["ed25519", "ecdsa"] }
many-identity-hsm = { path = "../many-identity-hsm", version = "0.1.0" }
Expand Down
Loading

0 comments on commit 64eee77

Please sign in to comment.