diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79c4f7b0..9cc167c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: run: | go test ./... cargo r --bin onomyd_only - cargo r --bin ics_with_interchain_security_cd + cargo r --bin ics_cdd cargo r --bin chain_upgrade cargo r --bin clean diff --git a/app/app.go b/app/app.go index 372df470..55eea47b 100644 --- a/app/app.go +++ b/app/app.go @@ -102,6 +102,7 @@ import ( v1_0_3_4 "github.com/onomyprotocol/onomy/app/upgrades/v1.0.3.4" v1_0_3_5 "github.com/onomyprotocol/onomy/app/upgrades/v1.0.3.5" v1_1_1 "github.com/onomyprotocol/onomy/app/upgrades/v1.1.1" + v1_1_2 "github.com/onomyprotocol/onomy/app/upgrades/v1.1.2" "github.com/onomyprotocol/onomy/docs" "github.com/onomyprotocol/onomy/x/dao" daoclient "github.com/onomyprotocol/onomy/x/dao/client" @@ -800,6 +801,7 @@ func (app *OnomyApp) setupUpgradeHandlers() { return app.mm.RunMigrations(ctx, app.configurator, fromVM) }, ) + app.UpgradeKeeper.SetUpgradeHandler(v1_1_2.Name, v1_1_2.UpgradeHandler) upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { diff --git a/app/upgrades/readme.md b/app/upgrades/readme.md index 57794207..62ba0625 100644 --- a/app/upgrades/readme.md +++ b/app/upgrades/readme.md @@ -4,8 +4,9 @@ This folder contains sub-folders for every chain upgrade. ## Version History -- v1.0.1 - IBC integration fix -- v1.0.3 - Hyperinflation fix -- v1.0.3.4 - OIP 6 Undelegate DAO from all validators -- v1.0.3.5 - OIP 6 Patch Subtract DAO Treasury from Staking Supply +- v1.1.2 - Fix that the treasury is actually subtracted from the staking supply - v1.1.1 - Removal of Gravity module and addition of provider module +- v1.0.3.5 - OIP 6 Patch Subtract DAO Treasury from Staking Supply +- v1.0.3.4 - OIP 6 Undelegate DAO from all validators +- v1.0.3 - Hyperinflation fix +- v1.0.1 - IBC integration fix diff --git a/app/upgrades/v1.1.2/upgrade.go b/app/upgrades/v1.1.2/upgrade.go new file mode 100644 index 00000000..08ee82dd --- /dev/null +++ b/app/upgrades/v1.1.2/upgrade.go @@ -0,0 +1,16 @@ +// Package v1_1_2 is contains chain upgrade of the corresponding version. +package v1_1_2 //nolint:revive,stylecheck // app version + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// Name is migration name. +const Name = "v1.1.2" + +// UpgradeHandler is an x/upgrade handler. +func UpgradeHandler(_ sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return vm, nil +} diff --git a/go.mod b/go.mod index 24e579b8..a078ad34 100644 --- a/go.mod +++ b/go.mod @@ -152,7 +152,7 @@ replace ( // are anomolous build errors unless a hash from an accepted merge commit specifically is used. //github.com/cosmos/cosmos-sdk => ../onomy-sdk // v0.45.16-ics-onomy - github.com/cosmos/cosmos-sdk => github.com/onomyprotocol/onomy-sdk v0.44.6-0.20230608164016-6a3986f84e54 + github.com/cosmos/cosmos-sdk => github.com/onomyprotocol/onomy-sdk v0.44.6-0.20230822174525-3949f4f75a37 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.28 google.golang.org/grpc => google.golang.org/grpc v1.33.2 diff --git a/go.sum b/go.sum index 809c333f..93f3d808 100644 --- a/go.sum +++ b/go.sum @@ -2200,8 +2200,8 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onomyprotocol/onomy-sdk v0.44.6-0.20230608164016-6a3986f84e54 h1:dQY1X5mHfft7vpx2J1ORa0zMld4pWRH4tasD6GXdgKY= -github.com/onomyprotocol/onomy-sdk v0.44.6-0.20230608164016-6a3986f84e54/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= +github.com/onomyprotocol/onomy-sdk v0.44.6-0.20230822174525-3949f4f75a37 h1:2/Q3vA04I+3TEfdRl9S86d2ksO3AlT4F57dlsV3nMjc= +github.com/onomyprotocol/onomy-sdk v0.44.6-0.20230822174525-3949f4f75a37/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 18e0344f..584d34d6 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -9,9 +9,9 @@ name = "common" path = "src/lib/common.rs" [dependencies] -clap = { version = "4.2", features = ["derive"] } +clap = { version = "4", features = ["derive"] } log = "0.4" #onomy_test_lib = { path = "./../../onomy_tests/onomy_test_lib" } -onomy_test_lib = { git = "https://github.com/pendulum-labs/onomy_tests", rev = "b15f4d2143ae8fe8314acd939fb77023bafbf0f5" } +onomy_test_lib = { git = "https://github.com/pendulum-labs/onomy_tests", rev = "47b5a635b8a57b3ce8c72092b4eef89ccddce167" } serde_json = "1.0" -tokio = "1.28" +tokio = "1" diff --git a/tests/README.md b/tests/README.md index 6611f96b..6cdbc0d2 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,4 +1,4 @@ -This uses a [super_orchestrator](https://github.com/AaronKutch/super_orchestrator) based test harness system with some middle level functionality supplied by [onomy_tests](https://github.com/pendulum-labs/onomy_tests). All tests should be run from the repository root (not from the ./test directory or anywhere else) by `cargo r --bin [test binary name]`. Run `cargo doc --open` to find developer functions. Dockerfiles used by the tests are in `tests/dockerfiles`, and various resources are located in `tests/logs`, `tests/resources`, and `tests/dockerfiles/dockerfile_resources`. +This uses a [super_orchestrator](https://github.com/AaronKutch/super_orchestrator) based test harness system with some middle level functionality supplied by [onomy_tests](https://github.com/pendulum-labs/onomy_tests). All tests should be run from the repository root (not from the ./test directory or anywhere else) by `cargo r --bin [test binary name]`. Run `cargo doc --open` to find developer functions. If a set of running containers stalls or you need to terminate them quickly, you do not want to Ctrl-C the main runner which will leave containers running in the background, instead run `cargo r --bin auto_exec_i -- --container-name [name of a container]` from a different terminal and it will find the container. You can Ctrl-C to terminate the container (and usually will terminate the rest if super_orchestrator was used correctly), and can Ctrl-C again to terminate auto_exec_i (or you can leave it to wait for another run of the container). diff --git a/tests/dockerfiles/.gitignore b/tests/dockerfiles/.gitignore new file mode 100644 index 00000000..c48abeb4 --- /dev/null +++ b/tests/dockerfiles/.gitignore @@ -0,0 +1 @@ +__tmp.dockerfile \ No newline at end of file diff --git a/tests/dockerfiles/chain_upgrade.dockerfile b/tests/dockerfiles/chain_upgrade.dockerfile index 19ce7d83..0db5dc9f 100644 --- a/tests/dockerfiles/chain_upgrade.dockerfile +++ b/tests/dockerfiles/chain_upgrade.dockerfile @@ -6,17 +6,19 @@ ENV PATH=$PATH:/root/go/bin ENV DAEMON_NAME="onomyd" ENV DAEMON_HOME="/root/.onomy" # the previous version -ENV ONOMY_CURRENT_VERSION=v1.0.3.5 +ENV ONOMY_CURRENT_VERSION=v1.1.1 # the version that currently is implemented by this repository's state -ENV ONOMY_UPGRADE_VERSION=v1.1.1 +ENV ONOMY_UPGRADE_VERSION=v1.1.2 +ENV ONOMY_UPGRADE_DIR_NAME=$ONOMY_UPGRADE_VERSION # note that one has to go under `genesis/` and the other under `upgrades/` ADD https://github.com/onomyprotocol/onomy/releases/download/$ONOMY_CURRENT_VERSION/$DAEMON_NAME $DAEMON_HOME/cosmovisor/genesis/$ONOMY_CURRENT_VERSION/bin/$DAEMON_NAME -ADD ./dockerfile_resources/$DAEMON_NAME $DAEMON_HOME/cosmovisor/upgrades/$ONOMY_UPGRADE_VERSION/bin/$DAEMON_NAME +ADD ./dockerfile_resources/$DAEMON_NAME $DAEMON_HOME/cosmovisor/upgrades/$ONOMY_UPGRADE_DIR_NAME/bin/$DAEMON_NAME +#ADD https://github.com/onomyprotocol/onomy/releases/download/$ONOMY_UPGRADE_VERSION/$DAEMON_NAME $DAEMON_HOME/cosmovisor/upgrades/$ONOMY_UPGRADE_DIR_NAME/bin/$DAEMON_NAME # for manual testing RUN chmod +x $DAEMON_HOME/cosmovisor/genesis/$ONOMY_CURRENT_VERSION/bin/$DAEMON_NAME -RUN chmod +x $DAEMON_HOME/cosmovisor/upgrades/$ONOMY_UPGRADE_VERSION/bin/$DAEMON_NAME +RUN chmod +x $DAEMON_HOME/cosmovisor/upgrades/$ONOMY_UPGRADE_DIR_NAME/bin/$DAEMON_NAME # set up symbolic links RUN cosmovisor init $DAEMON_HOME/cosmovisor/genesis/$ONOMY_CURRENT_VERSION/bin/$DAEMON_NAME diff --git a/tests/dockerfiles/dockerfile_resources/hermes_config.toml b/tests/dockerfiles/dockerfile_resources/hermes_config.toml deleted file mode 100644 index 0aea71fe..00000000 --- a/tests/dockerfiles/dockerfile_resources/hermes_config.toml +++ /dev/null @@ -1,346 +0,0 @@ -# The global section has parameters that apply globally to the relayer operation. -[global] -log_level = 'info' - -# Specify the mode to be used by the relayer. [Required] -[mode] - -# Specify the client mode. -[mode.clients] - -# Whether or not to enable the client workers. [Required] -enabled = true - -# Whether or not to enable periodic refresh of clients. [Default: true] -# This feature only applies to clients that underlie an open channel. -# For Tendermint clients, the frequency at which Hermes refreshes them is 2/3 of their -# trusting period (e.g., refresh every ~9 days if the trusting period is 14 days). -# Note: Even if this is disabled, clients will be refreshed automatically if -# there is activity on a connection or channel they are involved with. -refresh = true - -# Whether or not to enable misbehaviour detection for clients. [Default: true] -misbehaviour = true - -# Specify the connections mode. -[mode.connections] - -# Whether or not to enable the connection workers for handshake completion. [Required] -enabled = false - -# Specify the channels mode. -[mode.channels] - -# Whether or not to enable the channel workers for handshake completion. [Required] -enabled = false - -# Specify the packets mode. -[mode.packets] - -# Whether or not to enable the packet workers. [Required] -enabled = true - -# Parametrize the periodic packet clearing feature. -# Interval (in number of blocks) at which pending packets -# should be periodically cleared. A value of '0' will disable -# periodic packet clearing. [Default: 100] -clear_interval = 100 - -# Whether or not to clear packets on start. [Default: true] -clear_on_start = true - -# Toggle the transaction confirmation mechanism. -# The tx confirmation mechanism periodically queries the `/tx_search` RPC -# endpoint to check that previously-submitted transactions -# (to any chain in this config file) have been successfully delivered. -# If they have not been, and `clear_interval = 0`, then those packets are -# queued up for re-submission. -# If set to `false`, the following telemetry metrics will be disabled: -# `acknowledgment_packets_confirmed`, `receive_packets_confirmed` and `timeout_packets_confirmed`. -# [Default: false] -tx_confirmation = false - -# Auto register the counterparty payee on a destination chain to -# the relayer's address on the source chain. This can be used -# for simple configuration of the relayer to receive fees for -# relaying RecvPacket on fee-enabled channels. -# For more complex configuration, turn this off and use the CLI -# to manually register the payee addresses. -# [Default: false] -auto_register_counterparty_payee = false - -# The REST section defines parameters for Hermes' built-in RESTful API. -# https://hermes.informal.systems/rest.html -[rest] - -# Whether or not to enable the REST service. Default: false -enabled = true - -# Specify the IPv4/6 host over which the built-in HTTP server will serve the RESTful -# API requests. Default: 127.0.0.1 -host = '127.0.0.1' - -# Specify the port over which the built-in HTTP server will serve the restful API -# requests. Default: 3000 -port = 3000 - - -# The telemetry section defines parameters for Hermes' built-in telemetry capabilities. -# https://hermes.informal.systems/telemetry.html -[telemetry] - -# Whether or not to enable the telemetry service. Default: false -enabled = false - -# Specify the IPv4/6 host over which the built-in HTTP server will serve the metrics -# gathered by the telemetry service. Default: 127.0.0.1 -host = '127.0.0.1' - -# Specify the port over which the built-in HTTP server will serve the metrics gathered -# by the telemetry service. Default: 3001 -port = 3001 - - -# A chains section includes parameters related to a chain and the full node to which -# the relayer can send transactions and queries. -[[chains]] - -# Specify the chain ID. Required -id = 'onomy' - -# Whether or not this is a CCV consumer chain. Default: false -# Only specifiy true for CCV consumer chain, but NOT for sovereign chains. -ccv_consumer_chain = false - -# Specify the RPC address and port where the chain RPC server listens on. Required -rpc_addr = 'http://onomyd:26657' - -# Specify the GRPC address and port where the chain GRPC server listens on. Required -grpc_addr = 'http://onomyd:9090' - -# Specify the WebSocket address and port where the chain WebSocket server -# listens on. Required -websocket_addr = 'ws://onomyd:26657/websocket' - -# Specify the maximum amount of time (duration) that the RPC requests should -# take before timing out. Default: 10s (10 seconds) -# Note: Hermes uses this parameter _only_ in `start` mode; for all other CLIs, -# Hermes uses a large preconfigured timeout (on the order of minutes). -rpc_timeout = '10s' - -# Specify the prefix used by the chain. Required -account_prefix = 'onomy' - -# Specify the name of the private key to use for signing transactions. Required -# See the Adding Keys chapter for more information about managing signing keys: -# https://hermes.informal.systems/commands/keys/index.html#adding-keys -key_name = 'validator' - -# Specify the folder used to store the keys. Optional -# If this is not specified then the hermes home folder is used. -# key_store_folder = '$HOME/.hermes/keys' - -# Specify the address type which determines: -# 1) address derivation; -# 2) how to retrieve and decode accounts and pubkeys; -# 3) the message signing method. -# The current configuration options are for Cosmos SDK and Ethermint. -# -# Example configuration for chains based on Ethermint library: -# -# address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } } -# -# Default: { derivation = 'cosmos' }, i.e. address derivation as in Cosmos SDK. -# Warning: This is an advanced feature! Modify with caution. -address_type = { derivation = 'cosmos' } - -# Specify the store prefix used by the on-chain IBC modules. Required -# Recommended value for Cosmos SDK: 'ibc' -store_prefix = 'ibc' - -# Gas Parameters -# -# The term 'gas' is used to denote the amount of computation needed to execute -# and validate a transaction on-chain. It can be thought of as fuel that gets -# spent in order to power the on-chain execution of a transaction. -# -# Hermes attempts to simulate how much gas a transaction will expend on its -# target chain. From that, it calculates the cost of that gas by multiplying the -# amount of estimated gas by the `gas_multiplier` and the `gas_price` -# (estimated gas * `gas_multiplier` * `gas_price`) in order to compute the -# total fee to be deducted from the relayer's wallet. -# -# The `simulate_tx` operation does not always correctly estimate the appropriate -# amount of gas that a transaction requires. In those cases when the operation -# fails, Hermes will attempt to submit the transaction using the specified -# `default_gas` and `max_gas` parameters. In the case that a transaction would -# require more than `max_gas`, it doesn't get submitted and a -# `TxSimulateGasEstimateExceeded` error is returned. - -# Specify the default amount of gas to be used in case the tx simulation fails, -# and Hermes cannot estimate the amount of gas needed. -# Default: 100 000 -default_gas = 100000 - -# Specify the maximum amount of gas to be used as the gas limit for a transaction. -# If `default_gas` is unspecified, then `max_gas` will be used as `default_gas`. -# Default: 400 000 -max_gas = 400000 - -# Specify the price per gas used of the fee to submit a transaction and -# the denomination of the fee. -# -# The specified gas price should always be greater or equal to the `min-gas-price` -# configured on the chain. This is to ensure that at least some minimal price is -# paid for each unit of gas per transaction. -# -# Required -gas_price = { price = 0.001, denom = 'anom' } - -# Multiply this amount with the gas estimate, used to compute the fee -# and account for potential estimation error. -# -# The purpose of multiplying by `gas_multiplier` is to provide a bit of a buffer -# to catch some of the cases when the gas estimation calculation is on the low -# end. -# -# Example: With this setting set to 1.1, then if the estimated gas -# is 80_000, then gas used to compute the fee will be adjusted to -# 80_000 * 1.1 = 88_000. -# -# Default: 1.1, ie. the gas is increased by 10% -# Minimum value: 1.0 -gas_multiplier = 1.1 - -# Specify how many IBC messages at most to include in a single transaction. -# Default: 30 -max_msg_num = 30 - -# Specify the maximum size, in bytes, of each transaction that Hermes will submit. -# Default: 2097152 (2 MiB) -max_tx_size = 2097152 - -# Specify the maximum amount of time to tolerate a clock drift. -# The clock drift parameter defines how much new (untrusted) header's time -# can drift into the future. Default: 5s -clock_drift = '5s' - -# Specify the maximum time per block for this chain. -# The block time together with the clock drift are added to the source drift to estimate -# the maximum clock drift when creating a client on this chain. Default: 30s -# For cosmos-SDK chains a good approximation is `timeout_propose` + `timeout_commit` -# Note: This MUST be the same as the `max_expected_time_per_block` genesis parameter for Tendermint chains. -max_block_time = '30s' - -# Specify the amount of time to be used as the light client trusting period. -# It should be significantly less than the unbonding period -# (e.g. unbonding period = 3 weeks, trusting period = 2 weeks). -# Default: 2/3 of the `unbonding period` for Cosmos SDK chains -trusting_period = '14days' - -# Specify the trust threshold for the light client, ie. the minimum fraction of validators -# which must overlap across two blocks during light client verification. -# Default: { numerator = '2', denominator = '3' }, ie. 2/3. -# Warning: This is an advanced feature! Modify with caution. -trust_threshold = { numerator = '2', denominator = '3' } - -# Specify a string that Hermes will use as a memo for each transaction it submits -# to this chain. The string is limited to 50 characters. Default: '' (empty). -# Note: Hermes will append to the string defined here additional -# operational debugging information, e.g., relayer build version. -memo_prefix = '' - -# This section specifies the filters for policy based relaying. -# -# Default: no policy / filters, allow all packets on all channels. -# -# Only packet filtering based on channel identifier can be specified. -# A channel filter has two fields: -# 1. `policy` - one of two types are supported: -# - 'allow': permit relaying _only on_ the port/channel id in the list below, -# - 'deny': permit relaying on any channel _except for_ the list below. -# 2. `list` - the list of channels specified by the port and channel identifiers. -# Optionally, each element may also contains wildcards, for eg. 'ica*' -# to match all identifiers starting with 'ica' or '*' to match all identifiers. -# -# Example configuration of a channel filter, only allowing packet relaying on -# channel with port ID 'transfer' and channel ID 'channel-0', as well as on -# all ICA channels. -# -# [chains.packet_filter] -# policy = 'allow' -# list = [ -# ['ica*', '*'], -# ['transfer', 'channel-0'], -# ] - -# This section specifies the filters for incentivized packet relaying. -# Default: no filters, will relay all packets even if they -# are not incentivized. -# -# It is possible to specify the channel or use wildcards for the -# channels. -# The only fee which can be parametrized is the `recv_fee`. -# -# Example configuration of a filter which will only relay incentivized -# packets, with no regards for channel and amount. -# -# [chains.packet_filter.min_fees.'*'] -# recv = [ { amount = 0 } ] -# -# Example configuration of a filter which will only relay packets if they are -# from the channel 'channel-0', and they have a `recv_fee` of at least 20 stake -# or 10 uatom. -# -# [chains.packet_filter.min_fees.'channel-0'] -# recv = [ { amount = 20, denom = 'stake' }, { amount = 10, denom = 'uatom' } ] - -# Specify that the transaction fees should be payed from this fee granter's account. -# Optional. If unspecified (the default behavior), then no fee granter is used, and -# the account specified in `key_name` will pay the tx fees for all transactions -# submitted to this chain. -# fee_granter = '' - -[[chains]] -id = 'market' -ccv_consumer_chain = true -rpc_addr = 'http://marketd:26657' -grpc_addr = 'http://marketd:9090' -websocket_addr = 'ws://marketd:26657/websocket' -rpc_timeout = '10s' -account_prefix = 'onomy' -key_name = 'validator' -store_prefix = 'ibc' -default_gas = 100000 -max_gas = 400000 -gas_price = { price = 0.001, denom = 'anom' } -gas_multiplier = 1.1 -max_msg_num = 30 -max_tx_size = 2097152 -clock_drift = '5s' -max_block_time = '30s' -trusting_period = '14days' -trust_threshold = { numerator = '1', denominator = '3' } -address_type = { derivation = 'cosmos' } - -[[chains]] -id = 'interchain-security-c' -ccv_consumer_chain = true -rpc_addr = 'http://interchain-security-cd:26657' -grpc_addr = 'http://interchain-security-cd:9090' -websocket_addr = 'ws://interchain-security-cd:26657/websocket' -rpc_timeout = '10s' -account_prefix = 'cosmos' -key_name = 'validator' -store_prefix = 'ibc' -default_gas = 100000 -max_gas = 400000 -gas_price = { price = 0.001, denom = 'native' } -gas_multiplier = 1.1 -max_msg_num = 30 -max_tx_size = 2097152 -clock_drift = '5s' -max_block_time = '30s' -trusting_period = '14days' -trust_threshold = { numerator = '1', denominator = '3' } -address_type = { derivation = 'cosmos' } diff --git a/tests/dockerfiles/hermes.dockerfile b/tests/dockerfiles/hermes.dockerfile deleted file mode 100644 index 64881b47..00000000 --- a/tests/dockerfiles/hermes.dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM fedora:38 -RUN dnf install -y git make cmake gcc gcc-c++ which iproute iputils procps-ng vim-minimal tmux net-tools htop tar jq npm openssl-devel perl rust cargo golang -RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest -ENV PATH=$PATH:/root/go/bin -ADD https://github.com/informalsystems/hermes/releases/download/v1.5.1/hermes-v1.5.1-x86_64-unknown-linux-gnu.tar.gz /root/.hermes/bin/ -RUN cd /root/.hermes/bin/ && tar -vxf * -ENV PATH=$PATH:/root/.hermes/bin - -ADD ./dockerfile_resources/hermes_config.toml /root/.hermes/config.toml diff --git a/tests/dockerfiles/interchain_security_cd.dockerfile b/tests/dockerfiles/interchain_security_cd.dockerfile deleted file mode 100644 index f88d91d2..00000000 --- a/tests/dockerfiles/interchain_security_cd.dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM fedora:38 -RUN dnf install -y git make cmake gcc gcc-c++ which iproute iputils procps-ng vim-minimal tmux net-tools htop tar jq npm openssl-devel perl rust cargo golang -RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest -ENV PATH=$PATH:/root/go/bin - -# without the leading 'v' -ENV ICS_VERSION=1.1.0-multiden -ENV DAEMON_NAME="interchain-security-cd" -ENV DAEMON_HOME="/root/.interchain-security-c" -ENV CONSUMER_CURRENT_VERSION=v07-Theta - -ADD https://github.com/cosmos/interchain-security/archive/refs/tags/v$ICS_VERSION.tar.gz /root/v$ICS_VERSION.tar.gz -RUN cd /root && tar -xvf ./v$ICS_VERSION.tar.gz -RUN cd /root/interchain-security-$ICS_VERSION && go build ./cmd/interchain-security-cd - -RUN mkdir -p $DAEMON_HOME/cosmovisor/genesis/$CONSUMER_CURRENT_VERSION/bin/ -RUN mv /root/interchain-security-$ICS_VERSION/interchain-security-cd $DAEMON_HOME/cosmovisor/genesis/$CONSUMER_CURRENT_VERSION/bin/$DAEMON_NAME - -# for manual testing -RUN chmod +x $DAEMON_HOME/cosmovisor/genesis/$CONSUMER_CURRENT_VERSION/bin/$DAEMON_NAME - -# set up symbolic links -RUN cosmovisor init $DAEMON_HOME/cosmovisor/genesis/$CONSUMER_CURRENT_VERSION/bin/$DAEMON_NAME - -# some commands don't like if the data directory does not exist -RUN mkdir $DAEMON_HOME/data diff --git a/tests/dockerfiles/onomyd.dockerfile b/tests/dockerfiles/onomyd.dockerfile deleted file mode 100644 index 3e8cd240..00000000 --- a/tests/dockerfiles/onomyd.dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM fedora:38 -RUN dnf install -y git make cmake gcc gcc-c++ which iproute iputils procps-ng vim-minimal tmux net-tools htop tar jq npm openssl-devel perl rust cargo golang -RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest -ENV PATH=$PATH:/root/go/bin - -ENV DAEMON_NAME="onomyd" -ENV DAEMON_HOME="/root/.onomy" -ENV ONOMY_CURRENT_VERSION=v1.1.1 - -ADD ./dockerfile_resources/$DAEMON_NAME $DAEMON_HOME/cosmovisor/genesis/$ONOMY_CURRENT_VERSION/bin/$DAEMON_NAME - -# for manual testing -RUN chmod +x $DAEMON_HOME/cosmovisor/genesis/$ONOMY_CURRENT_VERSION/bin/$DAEMON_NAME - -# set up symbolic links -RUN cosmovisor init $DAEMON_HOME/cosmovisor/genesis/$ONOMY_CURRENT_VERSION/bin/$DAEMON_NAME - -# some commands don't like if the data directory does not exist -RUN mkdir $DAEMON_HOME/data diff --git a/tests/src/bin/chain_upgrade.rs b/tests/src/bin/chain_upgrade.rs index 429f73c1..ade5444e 100644 --- a/tests/src/bin/chain_upgrade.rs +++ b/tests/src/bin/chain_upgrade.rs @@ -1,17 +1,18 @@ -use common::container_runner; -use log::info; +use log::{info, warn}; use onomy_test_lib::{ cosmovisor::{ - cosmovisor_start, get_block_height, get_staking_pool, get_treasury, - get_treasury_inflation_annual, onomyd_setup, sh_cosmovisor, wait_for_height, + cosmovisor_gov_proposal, cosmovisor_start, get_block_height, get_staking_pool, + get_treasury, get_treasury_inflation_annual, sh_cosmovisor, wait_for_height, }, nom, onomy_std_init, + setups::onomyd_setup, super_orchestrator::{ + docker::{Container, ContainerNetwork, Dockerfile}, sh, - stacked_errors::{MapAddError, Result}, + stacked_errors::{Error, Result, StackableErr}, STD_DELAY, STD_TRIES, }, - Args, + Args, TIMEOUT, }; #[tokio::main] @@ -21,97 +22,113 @@ async fn main() -> Result<()> { if let Some(ref s) = args.entry_name { match s.as_str() { "onomyd" => onomyd_runner(&args).await, - _ => format!("entry_name \"{s}\" is not recognized").map_add_err(|| ()), + _ => Err(Error::from(format!("entry_name \"{s}\" is not recognized"))), } } else { - sh("make build", &[]).await?; + sh("make build", &[]).await.stack()?; // copy to dockerfile resources (docker cannot use files from outside cwd) sh( - "cp ./onomyd ./tests/dockerfiles/dockerfile_resources/onomyd", + "cp ./../onomy/onomyd ./tests/dockerfiles/dockerfile_resources/onomyd", &[], ) - .await?; - container_runner(&args, &[("chain_upgrade", "onomyd")]).await + .await + .stack()?; + container_runner(&args).await } } +async fn container_runner(args: &Args) -> Result<()> { + let logs_dir = "./tests/logs"; + let dockerfiles_dir = "./tests/dockerfiles"; + let bin_entrypoint = &args.bin_name; + let container_target = "x86_64-unknown-linux-gnu"; + + // build internal runner + sh("cargo build --release --bin", &[ + bin_entrypoint, + "--target", + container_target, + ]) + .await + .stack()?; + + let mut cn = ContainerNetwork::new( + "test", + vec![Container::new( + "onomyd", + Dockerfile::Path(format!("{dockerfiles_dir}/chain_upgrade.dockerfile")), + Some(&format!( + "./target/{container_target}/release/{bin_entrypoint}" + )), + &["--entry-name", "onomyd"], + )], + None, + true, + logs_dir, + ) + .stack()? + .add_common_volumes(&[(logs_dir, "/logs")]); + cn.run_all(true).await.stack()?; + cn.wait_with_timeout_all(true, TIMEOUT).await.stack()?; + Ok(()) +} + async fn onomyd_runner(args: &Args) -> Result<()> { - let onomy_current_version = args.onomy_current_version.as_ref().map_add_err(|| ())?; - let onomy_upgrade_version = args.onomy_upgrade_version.as_ref().map_add_err(|| ())?; - let daemon_home = args.daemon_home.as_ref().map_add_err(|| ())?; - assert_ne!(onomy_current_version, onomy_upgrade_version); - // TODO for the next version we turn this to 'false' - onomyd_setup(daemon_home, true).await?; - let mut cosmovisor_runner = cosmovisor_start("onomyd_runner.log", false, None).await?; + let onomy_current_version = args.onomy_current_version.as_ref().stack()?; + let onomy_upgrade_version = args.onomy_upgrade_version.as_ref().stack()?; + let daemon_home = args.daemon_home.as_ref().stack()?; + + info!("current version: {onomy_current_version}, upgrade version: {onomy_upgrade_version}"); + + onomyd_setup(daemon_home, None).await.stack()?; + let mut cosmovisor_runner = cosmovisor_start("onomyd_runner.log", None).await.stack()?; assert_eq!( - sh_cosmovisor("version", &[]).await?.trim(), + sh_cosmovisor("version", &[]).await.stack()?.trim(), onomy_current_version ); - let upgrade_prepare_start = get_block_height().await?; + let upgrade_prepare_start = get_block_height().await.stack()?; let upgrade_height = &format!("{}", upgrade_prepare_start + 4); - let proposal_id = "1"; - - let gas_args = [ - "--gas", - "auto", - "--gas-adjustment", - "1.3", - "-y", - "-b", - "block", - "--from", - "validator", - ] - .as_slice(); let description = &format!("\"upgrade {onomy_upgrade_version}\""); - sh_cosmovisor( - "tx gov submit-proposal software-upgrade", + + cosmovisor_gov_proposal( + "software-upgrade", &[ - [ - onomy_upgrade_version, - "--title", - description, - "--description", - description, - "--upgrade-height", - upgrade_height, - ] - .as_slice(), - gas_args, - ] - .concat(), - ) - .await?; - sh_cosmovisor( - "tx gov deposit", - &[[proposal_id, &nom(2000.0)].as_slice(), gas_args].concat(), - ) - .await?; - sh_cosmovisor( - "tx gov vote", - &[[proposal_id, "yes"].as_slice(), gas_args].concat(), + onomy_upgrade_version, + "--title", + description, + "--description", + description, + "--upgrade-height", + upgrade_height, + ], + &nom(2000.0), + "1anom", ) - .await?; + .await + .stack()?; - wait_for_height(STD_TRIES, STD_DELAY, upgrade_prepare_start + 5).await?; + wait_for_height(STD_TRIES, STD_DELAY, upgrade_prepare_start + 5) + .await + .stack()?; - let version = sh_cosmovisor("version", &[]).await?.trim().to_owned(); - // if the build is not on a tag we get some hashed garbage on the end - //assert_eq!(version.find(onomy_upgrade_version).unwrap(), 0); - // just check that the version has changed so we don't have to deal with tag - // problems - assert_ne!(&version, onomy_current_version); - - info!("{:?}", get_staking_pool().await?); - info!("{}", get_treasury().await?); - info!("{}", get_treasury_inflation_annual().await?); - - info!("version: {version}"); + // Ideally we would just compare the version to `onomy_upgrade_version`, but + // development and merge squashing messes up the tags. This should be manually + // tested after it as been tagged in the main repo. + let version = sh_cosmovisor("version", &[]).await.stack()?; + let version = version.trim(); + if version != onomy_upgrade_version { + warn!("WARNING version after upgrade is {version}"); + } + // asserting that the versions have changed provides most of the same guarantees + assert_ne!(onomy_current_version, version); - cosmovisor_runner.terminate().await?; + info!("{:?}", get_staking_pool().await.stack()?); + info!("{}", get_treasury().await.stack()?); + info!("{}", get_treasury_inflation_annual().await.stack()?); + cosmovisor_runner.terminate(TIMEOUT).await.stack()?; Ok(()) } diff --git a/tests/src/bin/clean.rs b/tests/src/bin/clean.rs index cc486347..07f6848d 100644 --- a/tests/src/bin/clean.rs +++ b/tests/src/bin/clean.rs @@ -1,4 +1,4 @@ -// for locally cleaning up log files and other temproraries +// for locally cleaning up log files and other temporaries use onomy_test_lib::super_orchestrator::{remove_files_in_dir, stacked_errors::Result, std_init}; @@ -6,14 +6,17 @@ use onomy_test_lib::super_orchestrator::{remove_files_in_dir, stacked_errors::Re async fn main() -> Result<()> { std_init()?; + remove_files_in_dir("./tests/dockerfiles", &["__tmp.dockerfile"]).await?; remove_files_in_dir("./tests/dockerfiles/dockerfile_resources", &[ "onomyd", "marketd", "interchain-security-cd", + "__tmp_hermes_config.toml", ]) .await?; - remove_files_in_dir("./tests/logs", &["log", "json"]).await?; - remove_files_in_dir("./tests/resources/keyring-test/", &["address", "info"]).await?; + remove_files_in_dir("./", &["onomyd"]).await?; + remove_files_in_dir("./tests/logs", &[".log", ".json"]).await?; + remove_files_in_dir("./tests/resources/keyring-test/", &[".address", ".info"]).await?; Ok(()) } diff --git a/tests/src/bin/ics_cdd.rs b/tests/src/bin/ics_cdd.rs new file mode 100644 index 00000000..92e89c66 --- /dev/null +++ b/tests/src/bin/ics_cdd.rs @@ -0,0 +1,506 @@ +use std::time::Duration; + +use common::dockerfile_onomyd; +use log::info; +use onomy_test_lib::{ + cosmovisor::{ + cosmovisor_bank_send, cosmovisor_get_addr, cosmovisor_get_balances, cosmovisor_start, + set_minimum_gas_price, sh_cosmovisor, sh_cosmovisor_no_dbg, sh_cosmovisor_tx, + wait_for_num_blocks, + }, + dockerfiles::{dockerfile_hermes, onomy_std_cosmos_daemon_with_arbitrary}, + hermes::{ + hermes_set_gas_price_denom, hermes_start, sh_hermes, write_hermes_config, + HermesChainConfig, IbcPair, + }, + onomy_std_init, reprefix_bech32, + setups::{cosmovisor_add_consumer, marketd_setup, onomyd_setup, test_proposal}, + super_orchestrator::{ + docker::{Container, ContainerNetwork, Dockerfile}, + net_message::NetMessenger, + remove_files_in_dir, sh, + stacked_errors::{Error, Result, StackableErr}, + FileOptions, STD_DELAY, STD_TRIES, + }, + token18, u64_array_bigints, + u64_array_bigints::u256, + Args, ONOMY_IBC_NOM, TIMEOUT, +}; +use tokio::time::sleep; + +const CONSUMER_ID: &str = "interchain-security-cd"; +const CONSUMER_VERSION: &str = "v07-Theta"; +const PROVIDER_ACCOUNT_PREFIX: &str = "onomy"; +const CONSUMER_ACCOUNT_PREFIX: &str = "cosmos"; + +fn consumer_binary_name() -> String { + format!("{CONSUMER_ID}d") +} + +fn consumer_directory() -> String { + format!(".{CONSUMER_ID}") + //format!(".onomy_{CONSUMER_ID}") +} + +#[rustfmt::skip] +const INTERCHAIN_SECURTY_CDD: &str = r#"ENV ICS_VERSION=1.2.0-multiden +ADD https://github.com/cosmos/interchain-security/archive/refs/tags/v$ICS_VERSION.tar.gz /root/v$ICS_VERSION.tar.gz +RUN cd /root && tar -xvf ./v$ICS_VERSION.tar.gz +RUN cd /root/interchain-security-$ICS_VERSION && go build ./cmd/interchain-security-cdd +RUN mkdir -p $DAEMON_HOME/cosmovisor/genesis/$DAEMON_VERSION/bin/ +RUN mv /root/interchain-security-$ICS_VERSION/interchain-security-cdd $DAEMON_HOME/cosmovisor/genesis/$DAEMON_VERSION/bin/$DAEMON_NAME +"#; + +#[tokio::main] +async fn main() -> Result<()> { + let args = onomy_std_init()?; + + if let Some(ref s) = args.entry_name { + match s.as_str() { + "onomyd" => onomyd_runner(&args).await, + "consumer" => consumer(&args).await, + "hermes" => hermes_runner(&args).await, + _ => Err(Error::from(format!("entry_name \"{s}\" is not recognized"))), + } + } else { + sh("make build", &[]).await.stack()?; + // copy to dockerfile resources (docker cannot use files from outside cwd) + sh( + "cp ./onomyd ./tests/dockerfiles/dockerfile_resources/onomyd", + &[], + ) + .await + .stack()?; + container_runner(&args).await.stack() + } +} + +async fn container_runner(args: &Args) -> Result<()> { + let logs_dir = "./tests/logs"; + let dockerfiles_dir = "./tests/dockerfiles"; + let bin_entrypoint = &args.bin_name; + let container_target = "x86_64-unknown-linux-gnu"; + + // build internal runner with `--release` + sh("cargo build --release --bin", &[ + bin_entrypoint, + "--target", + container_target, + ]) + .await + .stack()?; + + // prepare volumed resources + remove_files_in_dir("./tests/resources/keyring-test/", &[".address", ".info"]) + .await + .stack()?; + + // prepare hermes config + write_hermes_config( + &[ + HermesChainConfig::new("onomy", "onomy", false, "anom", true), + HermesChainConfig::new(CONSUMER_ID, CONSUMER_ACCOUNT_PREFIX, true, "anative", true), + ], + &format!("{dockerfiles_dir}/dockerfile_resources"), + ) + .await + .stack()?; + + let entrypoint = Some(format!( + "./target/{container_target}/release/{bin_entrypoint}" + )); + let entrypoint = entrypoint.as_deref(); + + let mut cn = ContainerNetwork::new( + "test", + vec![ + Container::new( + "hermes", + Dockerfile::Contents(dockerfile_hermes("__tmp_hermes_config.toml")), + entrypoint, + &["--entry-name", "hermes"], + ), + Container::new( + "onomyd", + Dockerfile::Contents(dockerfile_onomyd()), + entrypoint, + &["--entry-name", "onomyd"], + ) + .volumes(&[( + "./tests/resources/keyring-test", + "/root/.onomy/keyring-test", + )]), + Container::new( + &consumer_binary_name(), + Dockerfile::Contents(onomy_std_cosmos_daemon_with_arbitrary( + &consumer_binary_name(), + &consumer_directory(), + CONSUMER_VERSION, + INTERCHAIN_SECURTY_CDD, + )), + entrypoint, + &["--entry-name", "consumer"], + ) + .volumes(&[( + "./tests/resources/keyring-test", + &format!("/root/{}/keyring-test", consumer_directory()), + )]), + ], + Some(dockerfiles_dir), + true, + logs_dir, + ) + .stack()? + .add_common_volumes(&[(logs_dir, "/logs")]); + cn.run_all(true).await.stack()?; + cn.wait_with_timeout_all(true, TIMEOUT).await.stack()?; + Ok(()) +} + +async fn hermes_runner(args: &Args) -> Result<()> { + let hermes_home = args.hermes_home.as_ref().stack()?; + let mut nm_onomyd = NetMessenger::listen_single_connect("0.0.0.0:26000", TIMEOUT) + .await + .stack()?; + + // get mnemonic from onomyd + let mnemonic: String = nm_onomyd.recv().await.stack()?; + // set keys for our chains + FileOptions::write_str("/root/.hermes/mnemonic.txt", &mnemonic) + .await + .stack()?; + sh_hermes( + "keys add --chain onomy --mnemonic-file /root/.hermes/mnemonic.txt", + &[], + ) + .await + .stack()?; + sh_hermes( + &format!("keys add --chain {CONSUMER_ID} --mnemonic-file /root/.hermes/mnemonic.txt"), + &[], + ) + .await + .stack()?; + + // wait for setup + nm_onomyd.recv::<()>().await.stack()?; + + let ibc_pair = IbcPair::hermes_setup_ics_pair(CONSUMER_ID, "onomy") + .await + .stack()?; + let mut hermes_runner = hermes_start("/logs/hermes_bootstrap_runner.log") + .await + .stack()?; + ibc_pair.hermes_check_acks().await.stack()?; + + // tell that chains have been connected + nm_onomyd.send::(&ibc_pair).await.stack()?; + + // signal to update gas denom + let ibc_nom = nm_onomyd.recv::().await.stack()?; + hermes_runner.terminate(TIMEOUT).await.stack()?; + hermes_set_gas_price_denom(hermes_home, CONSUMER_ID, &ibc_nom) + .await + .stack()?; + + // restart + let mut hermes_runner = hermes_start("/logs/hermes_runner.log").await.stack()?; + nm_onomyd.send::<()>(&()).await.stack()?; + + // termination signal + nm_onomyd.recv::<()>().await.stack()?; + hermes_runner.terminate(TIMEOUT).await.stack()?; + Ok(()) +} + +async fn onomyd_runner(args: &Args) -> Result<()> { + let consumer_id = CONSUMER_ID; + let daemon_home = args.daemon_home.as_ref().stack()?; + let mut nm_hermes = NetMessenger::connect(STD_TRIES, STD_DELAY, "hermes:26000") + .await + .stack()?; + let mut nm_consumer = + NetMessenger::connect(STD_TRIES, STD_DELAY, &format!("{consumer_id}d:26001")) + .await + .stack() + .stack()?; + + let mnemonic = onomyd_setup(daemon_home, None).await.stack()?; + // send mnemonic to hermes + nm_hermes.send::(&mnemonic).await.stack()?; + + // keep these here for local testing purposes + let addr = &cosmovisor_get_addr("validator").await.stack()?; + sleep(Duration::ZERO).await; + + let mut cosmovisor_runner = cosmovisor_start("onomyd_runner.log", None).await.stack()?; + + let ccvconsumer_state = cosmovisor_add_consumer( + daemon_home, + consumer_id, + &test_proposal(consumer_id, "anative"), + ) + .await + .stack()?; + + // send to consumer + nm_consumer + .send::(&ccvconsumer_state) + .await + .stack()?; + + // send keys + nm_consumer + .send::( + &FileOptions::read_to_string(&format!("{daemon_home}/config/node_key.json")) + .await + .stack()?, + ) + .await + .stack()?; + nm_consumer + .send::( + &FileOptions::read_to_string(&format!("{daemon_home}/config/priv_validator_key.json")) + .await + .stack()?, + ) + .await + .stack()?; + + // wait for consumer to be online + nm_consumer.recv::<()>().await.stack()?; + // notify hermes to connect the chains + nm_hermes.send::<()>(&()).await.stack()?; + // when hermes is done + let ibc_pair = nm_hermes.recv::().await.stack()?; + info!("IbcPair: {ibc_pair:?}"); + + // send anom to consumer + ibc_pair + .b + .cosmovisor_ibc_transfer( + "validator", + &reprefix_bech32(addr, CONSUMER_ACCOUNT_PREFIX).stack()?, + &token18(100.0e3, ""), + "anom", + ) + .await + .stack()?; + // it takes time for the relayer to complete relaying + wait_for_num_blocks(4).await.stack()?; + // notify consumer that we have sent NOM + nm_consumer.send::(&ibc_pair).await.stack()?; + + // tell hermes to restart with updated gas denom on its side + let ibc_nom = nm_consumer.recv::().await.stack()?; + nm_hermes.send::(&ibc_nom).await.stack()?; + nm_hermes.recv::<()>().await.stack()?; + nm_consumer.send::<()>(&()).await.stack()?; + + // recieve round trip signal + nm_consumer.recv::<()>().await.stack()?; + // check that the IBC NOM converted back to regular NOM + assert_eq!( + cosmovisor_get_balances("onomy1gk7lg5kd73mcr8xuyw727ys22t7mtz9gh07ul3") + .await + .stack()?["anom"], + u256!(5000) + ); + + // signal to collectively terminate + nm_hermes.send::<()>(&()).await.stack()?; + nm_consumer.send::<()>(&()).await.stack()?; + cosmovisor_runner.terminate(TIMEOUT).await.stack()?; + + FileOptions::write_str( + "/logs/onomyd_export.json", + &sh_cosmovisor_no_dbg("export", &[]).await.stack()?, + ) + .await + .stack()?; + + Ok(()) +} + +async fn consumer(args: &Args) -> Result<()> { + let daemon_home = args.daemon_home.as_ref().stack()?; + let chain_id = CONSUMER_ID; + let mut nm_onomyd = NetMessenger::listen_single_connect("0.0.0.0:26001", TIMEOUT) + .await + .stack()?; + // we need the initial consumer state + let ccvconsumer_state_s: String = nm_onomyd.recv().await.stack()?; + + marketd_setup(daemon_home, chain_id, &ccvconsumer_state_s) + .await + .stack()?; + + // get keys + let node_key = nm_onomyd.recv::().await.stack()?; + // we used same keys for consumer as producer, need to copy them over or else + // the node will not be a working validator for itself + FileOptions::write_str(&format!("{daemon_home}/config/node_key.json"), &node_key) + .await + .stack()?; + + let priv_validator_key = nm_onomyd.recv::().await.stack()?; + FileOptions::write_str( + &format!("{daemon_home}/config/priv_validator_key.json"), + &priv_validator_key, + ) + .await + .stack()?; + + let mut cosmovisor_runner = + cosmovisor_start(&format!("{chain_id}d_bootstrap_runner.log"), None) + .await + .stack()?; + + let addr = &cosmovisor_get_addr("validator").await.stack()?; + + // signal that we have started + nm_onomyd.send::<()>(&()).await.stack()?; + + // wait for producer to send us stuff + let ibc_pair = nm_onomyd.recv::().await.stack()?; + // get the name of the IBC NOM. Note that we can't do this on the onomyd side, + // it has to be with respect to the consumer side + let ibc_nom = &ibc_pair.a.get_ibc_denom("anom").await.stack()?; + assert_eq!(ibc_nom, ONOMY_IBC_NOM); + let balances = cosmovisor_get_balances(addr).await.stack()?; + assert!(balances.contains_key(ibc_nom)); + + // we have IBC NOM, shut down, change gas in app.toml, restart + cosmovisor_runner.terminate(TIMEOUT).await.stack()?; + set_minimum_gas_price(daemon_home, &format!("1{ibc_nom}")) + .await + .stack()?; + let mut cosmovisor_runner = cosmovisor_start(&format!("{chain_id}d_runner.log"), None) + .await + .stack()?; + // tell hermes to restart with updated gas denom on its side + nm_onomyd.send::(ibc_nom).await.stack()?; + nm_onomyd.recv::<()>().await.stack()?; + info!("restarted with new gas denom"); + + // test normal transfer + let dst_addr = &reprefix_bech32( + "onomy1gk7lg5kd73mcr8xuyw727ys22t7mtz9gh07ul3", + CONSUMER_ACCOUNT_PREFIX, + ) + .stack()?; + cosmovisor_bank_send(addr, dst_addr, "5000", ibc_nom) + .await + .stack()?; + assert_eq!( + cosmovisor_get_balances(dst_addr).await.stack()?[ibc_nom], + u256!(5000) + ); + + let test_addr = &reprefix_bech32( + "onomy1gk7lg5kd73mcr8xuyw727ys22t7mtz9gh07ul3", + PROVIDER_ACCOUNT_PREFIX, + ) + .stack()?; + info!("sending back to {}", test_addr); + + // avoid conflict with hermes relayer + wait_for_num_blocks(4).await.stack()?; + + // send some IBC NOM back to origin chain using it as gas + ibc_pair + .a + .cosmovisor_ibc_transfer("validator", test_addr, "5000", ibc_nom) + .await + .stack()?; + wait_for_num_blocks(4).await.stack()?; + + let pubkey = sh_cosmovisor("tendermint show-validator", &[]) + .await + .stack()?; + let pubkey = pubkey.trim(); + sh_cosmovisor_tx("staking", &[ + "create-validator", + "--commission-max-change-rate", + "0.01", + "--commission-max-rate", + "0.10", + "--commission-rate", + "0.05", + "--from", + "validator", + "--min-self-delegation", + "1", + "--amount", + &token18(1.0e3, ONOMY_IBC_NOM), + "--fees", + &format!("1000000{ONOMY_IBC_NOM}"), + "--pubkey", + pubkey, + "-y", + "-b", + "block", + ]) + .await + .stack()?; + + // round trip signal + nm_onomyd.send::<()>(&()).await.stack()?; + + // termination signal + nm_onomyd.recv::<()>().await.stack()?; + + // interchain-security-cd does not support this proposal + /* + // but first, test governance with IBC NOM as the token + let test_crisis_denom = ONOMY_IBC_NOM; + let test_deposit = token18(2000.0, ONOMY_IBC_NOM); + wait_for_num_blocks(1).await.stack()?; + cosmovisor_gov_file_proposal( + daemon_home, + "param-change", + &format!( + r#" + {{ + "title": "Parameter Change", + "description": "Making a parameter change", + "changes": [ + {{ + "subspace": "crisis", + "key": "ConstantFee", + "value": {{"denom":"{test_crisis_denom}","amount":"1337"}} + }} + ], + "deposit": "{test_deposit}" + }} + "# + ), + &format!("1{ibc_nom}"), + ) + .await + .stack()?; + wait_for_num_blocks(5).await.stack()?; + // just running this for debug, param querying is weird because it is json + // inside of yaml, so we will instead test the exported genesis + sh_cosmovisor("query params subspace crisis ConstantFee", &[]) + .await + .stack()?;*/ + + cosmovisor_runner.terminate(TIMEOUT).await.stack()?; + + let exported = sh_cosmovisor_no_dbg("export", &[]).await.stack()?; + FileOptions::write_str(&format!("/logs/{chain_id}_export.json"), &exported) + .await + .stack()?; + /*let exported = yaml_str_to_json_value(&exported).stack()?; + assert_eq!( + exported["app_state"]["crisis"]["constant_fee"]["denom"], + test_crisis_denom + ); + assert_eq!( + exported["app_state"]["crisis"]["constant_fee"]["amount"], + "1337" + );*/ + + Ok(()) +} diff --git a/tests/src/bin/ics_with_interchain_security_cd.rs b/tests/src/bin/ics_with_interchain_security_cd.rs deleted file mode 100644 index fa9f235b..00000000 --- a/tests/src/bin/ics_with_interchain_security_cd.rs +++ /dev/null @@ -1,407 +0,0 @@ -use std::time::Duration; - -use log::info; -use onomy_test_lib::{ - cosmovisor::{ - cosmovisor_get_addr, cosmovisor_start, fast_block_times, onomyd_setup, sh_cosmovisor, - wait_for_height, - }, - hermes::{create_channel_pair, create_connection_pair, sh_hermes}, - json_inner, onomy_std_init, reprefix_bech32, - super_orchestrator::{ - docker::{Container, ContainerNetwork}, - net_message::NetMessenger, - remove_files_in_dir, sh, - stacked_errors::{MapAddError, Result}, - Command, FileOptions, STD_DELAY, STD_TRIES, - }, - token18, Args, TIMEOUT, -}; -use serde_json::Value; -use tokio::time::sleep; - -#[tokio::main] -async fn main() -> Result<()> { - let args = onomy_std_init()?; - - if let Some(ref s) = args.entry_name { - match s.as_str() { - "onomyd" => onomyd_runner(&args).await, - "interchain-security-cd" => interchain_security_cd_runner(&args).await, - "hermes" => hermes_runner().await, - _ => format!("entry_name \"{s}\" is not recognized").map_add_err(|| ()), - } - } else { - sh("make build", &[]).await?; - // copy to dockerfile resources (docker cannot use files from outside cwd) - sh( - "cp ./onomyd ./tests/dockerfiles/dockerfile_resources/onomyd", - &[], - ) - .await?; - container_runner(&args).await - } -} - -async fn container_runner(args: &Args) -> Result<()> { - let bin_entrypoint = &args.bin_name; - let container_target = "x86_64-unknown-linux-gnu"; - let logs_dir = "./tests/logs"; - - // build internal runner with `--release` - sh("cargo build --release --bin", &[ - bin_entrypoint, - "--target", - container_target, - ]) - .await?; - - // prepare volumed resources - remove_files_in_dir("./tests/resources/keyring-test/", &["address", "info"]).await?; - - let entrypoint = Some(format!( - "./target/{container_target}/release/{bin_entrypoint}" - )); - let entrypoint = entrypoint.as_deref(); - let volumes = vec![(logs_dir, "/logs")]; - let mut onomyd_volumes = volumes.clone(); - let mut consumer_volumes = volumes.clone(); - onomyd_volumes.push(( - "./tests/resources/keyring-test", - "/root/.onomy/keyring-test", - )); - consumer_volumes.push(( - "./tests/resources/keyring-test", - "/root/.interchain-security-c/keyring-test", - )); - - let mut cn = ContainerNetwork::new( - "test", - vec![ - Container::new( - "hermes", - Some("./tests/dockerfiles/hermes.dockerfile"), - None, - &volumes, - entrypoint, - &["--entry-name", "hermes"], - ), - Container::new( - "onomyd", - Some("./tests/dockerfiles/onomyd.dockerfile"), - None, - &onomyd_volumes, - entrypoint, - &["--entry-name", "onomyd"], - ), - Container::new( - "interchain-security-cd", - Some("./tests/dockerfiles/interchain_security_cd.dockerfile"), - None, - &consumer_volumes, - entrypoint, - &["--entry-name", "interchain-security-cd"], - ), - ], - true, - logs_dir, - )?; - cn.run_all(true).await?; - cn.wait_with_timeout_all(true, TIMEOUT).await?; - Ok(()) -} - -async fn hermes_runner() -> Result<()> { - let mut nm_onomyd = NetMessenger::listen_single_connect("0.0.0.0:26000", TIMEOUT).await?; - - let mnemonic: String = nm_onomyd.recv().await?; - // set keys for our chains - FileOptions::write_str("/root/.hermes/mnemonic.txt", &mnemonic).await?; - sh_hermes( - "keys add --chain onomy --mnemonic-file /root/.hermes/mnemonic.txt", - &[], - ) - .await?; - sh_hermes( - "keys add --chain interchain-security-c --mnemonic-file /root/.hermes/mnemonic.txt", - &[], - ) - .await?; - - nm_onomyd.recv::<()>().await?; - - // https://hermes.informal.systems/tutorials/local-chains/add-a-new-relay-path.html - - // Note: For ICS, there is a point where a handshake must be initiated by the - // consumer chain, so we must make the consumer chain the "a-chain" and the - // producer chain the "b-chain" - - let b_chain = "onomy"; - let a_chain = "interchain-security-c"; - // a client is already created because of the ICS setup - //let client_pair = create_client_pair(a_chain, b_chain).await?; - // create one client and connection pair that will be used for IBC transfer and - // ICS communication - let connection_pair = create_connection_pair(a_chain, b_chain).await?; - - // a_chain<->b_chain transfer<->transfer - let transfer_channel_pair = - create_channel_pair(a_chain, &connection_pair.0, "transfer", "transfer", false).await?; - - // a_chain<->b_chain consumer<->provider - let ics_channel_pair = - create_channel_pair(a_chain, &connection_pair.0, "consumer", "provider", true).await?; - - let hermes_log = FileOptions::write2("/logs", "hermes_runner.log"); - let mut hermes_runner = Command::new("hermes start", &[]) - .stderr_log(&hermes_log) - .stdout_log(&hermes_log) - .run() - .await?; - - info!("Onomy Network has been setup"); - - sleep(Duration::from_secs(5)).await; - - // check all channels on both sides - sh_hermes("query packet acks --chain", &[ - b_chain, - "--port", - "transfer", - "--channel", - &transfer_channel_pair.0, - ]) - .await?; - sh_hermes("query packet acks --chain", &[ - a_chain, - "--port", - "transfer", - "--channel", - &transfer_channel_pair.1, - ]) - .await?; - sh_hermes("query packet acks --chain", &[ - b_chain, - "--port", - "provider", - "--channel", - &ics_channel_pair.0, - ]) - .await?; - sh_hermes("query packet acks --chain", &[ - a_chain, - "--port", - "consumer", - "--channel", - &ics_channel_pair.1, - ]) - .await?; - - //hermes tx ft-transfer --timeout-seconds 10 --dst-chain interchain-security-c - // --src-chain onomy --src-port transfer --src-channel channel-0 --amount - // 1337 --denom anom - - nm_onomyd.send::<()>(&()).await?; - - hermes_runner.terminate().await?; - Ok(()) -} - -async fn onomyd_runner(args: &Args) -> Result<()> { - let consumer_id = "interchain-security-c"; - let daemon_home = args.daemon_home.as_ref().map_add_err(|| ())?; - let mut nm_hermes = NetMessenger::connect(STD_TRIES, STD_DELAY, "hermes:26000") - .await - .map_add_err(|| ())?; - let mut nm_consumer = - NetMessenger::connect(STD_TRIES, STD_DELAY, "interchain-security-cd:26001") - .await - .map_add_err(|| ())?; - - let mnemonic = onomyd_setup(daemon_home, false).await?; - - let mut cosmovisor_runner = cosmovisor_start("onomyd_runner.log", true, None).await?; - - let proposal_id = "1"; - - // TODO we think we will make the redistribution fraction 0 and either make a - // native "native" or IBC NOM as the gas denom (may take a gov proposal for - // bootstrap) - - // `json!` doesn't like large literals beyond i32 - let proposal_s = &format!( - r#"{{ - "title": "Propose the addition of a new chain", - "description": "add consumer chain", - "chain_id": "{consumer_id}", - "initial_height": {{ - "revision_number": 0, - "revision_height": 1 - }}, - "genesis_hash": "Z2VuX2hhc2g=", - "binary_hash": "YmluX2hhc2g=", - "spawn_time": "2023-05-18T01:15:49.83019476-05:00", - "consumer_redistribution_fraction": "0.0", - "blocks_per_distribution_transmission": 1000, - "historical_entries": 10000, - "ccv_timeout_period": 2419200000000000, - "transfer_timeout_period": 3600000000000, - "unbonding_period": 1728000000000000, - "deposit": "2000000000000000000000anom", - "provider_reward_denoms": [] - }}"# - ); - // we will just place the file under the config folder - let proposal_file_path = format!("{daemon_home}/config/consumer_add_proposal.json"); - FileOptions::write_str(&proposal_file_path, proposal_s) - .await - .map_add_err(|| ())?; - - let gas_args = [ - "--gas", - "auto", - "--gas-adjustment", - "1.3", - "-y", - "-b", - "block", - "--from", - "validator", - ] - .as_slice(); - sh_cosmovisor( - "tx gov submit-proposal consumer-addition", - &[&[proposal_file_path.as_str()], gas_args].concat(), - ) - .await?; - // the deposit is done as part of the chain addition proposal - sh_cosmovisor( - "tx gov vote", - &[[proposal_id, "yes"].as_slice(), gas_args].concat(), - ) - .await?; - - // In the mean time get consensus key assignment done - - let tendermint_key: Value = serde_json::from_str( - &FileOptions::read_to_string(&format!("{daemon_home}/config/priv_validator_key.json")) - .await?, - )?; - let tendermint_key = json_inner(&tendermint_key["pub_key"]["value"]); - let tendermint_key = - format!("{{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"{tendermint_key}\"}}"); - - // do this before getting the consumer-genesis - sh_cosmovisor( - "tx provider assign-consensus-key", - &[[consumer_id, tendermint_key.as_str()].as_slice(), gas_args].concat(), - ) - .await?; - - wait_for_height(STD_TRIES, STD_DELAY, 5).await?; - - let ccvconsumer_state = sh_cosmovisor("query provider consumer-genesis", &[ - consumer_id, - "-o", - "json", - ]) - .await?; - - nm_hermes.send::(&mnemonic).await?; - - // send to consumer - nm_consumer.send::(&ccvconsumer_state).await?; - - nm_consumer - .send::( - &FileOptions::read_to_string(&format!("{daemon_home}/config/node_key.json")).await?, - ) - .await?; - nm_consumer - .send::( - &FileOptions::read_to_string(&format!("{daemon_home}/config/priv_validator_key.json")) - .await?, - ) - .await?; - - // wait for consumer to be online - nm_consumer.recv::<()>().await?; - // notify hermes to connect the chains - nm_hermes.send::<()>(&()).await?; - // when hermes is done - nm_hermes.recv::<()>().await?; - // finish - nm_consumer.send::<()>(&()).await?; - - //cosmovisor("tx ibc-transfer transfer", &[port, channel, receiver, - // amount]).await?; - - cosmovisor_runner.terminate().await?; - Ok(()) -} - -async fn interchain_security_cd_runner(args: &Args) -> Result<()> { - let daemon_home = args.daemon_home.as_ref().map_add_err(|| ())?; - let mut nm_onomyd = NetMessenger::listen_single_connect("0.0.0.0:26001", TIMEOUT).await?; - let chain_id = "interchain-security-c"; - sh_cosmovisor("config chain-id", &[chain_id]).await?; - sh_cosmovisor("config keyring-backend test", &[]).await?; - sh_cosmovisor("init --overwrite", &[chain_id]).await?; - let genesis_file_path = format!("{daemon_home}/config/genesis.json"); - - // we need the initial consumer state - let ccvconsumer_state_s: String = nm_onomyd.recv().await?; - let ccvconsumer_state: Value = serde_json::from_str(&ccvconsumer_state_s)?; - - // add `ccvconsumer_state` to genesis - - let genesis_s = FileOptions::read_to_string(&genesis_file_path).await?; - - let mut genesis: Value = serde_json::from_str(&genesis_s)?; - genesis["app_state"]["ccvconsumer"] = ccvconsumer_state; - let genesis_s = genesis.to_string(); - - // I will name the token "native" because it won't be staked in the normal sense - let genesis_s = genesis_s.replace("\"stake\"", "\"native\""); - - FileOptions::write_str(&genesis_file_path, &genesis_s).await?; - - let addr: &String = &cosmovisor_get_addr("validator").await?; - // use "cosmos" prefix on the consumer chain so that we don't have to modify it - let addr = &reprefix_bech32(addr, "cosmos").unwrap(); - - // we need some native token in the bank, and don't need gentx - sh_cosmovisor("add-genesis-account", &[addr, &token18(2.0e6, "native")]).await?; - - FileOptions::write_str( - &format!("/logs/{chain_id}_genesis.json"), - &FileOptions::read_to_string(&genesis_file_path).await?, - ) - .await?; - - fast_block_times(daemon_home).await?; - - // we used same keys for consumer as producer, need to copy them over or else - // the node will not be a working validator for itself - FileOptions::write_str( - &format!("{daemon_home}/config/node_key.json"), - &nm_onomyd.recv::().await?, - ) - .await?; - FileOptions::write_str( - &format!("{daemon_home}/config/priv_validator_key.json"), - &nm_onomyd.recv::().await?, - ) - .await?; - - let mut cosmovisor_runner = - cosmovisor_start(&format!("{chain_id}d_runner.log"), true, None).await?; - - // signal that we have started - nm_onomyd.send::<()>(&()).await?; - - nm_onomyd.recv::<()>().await?; - - cosmovisor_runner.terminate().await?; - Ok(()) -} diff --git a/tests/src/bin/onomyd_only.rs b/tests/src/bin/onomyd_only.rs index 1671f5a6..b699fa82 100644 --- a/tests/src/bin/onomyd_only.rs +++ b/tests/src/bin/onomyd_only.rs @@ -1,16 +1,23 @@ -use common::container_runner; +use std::time::Duration; + +use common::{container_runner, dockerfile_onomyd}; +use log::info; use onomy_test_lib::{ cosmovisor::{ - cosmovisor_get_addr, cosmovisor_start, get_apr_annual, get_delegations_to, - get_staking_pool, get_treasury, get_treasury_inflation_annual, onomyd_setup, + cosmovisor_get_addr, cosmovisor_gov_file_proposal, cosmovisor_start, get_apr_annual, + get_delegations_to, get_staking_pool, get_treasury, get_treasury_inflation_annual, + sh_cosmovisor, sh_cosmovisor_no_dbg, sh_cosmovisor_tx, wait_for_num_blocks, }, - json_inner, onomy_std_init, reprefix_bech32, + onomy_std_init, reprefix_bech32, + setups::{onomyd_setup, CosmosSetupOptions}, super_orchestrator::{ sh, - stacked_errors::{MapAddError, Result}, + stacked_errors::{Error, Result, StackableErr}, + FileOptions, }, - token18, yaml_str_to_json_value, Args, + token18, yaml_str_to_json_value, Args, ONOMY_IBC_NOM, TIMEOUT, }; +use tokio::time::sleep; #[tokio::main] async fn main() -> Result<()> { @@ -19,44 +26,140 @@ async fn main() -> Result<()> { if let Some(ref s) = args.entry_name { match s.as_str() { "onomyd" => onomyd_runner(&args).await, - _ => format!("entry_name \"{s}\" is not recognized").map_add_err(|| ()), + _ => Err(Error::from(format!("entry_name \"{s}\" is not recognized"))), } } else { - sh("make build", &[]).await?; + sh("make build", &[]).await.stack()?; // copy to dockerfile resources (docker cannot use files from outside cwd) sh( "cp ./onomyd ./tests/dockerfiles/dockerfile_resources/onomyd", &[], ) - .await?; - container_runner(&args, &[("onomyd", "onomyd")]).await + .await + .stack()?; + container_runner(&args, &[("onomyd", &dockerfile_onomyd())]) + .await + .stack() } } async fn onomyd_runner(args: &Args) -> Result<()> { - let daemon_home = args.daemon_home.as_ref().map_add_err(|| ())?; - onomyd_setup(daemon_home, false).await?; - let mut cosmovisor_runner = cosmovisor_start("onomyd_runner.log", false, None).await?; + let daemon_home = args.daemon_home.as_ref().stack()?; + let mut options = CosmosSetupOptions::new(); + options.high_staking_level = true; + onomyd_setup(daemon_home, Some(options)).await.stack()?; + let mut cosmovisor_runner = cosmovisor_start("onomyd_runner.log", None).await.stack()?; - let addr: &String = &cosmovisor_get_addr("validator").await?; - let valoper_addr = &reprefix_bech32(addr, "onomyvaloper").unwrap(); - assert!((get_apr_annual(valoper_addr).await? - 13.25).abs() < 0.1); + let addr = &cosmovisor_get_addr("validator").await.stack()?; + let valoper_addr = &reprefix_bech32(addr, "onomyvaloper").stack()?; + let tmp = sh_cosmovisor("tendermint show-address", &[]) + .await + .stack()?; + let valcons_addr = tmp.trim(); + info!("address: {addr}"); + info!("valoper address: {valoper_addr}"); + info!("valcons address: {valcons_addr}"); + //sleep(TIMEOUT).await; - // make sure DAO is not delegating - let delegations = yaml_str_to_json_value(&get_delegations_to(valoper_addr).await?)?; - assert_eq!( - json_inner(&delegations["delegation_responses"][0]["balance"]["amount"]), - token18(1.0e6, "") - ); + // get valcons bech32 and pub key + // cosmovisor run query tendermint-validator-set + let valcons_set = sh_cosmovisor("query tendermint-validator-set", &[]) + .await + .stack()?; + info!("{valcons_set}"); + + // get mapping of cons pub keys and valoper addr + // cosmovisor run query staking validators + + sh_cosmovisor_tx( + &format!( + "staking delegate {valoper_addr} 1000000000000000000000anom --fees 1000000anom -y -b \ + block --from validator" + ), + &[], + ) + .await + .stack()?; + sh_cosmovisor("query staking validators", &[]) + .await + .stack()?; + + let apr0 = get_apr_annual(valoper_addr, 6311520.0).await.stack()?; + info!("APR: {apr0}"); + wait_for_num_blocks(1).await.stack()?; + let apr1 = get_apr_annual(valoper_addr, 6311520.0).await.stack()?; + info!("APR: {apr1}"); + assert!(apr1 < apr0); + assert!(apr1 < 0.14); - let staking_pool = get_staking_pool().await?; - assert_eq!(staking_pool.bonded_tokens, 1.0e6); - assert_eq!(staking_pool.unbonded_tokens, 0.0); + info!("{}", get_delegations_to(valoper_addr).await.stack()?); + info!("{:?}", get_staking_pool().await.stack()?); + info!("{}", get_treasury().await.stack()?); + info!("{}", get_treasury_inflation_annual().await.stack()?); - assert!((get_treasury().await? - 100.0e6).abs() < 100.0); - assert!((get_treasury_inflation_annual().await? - 0.13).abs() < 0.001); + sh( + &format!( + "cosmovisor run tx bank send {addr} onomy1a69w3hfjqere4crkgyee79x2mxq0w2pfj9tu2m \ + 1337anom --fees 1000000anom -y -b block" + ), + &[], + ) + .await + .stack()?; - cosmovisor_runner.terminate().await?; + //cosmovisor run tx staking delegate onomyvaloper + // 10000000000000000000000ibc/ + // 0EEDE4D6082034D6CD465BD65761C305AACC6FCA1246F87D6A3C1F5488D18A7B --gas auto + // --gas-adjustment 1.3 -y -b block + + let test_crisis_denom = ONOMY_IBC_NOM; + let test_deposit = token18(2000.0, "anom"); + cosmovisor_gov_file_proposal( + daemon_home, + "param-change", + &format!( + r#" + {{ + "title": "Parameter Change", + "description": "Making a parameter change", + "changes": [ + {{ + "subspace": "crisis", + "key": "ConstantFee", + "value": {{"denom":"{test_crisis_denom}","amount":"1337"}} + }} + ], + "deposit": "{test_deposit}" + }} + "# + ), + "1anom", + ) + .await + .stack()?; + wait_for_num_blocks(1).await.stack()?; + // just running this for debug, param querying is weird because it is json + // inside of yaml, so we will instead test the exported genesis + sh_cosmovisor("query params subspace crisis ConstantFee", &[]) + .await + .stack()?; + + sleep(Duration::ZERO).await; + cosmovisor_runner.terminate(TIMEOUT).await.stack()?; + // test that exporting works + let exported = sh_cosmovisor_no_dbg("export", &[]).await.stack()?; + FileOptions::write_str("/logs/onomyd_export.json", &exported) + .await + .stack()?; + let exported = yaml_str_to_json_value(&exported)?; + assert_eq!( + exported["app_state"]["crisis"]["constant_fee"]["denom"], + test_crisis_denom + ); + assert_eq!( + exported["app_state"]["crisis"]["constant_fee"]["amount"], + "1337" + ); Ok(()) } diff --git a/tests/src/lib/common.rs b/tests/src/lib/common.rs index bafa1c8e..18432fce 100644 --- a/tests/src/lib/common.rs +++ b/tests/src/lib/common.rs @@ -1,21 +1,24 @@ use onomy_test_lib::{ + dockerfiles::onomy_std_cosmos_daemon, super_orchestrator::{ - docker::{Container, ContainerNetwork}, + docker::{Container, ContainerNetwork, Dockerfile}, sh, stacked_errors::Result, }, Args, TIMEOUT, }; +pub fn dockerfile_onomyd() -> String { + onomy_std_cosmos_daemon("onomyd", ".onomy", "v1.1.1", "onomyd") +} + /// Useful for running simple container networks that have a standard format and /// don't need extra build or volume arguments. -pub async fn container_runner( - args: &Args, - dockerfiles_and_entry_names: &[(&str, &str)], -) -> Result<()> { +pub async fn container_runner(args: &Args, name_and_contents: &[(&str, &str)]) -> Result<()> { + let logs_dir = "./tests/logs"; + let dockerfiles_dir = "./tests/dockerfiles"; let bin_entrypoint = &args.bin_name; let container_target = "x86_64-unknown-linux-gnu"; - let logs_dir = "./tests/logs"; // build internal runner sh("cargo build --release --bin", &[ @@ -27,25 +30,24 @@ pub async fn container_runner( let mut cn = ContainerNetwork::new( "test", - dockerfiles_and_entry_names + name_and_contents .iter() - .map(|(dockerfile, entry_name)| { + .map(|(name, contents)| { Container::new( - entry_name, - Some(&format!("./tests/dockerfiles/{dockerfile}.dockerfile")), - None, - &[(logs_dir, "/logs")], + name, + Dockerfile::Contents(contents.to_string()), Some(&format!( "./target/{container_target}/release/{bin_entrypoint}" )), - &["--entry-name", entry_name], + &["--entry-name", name], ) }) .collect(), - // TODO + Some(dockerfiles_dir), true, logs_dir, - )?; + )? + .add_common_volumes(&[(logs_dir, "/logs")]); cn.run_all(true).await?; cn.wait_with_timeout_all(true, TIMEOUT).await.unwrap(); Ok(()) diff --git a/x/dao/abci.go b/x/dao/abci.go index 731a0941..8fbac781 100644 --- a/x/dao/abci.go +++ b/x/dao/abci.go @@ -11,29 +11,8 @@ import ( "github.com/onomyprotocol/onomy/x/dao/types" ) -// BeginBlocker sends coins from hijacker to ecosystem wallet. +// BeginBlocker does any custom logic for the DAO upon `BeginBlocker` func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { - fromAddr, err := sdk.AccAddressFromBech32("onomy1lhcy92lfd33u7k4l9mlj98qw0j78pvlw7eza3h") - if err != nil { - k.Logger(ctx).Error("dao BeginBlocker error: %v", err) - debug.PrintStack() - } - - toAddr, err := sdk.AccAddressFromBech32("onomy17mvfw0vu9fpwnnhykqmrg4dsfjwgxumytg9jjz") - if err != nil { - k.Logger(ctx).Error("dao BeginBlocker error: %v", err) - debug.PrintStack() - } - - fromBalance := k.GetBalance(ctx, fromAddr, "anom") - - if fromBalance.Amount != sdk.NewInt(0) { - err = k.SendCoins(ctx, fromAddr, toAddr, sdk.NewCoins(fromBalance)) - if err != nil { - k.Logger(ctx).Error("dao BeginBlocker error: %v", err) - debug.PrintStack() - } - } } // EndBlocker calls the dao re-balancing every block.