mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
Compare commits
66 Commits
a58ed51deb
...
e3b7446a05
Author | SHA1 | Date | |
---|---|---|---|
|
e3b7446a05 | ||
|
d82675f503 | ||
|
8068bf7923 | ||
|
907eea75ef | ||
|
0934f2346f | ||
|
540e1a1734 | ||
|
08a50bcbd1 | ||
|
2862336f03 | ||
|
377fdd6778 | ||
|
49307038eb | ||
|
df10d41116 | ||
|
f0fbbb41cc | ||
|
f373f2590d | ||
|
e7d5d98d59 | ||
|
e7f1517146 | ||
|
077df745e5 | ||
|
5c71991b81 | ||
|
c575f8ba30 | ||
|
482057cf9f | ||
|
e3fcedd2b6 | ||
|
f66c922327 | ||
|
849335487e | ||
|
19dd651fe8 | ||
|
43a6812a34 | ||
|
fcb9042e74 | ||
|
bac49bffbf | ||
|
92fde64d1d | ||
|
4ef0aa0d44 | ||
|
cb81641f7d | ||
|
a1f4ff7070 | ||
|
c869eb01a5 | ||
|
149fa8b50b | ||
|
0751c15d9b | ||
|
7afeaf015d | ||
|
eb61c996ad | ||
|
613e2d459d | ||
|
5a5341adb9 | ||
|
fd66a420b7 | ||
|
b8b4a08235 | ||
|
8ac0f3ec27 | ||
|
ff340b4717 | ||
|
a4486a680e | ||
|
6609ea5293 | ||
|
67b6975c72 | ||
|
143dff2d9f | ||
|
191bfd72c2 | ||
|
bf9ab3fc7c | ||
|
7b4b4e1a32 | ||
|
3d18f3164f | ||
|
764794f5c5 | ||
|
3743e80727 | ||
|
5e5e003123 | ||
|
f6b7c1d56c | ||
|
e54c2f6fb8 | ||
|
b69e44123b | ||
|
7f625389a7 | ||
|
154b1af1c4 | ||
|
54425ab766 | ||
|
de2559f6cc | ||
|
54feea3d12 | ||
|
b8c8971119 | ||
|
4a55eb9259 | ||
|
64bff1b331 | ||
|
36281975c8 | ||
|
34625da5b4 | ||
|
a83a32d3d2 |
10
.github/mergify.yml
vendored
10
.github/mergify.yml
vendored
@ -26,7 +26,6 @@ pull_request_rules:
|
||||
- release/v0.23.x
|
||||
- release/v0.24.x
|
||||
- release/v0.25.x
|
||||
- release/v0.26.x
|
||||
|
||||
- name: Backport patches to the release/v0.17.x branch
|
||||
conditions:
|
||||
@ -90,12 +89,3 @@ pull_request_rules:
|
||||
backport:
|
||||
branches:
|
||||
- release/v0.25.x
|
||||
|
||||
- name: Backport patches to the release/v0.26.x branch
|
||||
conditions:
|
||||
- base=master
|
||||
- label=A:backport/v0.26.x
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- release/v0.26.x
|
||||
|
@ -33,7 +33,7 @@ kava config chain-id "${CHAIN_ID}"
|
||||
kava config keyring-backend test
|
||||
|
||||
# wait for transactions to be committed per CLI command
|
||||
kava config broadcast-mode sync
|
||||
kava config broadcast-mode block
|
||||
|
||||
# setup god's wallet
|
||||
echo "${KAVA_TESTNET_GOD_MNEMONIC}" | kava keys add --recover god
|
||||
|
23
.github/scripts/seed-internal-testnet.sh
vendored
23
.github/scripts/seed-internal-testnet.sh
vendored
@ -1,14 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
# by sleeping 1 block in between tx's
|
||||
# we can emulate the behavior of the
|
||||
# the deprecated and now removed (as of Kava 16)
|
||||
# broadcast mode of `block` in order to
|
||||
# minimize the chance tx's fail due to an
|
||||
# account sequence number mismatch
|
||||
AVG_SECONDS_BETWEEN_BLOCKS=6.5
|
||||
|
||||
# configure kava binary to talk to the desired chain endpoint
|
||||
kava config node "${CHAIN_API_URL}"
|
||||
kava config chain-id "${CHAIN_ID}"
|
||||
@ -17,7 +9,7 @@ kava config chain-id "${CHAIN_ID}"
|
||||
kava config keyring-backend test
|
||||
|
||||
# wait for transactions to be committed per CLI command
|
||||
kava config broadcast-mode sync
|
||||
kava config broadcast-mode block
|
||||
|
||||
# setup dev wallet
|
||||
echo "${DEV_WALLET_MNEMONIC}" | kava keys add --recover dev-wallet
|
||||
@ -31,8 +23,6 @@ echo "sweet ocean blush coil mobile ten floor sample nuclear power legend where
|
||||
# fund evm-contract-deployer account (using issuance)
|
||||
kava tx issuance issue 200000000ukava kava1van3znl6597xgwwh46jgquutnqkwvwszjg04fz --from dev-wallet --gas-prices 0.5ukava -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# deploy and fund USDC ERC20 contract
|
||||
MULTICHAIN_USDC_CONTRACT_DEPLOY=$(npx hardhat --network "${ERC20_DEPLOYER_NETWORK_NAME}" deploy-erc20 "USD Coin" USDC 6)
|
||||
MULTICHAIN_USDC_CONTRACT_ADDRESS=${MULTICHAIN_USDC_CONTRACT_DEPLOY: -42}
|
||||
@ -106,8 +96,6 @@ npx hardhat --network "${ERC20_DEPLOYER_NETWORK_NAME}" mint-erc20 "$TETHER_USDT_
|
||||
kava tx issuance issue 6000000000ukava kava1vlpsrmdyuywvaqrv7rx6xga224sqfwz3fyfhwq \
|
||||
--from dev-wallet --gas-prices 0.5ukava -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# parse space seperated list of validators
|
||||
# into bash array
|
||||
read -r -a GENESIS_VALIDATOR_ADDRESS_ARRAY <<<"$GENESIS_VALIDATOR_ADDRESSES"
|
||||
@ -115,14 +103,11 @@ read -r -a GENESIS_VALIDATOR_ADDRESS_ARRAY <<<"$GENESIS_VALIDATOR_ADDRESSES"
|
||||
# delegate 300KAVA to each validator
|
||||
for validator in "${GENESIS_VALIDATOR_ADDRESS_ARRAY[@]}"; do
|
||||
kava tx staking delegate "${validator}" 300000000ukava --from dev-wallet --gas-prices 0.5ukava -y
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
done
|
||||
|
||||
# create a text proposal
|
||||
kava tx gov submit-legacy-proposal --deposit 1000000000ukava --type "Text" --title "Example Proposal" --description "This is an example proposal" --gas auto --gas-adjustment 1.2 --from dev-wallet --gas-prices 0.01ukava -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# setup god's wallet
|
||||
echo "${KAVA_TESTNET_GOD_MNEMONIC}" | kava keys add --recover god
|
||||
|
||||
@ -174,13 +159,9 @@ printf "original evm util module params\n %s" , "$originalEvmUtilParams"
|
||||
# committee 1 is the stability committee. on internal testnet, this has only one member.
|
||||
kava tx committee submit-proposal 1 "$proposalFileName" --gas 2000000 --gas-prices 0.01ukava --from god -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# vote on the proposal. this assumes no other committee proposal has ever been submitted (id=1)
|
||||
kava tx committee vote 1 yes --gas 2000000 --gas-prices 0.01ukava --from god -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# fetch current module params
|
||||
updatedEvmUtilParams=$(curl https://api.app.internal.testnet.us-east.production.kava.io/kava/evmutil/v1beta1/params)
|
||||
printf "updated evm util module params\n %s" , "$updatedEvmUtilParams"
|
||||
@ -191,5 +172,3 @@ kava tx evmutil convert-cosmos-coin-to-erc20 \
|
||||
"$DEV_TEST_WALLET_ADDRESS" \
|
||||
1000000hard \
|
||||
--from dev-wallet --gas 2000000 --gas-prices 0.001ukava -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
23
.github/scripts/seed-protonet.sh
vendored
23
.github/scripts/seed-protonet.sh
vendored
@ -1,14 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
# by sleeping 1 block in between tx's
|
||||
# we can emulate the behavior of the
|
||||
# the deprecated and now removed (as of Kava 16)
|
||||
# broadcast mode of `block` in order to
|
||||
# minimize the chance tx's fail due to an
|
||||
# account sequence number mismatch
|
||||
AVG_SECONDS_BETWEEN_BLOCKS=6.5
|
||||
|
||||
# configure kava binary to talk to the desired chain endpoint
|
||||
kava config node "${CHAIN_API_URL}"
|
||||
kava config chain-id "${CHAIN_ID}"
|
||||
@ -17,7 +9,7 @@ kava config chain-id "${CHAIN_ID}"
|
||||
kava config keyring-backend test
|
||||
|
||||
# wait for transactions to be committed per CLI command
|
||||
kava config broadcast-mode sync
|
||||
kava config broadcast-mode block
|
||||
|
||||
# setup dev wallet
|
||||
echo "${DEV_WALLET_MNEMONIC}" | kava keys add --recover dev-wallet
|
||||
@ -31,13 +23,9 @@ echo "sweet ocean blush coil mobile ten floor sample nuclear power legend where
|
||||
# fund evm-contract-deployer account (using issuance)
|
||||
kava tx issuance issue 200000000ukava kava1van3znl6597xgwwh46jgquutnqkwvwszjg04fz --from dev-wallet --gas-prices 0.5ukava -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# fund 5k kava to x/community account
|
||||
kava tx community fund-community-pool 5000000000ukava --from dev-wallet --gas-prices 0.5ukava -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# deploy and fund USDC ERC20 contract
|
||||
MULTICHAIN_USDC_CONTRACT_DEPLOY=$(npx hardhat --network "${ERC20_DEPLOYER_NETWORK_NAME}" deploy-erc20 "USD Coin" USDC 6)
|
||||
MULTICHAIN_USDC_CONTRACT_ADDRESS=${MULTICHAIN_USDC_CONTRACT_DEPLOY: -42}
|
||||
@ -101,8 +89,6 @@ npx hardhat --network "${ERC20_DEPLOYER_NETWORK_NAME}" mint-erc20 "$AXL_USDC_CON
|
||||
kava tx issuance issue 6000000000ukava kava1vlpsrmdyuywvaqrv7rx6xga224sqfwz3fyfhwq \
|
||||
--from dev-wallet --gas-prices 0.5ukava -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# parse space seperated list of validators
|
||||
# into bash array
|
||||
read -r -a GENESIS_VALIDATOR_ADDRESS_ARRAY <<< "$GENESIS_VALIDATOR_ADDRESSES"
|
||||
@ -111,14 +97,11 @@ read -r -a GENESIS_VALIDATOR_ADDRESS_ARRAY <<< "$GENESIS_VALIDATOR_ADDRESSES"
|
||||
for validator in "${GENESIS_VALIDATOR_ADDRESS_ARRAY[@]}"
|
||||
do
|
||||
kava tx staking delegate "${validator}" 300000000ukava --from dev-wallet --gas-prices 0.5ukava -y
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
done
|
||||
|
||||
# create a text proposal
|
||||
kava tx gov submit-legacy-proposal --deposit 1000000000ukava --type "Text" --title "Example Proposal" --description "This is an example proposal" --gas auto --gas-adjustment 1.2 --from dev-wallet --gas-prices 0.01ukava -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# setup god's wallet
|
||||
echo "${KAVA_TESTNET_GOD_MNEMONIC}" | kava keys add --recover god
|
||||
|
||||
@ -167,13 +150,9 @@ printf "original evm util module params\n %s" , "$originalEvmUtilParams"
|
||||
# https://github.com/0glabs/0g-chain/pull/1556/files#diff-0bd6043650c708661f37bbe6fa5b29b52149e0ec0069103c3954168fc9f12612R900-R903
|
||||
kava tx committee submit-proposal 1 "$proposalFileName" --gas 2000000 --gas-prices 0.01ukava --from god -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# vote on the proposal. this assumes no other committee proposal has ever been submitted (id=1)
|
||||
kava tx committee vote 1 yes --gas 2000000 --gas-prices 0.01ukava --from god -y
|
||||
|
||||
sleep $AVG_SECONDS_BETWEEN_BLOCKS
|
||||
|
||||
# fetch current module params
|
||||
updatedEvmUtilParams=$(curl https://api.app.internal.testnet.us-east.production.kava.io/kava/evmutil/v1beta1/params)
|
||||
printf "updated evm util module params\n %s" , "$updatedEvmUtilParams"
|
||||
|
21
.github/workflows/cd-internal-testnet.yml
vendored
21
.github/workflows/cd-internal-testnet.yml
vendored
@ -1,6 +1,5 @@
|
||||
name: Continuous Deployment (Internal Testnet)
|
||||
# run after every successful CI job of new commits to the master branch
|
||||
# if deploy version or config has changed
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [Continuous Integration (Kava Master)]
|
||||
@ -8,23 +7,6 @@ on:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
changed_files:
|
||||
runs-on: ubuntu-latest
|
||||
# define output for first job forwarding output of changedInternalTestnetConfig job
|
||||
outputs:
|
||||
changedInternalTestnetConfig: ${{ steps.changed-internal-testnet-config.outputs.any_changed }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
|
||||
- name: Get all changed internal testnet files
|
||||
id: changed-internal-testnet-config
|
||||
uses: tj-actions/changed-files@v42
|
||||
with:
|
||||
# Avoid using single or double quotes for multiline patterns
|
||||
files: |
|
||||
ci/env/kava-internal-testnet/**
|
||||
|
||||
# in order:
|
||||
# enter standby (prevents autoscaling group from killing node during deploy)
|
||||
# stop kava
|
||||
@ -32,9 +14,8 @@ jobs:
|
||||
# download updated binary and genesis
|
||||
# reset application database state (only done on internal testnet)
|
||||
reset-chain-to-zero-state:
|
||||
needs: [changed_files]
|
||||
# only start cd pipeline if last ci run was successful
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' && needs.changed_files.outputs.changedInternalTestnetConfig == 'true' }}
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
uses: ./.github/workflows/cd-reset-internal-testnet.yml
|
||||
with:
|
||||
aws-region: us-east-1
|
||||
|
2
.github/workflows/cd-protonet-manual.yml
vendored
2
.github/workflows/cd-protonet-manual.yml
vendored
@ -10,6 +10,8 @@ jobs:
|
||||
# download updated binary and genesis
|
||||
# reset application database state (only done on internal testnet)
|
||||
reset-chain-to-zero-state:
|
||||
# only start cd pipeline if last ci run was successful
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
uses: ./.github/workflows/cd-reset-internal-testnet.yml
|
||||
with:
|
||||
aws-region: us-east-1
|
||||
|
4
.github/workflows/cd-seed-chain.yml
vendored
4
.github/workflows/cd-seed-chain.yml
vendored
@ -76,8 +76,8 @@ jobs:
|
||||
- name: compile default erc20 contracts
|
||||
run: make compile-contracts
|
||||
working-directory: kava-bridge
|
||||
- name: download seed script from current commit
|
||||
run: wget https://raw.githubusercontent.com/Kava-Labs/kava/${GITHUB_SHA}/.github/scripts/${SEED_SCRIPT_FILENAME} && chmod +x ${SEED_SCRIPT_FILENAME}
|
||||
- name: download seed script from master
|
||||
run: wget https://raw.githubusercontent.com/Kava-Labs/kava/master/.github/scripts/${SEED_SCRIPT_FILENAME} && chmod +x ${SEED_SCRIPT_FILENAME}
|
||||
working-directory: kava-bridge/contract
|
||||
env:
|
||||
SEED_SCRIPT_FILENAME: ${{ inputs.seed-script-filename }}
|
||||
|
@ -1,2 +1,2 @@
|
||||
golang 1.21
|
||||
golang 1.20
|
||||
nodejs 18.16.0
|
||||
|
15
CHANGELOG.md
15
CHANGELOG.md
@ -36,18 +36,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [v0.26.0]
|
||||
|
||||
### Features
|
||||
|
||||
- (cli) [#1785] Add `shard` CLI command to support creating partitions of data for standalone nodes
|
||||
- (cdp) [#1818] Add module param and logic for running x/cdp begin blocker every `n` blocks
|
||||
- (cli) [#1804] Add `rocksdb compact` command for manual DB compaction of state or blockstore
|
||||
- (cosmos-sdk) [#1811] [#1846] Upgrades app to cosmos-sdk v0.47.10 with iavl v1 support
|
||||
- (validator-vesting) [#1832] Add grpc query service to replace removed legacy querier
|
||||
- (incentive) [#1836] Update x/incentive cli to use grpc query client
|
||||
- (ibc) [#1839] Add ibc packet forward middleware for ibc transfers
|
||||
- (evmutil) [#1848] Update evm native conversion logic to handle bep3 assets
|
||||
- (cli) [#1804] Add `rocksdb compact` command for manual DB compaction of state or blockstore.
|
||||
- (cosmos-sdk) [#1811] Upgrades app to cosmos-sdk v0.47.7
|
||||
|
||||
## [v0.25.0]
|
||||
|
||||
@ -330,11 +324,6 @@ the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/CHANGELOG.md).
|
||||
- [#257](https://github.com/Kava-Labs/kava/pulls/257) Include scripts to run
|
||||
large-scale simulations remotely using aws-batch
|
||||
|
||||
[#1846]: https://github.com/Kava-Labs/kava/pull/1846
|
||||
[#1848]: https://github.com/Kava-Labs/kava/pull/1848
|
||||
[#1839]: https://github.com/Kava-Labs/kava/pull/1839
|
||||
[#1836]: https://github.com/Kava-Labs/kava/pull/1836
|
||||
[#1832]: https://github.com/Kava-Labs/kava/pull/1832
|
||||
[#1811]: https://github.com/Kava-Labs/kava/pull/1811
|
||||
[#1804]: https://github.com/Kava-Labs/kava/pull/1804
|
||||
[#1785]: https://github.com/Kava-Labs/kava/pull/1785
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM golang:1.21-alpine AS build-env
|
||||
FROM golang:1.20-alpine AS build-env
|
||||
|
||||
# Set up dependencies
|
||||
# bash, jq, curl for debugging
|
||||
|
208
app/app.go
208
app/app.go
@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
dbm "github.com/cometbft/cometbft-db"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
tmjson "github.com/cometbft/cometbft/libs/json"
|
||||
@ -77,9 +78,6 @@ import (
|
||||
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
|
||||
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
|
||||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward"
|
||||
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper"
|
||||
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
|
||||
transfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
|
||||
ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper"
|
||||
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
|
||||
@ -87,10 +85,9 @@ import (
|
||||
ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client"
|
||||
ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client"
|
||||
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
|
||||
ibcporttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
|
||||
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
|
||||
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
|
||||
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
|
||||
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
|
||||
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
|
||||
evmante "github.com/evmos/ethermint/app/ante"
|
||||
ethermintconfig "github.com/evmos/ethermint/server/config"
|
||||
@ -102,6 +99,11 @@ import (
|
||||
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||
tmlog "github.com/tendermint/tendermint/libs/log"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
chainparams "github.com/0glabs/0g-chain/app/params"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
@ -159,8 +161,6 @@ var (
|
||||
slashing.AppModuleBasic{},
|
||||
ibc.AppModuleBasic{},
|
||||
ibctm.AppModuleBasic{},
|
||||
solomachine.AppModuleBasic{},
|
||||
packetforward.AppModuleBasic{},
|
||||
upgrade.AppModuleBasic{},
|
||||
evidence.AppModuleBasic{},
|
||||
authzmodule.AppModuleBasic{},
|
||||
@ -177,7 +177,6 @@ var (
|
||||
mint.AppModuleBasic{},
|
||||
council.AppModuleBasic{},
|
||||
dasigners.AppModuleBasic{},
|
||||
consensus.AppModuleBasic{},
|
||||
)
|
||||
|
||||
// module account permissions
|
||||
@ -247,21 +246,28 @@ type App struct {
|
||||
crisisKeeper crisiskeeper.Keeper
|
||||
slashingKeeper slashingkeeper.Keeper
|
||||
ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
|
||||
packetForwardKeeper *packetforwardkeeper.Keeper
|
||||
evmKeeper *evmkeeper.Keeper
|
||||
evmutilKeeper evmutilkeeper.Keeper
|
||||
feeMarketKeeper feemarketkeeper.Keeper
|
||||
upgradeKeeper upgradekeeper.Keeper
|
||||
evidenceKeeper evidencekeeper.Keeper
|
||||
transferKeeper ibctransferkeeper.Keeper
|
||||
CouncilKeeper councilkeeper.Keeper
|
||||
kavadistKeeper kavadistkeeper.Keeper
|
||||
auctionKeeper auctionkeeper.Keeper
|
||||
issuanceKeeper issuancekeeper.Keeper
|
||||
bep3Keeper bep3keeper.Keeper
|
||||
pricefeedKeeper pricefeedkeeper.Keeper
|
||||
swapKeeper swapkeeper.Keeper
|
||||
cdpKeeper cdpkeeper.Keeper
|
||||
hardKeeper hardkeeper.Keeper
|
||||
committeeKeeper committeekeeper.Keeper
|
||||
vestingKeeper vestingkeeper.VestingKeeper
|
||||
incentiveKeeper incentivekeeper.Keeper
|
||||
savingsKeeper savingskeeper.Keeper
|
||||
liquidKeeper liquidkeeper.Keeper
|
||||
earnKeeper earnkeeper.Keeper
|
||||
routerKeeper routerkeeper.Keeper
|
||||
mintKeeper mintkeeper.Keeper
|
||||
dasignersKeeper dasignerskeeper.Keeper
|
||||
communityKeeper communitykeeper.Keeper
|
||||
consensusParamsKeeper consensusparamkeeper.Keeper
|
||||
|
||||
// make scoped keepers public for test purposes
|
||||
@ -302,17 +308,15 @@ func NewApp(
|
||||
|
||||
keys := sdk.NewKVStoreKeys(
|
||||
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
|
||||
distrtypes.StoreKey, slashingtypes.StoreKey, packetforwardtypes.StoreKey,
|
||||
distrtypes.StoreKey, slashingtypes.StoreKey,
|
||||
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey,
|
||||
upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey,
|
||||
evmtypes.StoreKey, feemarkettypes.StoreKey, authzkeeper.StoreKey,
|
||||
capabilitytypes.StoreKey,
|
||||
issuancetypes.StoreKey, bep3types.StoreKey, pricefeedtypes.StoreKey,
|
||||
committeetypes.StoreKey, evmutiltypes.StoreKey,
|
||||
minttypes.StoreKey,
|
||||
counciltypes.StoreKey,
|
||||
dasignerstypes.StoreKey,
|
||||
vestingtypes.StoreKey,
|
||||
swaptypes.StoreKey, cdptypes.StoreKey, hardtypes.StoreKey, communitytypes.StoreKey,
|
||||
committeetypes.StoreKey, incentivetypes.StoreKey, evmutiltypes.StoreKey,
|
||||
savingstypes.StoreKey, earntypes.StoreKey, minttypes.StoreKey,
|
||||
consensusparamtypes.StoreKey, crisistypes.StoreKey,
|
||||
)
|
||||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
|
||||
@ -349,9 +353,13 @@ func NewApp(
|
||||
issuanceSubspace := app.paramsKeeper.Subspace(issuancetypes.ModuleName)
|
||||
bep3Subspace := app.paramsKeeper.Subspace(bep3types.ModuleName)
|
||||
pricefeedSubspace := app.paramsKeeper.Subspace(pricefeedtypes.ModuleName)
|
||||
swapSubspace := app.paramsKeeper.Subspace(swaptypes.ModuleName)
|
||||
cdpSubspace := app.paramsKeeper.Subspace(cdptypes.ModuleName)
|
||||
hardSubspace := app.paramsKeeper.Subspace(hardtypes.ModuleName)
|
||||
incentiveSubspace := app.paramsKeeper.Subspace(incentivetypes.ModuleName)
|
||||
savingsSubspace := app.paramsKeeper.Subspace(savingstypes.ModuleName)
|
||||
ibcSubspace := app.paramsKeeper.Subspace(ibcexported.ModuleName)
|
||||
ibctransferSubspace := app.paramsKeeper.Subspace(ibctransfertypes.ModuleName)
|
||||
packetforwardSubspace := app.paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable())
|
||||
feemarketSubspace := app.paramsKeeper.Subspace(feemarkettypes.ModuleName)
|
||||
evmSubspace := app.paramsKeeper.Subspace(evmtypes.ModuleName)
|
||||
evmutilSubspace := app.paramsKeeper.Subspace(evmutiltypes.ModuleName)
|
||||
@ -389,8 +397,9 @@ func NewApp(
|
||||
keys[stakingtypes.StoreKey],
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
app.vestingKeeper,
|
||||
govAuthAddrStr,
|
||||
app.vestingKeeper,
|
||||
stakingSubspace,
|
||||
)
|
||||
app.authzKeeper = authzkeeper.NewKeeper(
|
||||
keys[authzkeeper.StoreKey],
|
||||
@ -485,49 +494,23 @@ func NewApp(
|
||||
|
||||
app.evmutilKeeper.SetEvmKeeper(app.evmKeeper)
|
||||
|
||||
// It's important to note that the PFM Keeper must be initialized before the Transfer Keeper
|
||||
app.packetForwardKeeper = packetforwardkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[packetforwardtypes.StoreKey],
|
||||
nil, // will be zero-value here, reference is set later on with SetTransferKeeper.
|
||||
app.ibcKeeper.ChannelKeeper,
|
||||
app.distrKeeper,
|
||||
app.bankKeeper,
|
||||
app.ibcKeeper.ChannelKeeper,
|
||||
govAuthAddrStr,
|
||||
)
|
||||
|
||||
app.transferKeeper = ibctransferkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[ibctransfertypes.StoreKey],
|
||||
ibctransferSubspace,
|
||||
app.packetForwardKeeper,
|
||||
app.ibcKeeper.ChannelKeeper,
|
||||
app.ibcKeeper.ChannelKeeper,
|
||||
&app.ibcKeeper.PortKeeper,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
scopedTransferKeeper,
|
||||
)
|
||||
app.packetForwardKeeper.SetTransferKeeper(app.transferKeeper)
|
||||
transferModule := transfer.NewAppModule(app.transferKeeper)
|
||||
|
||||
// allow ibc packet forwarding for ibc transfers.
|
||||
// transfer stack contains (from top to bottom):
|
||||
// - Packet Forward Middleware
|
||||
// - Transfer
|
||||
var transferStack ibcporttypes.IBCModule
|
||||
transferStack = transfer.NewIBCModule(app.transferKeeper)
|
||||
transferStack = packetforward.NewIBCMiddleware(
|
||||
transferStack,
|
||||
app.packetForwardKeeper,
|
||||
0, // retries on timeout
|
||||
packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
|
||||
packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
|
||||
)
|
||||
transferIBCModule := transfer.NewIBCModule(app.transferKeeper)
|
||||
|
||||
// Create static IBC router, add transfer route, then set and seal it
|
||||
ibcRouter := ibcporttypes.NewRouter()
|
||||
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack)
|
||||
ibcRouter := porttypes.NewRouter()
|
||||
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
|
||||
app.ibcKeeper.SetRouter(ibcRouter)
|
||||
|
||||
app.issuanceKeeper = issuancekeeper.NewKeeper(
|
||||
@ -550,6 +533,68 @@ func NewApp(
|
||||
keys[pricefeedtypes.StoreKey],
|
||||
pricefeedSubspace,
|
||||
)
|
||||
swapKeeper := swapkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[swaptypes.StoreKey],
|
||||
swapSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
)
|
||||
cdpKeeper := cdpkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[cdptypes.StoreKey],
|
||||
cdpSubspace,
|
||||
app.pricefeedKeeper,
|
||||
app.auctionKeeper,
|
||||
app.bankKeeper,
|
||||
app.accountKeeper,
|
||||
mAccPerms,
|
||||
)
|
||||
hardKeeper := hardkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[hardtypes.StoreKey],
|
||||
hardSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
app.pricefeedKeeper,
|
||||
app.auctionKeeper,
|
||||
)
|
||||
app.liquidKeeper = liquidkeeper.NewDefaultKeeper(
|
||||
appCodec,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
app.stakingKeeper,
|
||||
&app.distrKeeper,
|
||||
)
|
||||
savingsKeeper := savingskeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[savingstypes.StoreKey],
|
||||
savingsSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
app.liquidKeeper,
|
||||
)
|
||||
earnKeeper := earnkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[earntypes.StoreKey],
|
||||
earnSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
&app.liquidKeeper,
|
||||
&hardKeeper,
|
||||
&savingsKeeper,
|
||||
&app.distrKeeper,
|
||||
)
|
||||
|
||||
app.kavadistKeeper = kavadistkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[kavadisttypes.StoreKey],
|
||||
kavadistSubspace,
|
||||
app.bankKeeper,
|
||||
app.accountKeeper,
|
||||
app.distrKeeper,
|
||||
app.loadBlockedMaccAddrs(),
|
||||
)
|
||||
|
||||
app.mintKeeper = mintkeeper.NewKeeper(
|
||||
appCodec,
|
||||
@ -561,6 +606,44 @@ func NewApp(
|
||||
govAuthAddrStr,
|
||||
)
|
||||
|
||||
// x/community's deposit/withdraw to lend proposals depend on hard keeper.
|
||||
app.communityKeeper = communitykeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[communitytypes.StoreKey],
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
&cdpKeeper,
|
||||
app.distrKeeper,
|
||||
&hardKeeper,
|
||||
&app.mintKeeper,
|
||||
&app.kavadistKeeper,
|
||||
app.stakingKeeper,
|
||||
govAuthAddr,
|
||||
)
|
||||
|
||||
app.incentiveKeeper = incentivekeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[incentivetypes.StoreKey],
|
||||
incentiveSubspace,
|
||||
app.bankKeeper,
|
||||
&cdpKeeper,
|
||||
&hardKeeper,
|
||||
app.accountKeeper,
|
||||
app.stakingKeeper,
|
||||
&swapKeeper,
|
||||
&savingsKeeper,
|
||||
&app.liquidKeeper,
|
||||
&earnKeeper,
|
||||
app.mintKeeper,
|
||||
app.distrKeeper,
|
||||
app.pricefeedKeeper,
|
||||
)
|
||||
app.routerKeeper = routerkeeper.NewKeeper(
|
||||
&app.earnKeeper,
|
||||
app.liquidKeeper,
|
||||
app.stakingKeeper,
|
||||
)
|
||||
|
||||
// create committee keeper with router
|
||||
committeeGovRouter := govv1beta1.NewRouter()
|
||||
committeeGovRouter.
|
||||
@ -583,6 +666,7 @@ func NewApp(
|
||||
stakingtypes.NewMultiStakingHooks(
|
||||
app.distrKeeper.Hooks(),
|
||||
app.slashingKeeper.Hooks(),
|
||||
app.incentiveKeeper.Hooks(),
|
||||
))
|
||||
|
||||
// create gov keeper with router
|
||||
@ -593,6 +677,9 @@ func NewApp(
|
||||
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
|
||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.upgradeKeeper)).
|
||||
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper)).
|
||||
AddRoute(earntypes.RouterKey, earn.NewCommunityPoolProposalHandler(app.earnKeeper)).
|
||||
AddRoute(communitytypes.RouterKey, community.NewCommunityPoolProposalHandler(app.communityKeeper)).
|
||||
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)).
|
||||
AddRoute(committeetypes.RouterKey, committee.NewProposalHandler(app.committeeKeeper))
|
||||
|
||||
govConfig := govtypes.DefaultConfig()
|
||||
@ -611,7 +698,8 @@ func NewApp(
|
||||
|
||||
// override x/gov tally handler with custom implementation
|
||||
tallyHandler := NewTallyHandler(
|
||||
app.govKeeper, *app.stakingKeeper, app.bankKeeper,
|
||||
app.govKeeper, *app.stakingKeeper, app.savingsKeeper, app.earnKeeper,
|
||||
app.liquidKeeper, app.bankKeeper,
|
||||
)
|
||||
app.govKeeper.SetTallyHandler(tallyHandler)
|
||||
|
||||
@ -634,13 +722,12 @@ func NewApp(
|
||||
slashing.NewAppModule(appCodec, app.slashingKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper, slashingSubspace),
|
||||
consensus.NewAppModule(appCodec, app.consensusParamsKeeper),
|
||||
ibc.NewAppModule(app.ibcKeeper),
|
||||
packetforward.NewAppModule(app.packetForwardKeeper, packetforwardSubspace),
|
||||
evm.NewAppModule(app.evmKeeper, app.accountKeeper),
|
||||
feemarket.NewAppModule(app.feeMarketKeeper, feemarketSubspace),
|
||||
upgrade.NewAppModule(&app.upgradeKeeper),
|
||||
evidence.NewAppModule(app.evidenceKeeper),
|
||||
transferModule,
|
||||
vesting.NewAppModule(app.accountKeeper, app.bankKeeper, app.vestingKeeper),
|
||||
vesting.NewAppModule(app.accountKeeper, app.vestingKeeper),
|
||||
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
|
||||
issuance.NewAppModule(app.issuanceKeeper, app.accountKeeper, app.bankKeeper),
|
||||
bep3.NewAppModule(app.bep3Keeper, app.accountKeeper, app.bankKeeper),
|
||||
@ -650,6 +737,8 @@ func NewApp(
|
||||
evmutil.NewAppModule(app.evmutilKeeper, app.bankKeeper, app.accountKeeper),
|
||||
// nil InflationCalculationFn, use SDK's default inflation function
|
||||
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, nil, mintSubspace),
|
||||
community.NewAppModule(app.communityKeeper, app.accountKeeper),
|
||||
metrics.NewAppModule(options.TelemetryOptions),
|
||||
)
|
||||
|
||||
// Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
@ -677,6 +766,7 @@ func NewApp(
|
||||
// It should be run before cdp begin blocker which cancels out debt with stable and starts more auctions.
|
||||
bep3types.ModuleName,
|
||||
issuancetypes.ModuleName,
|
||||
incentivetypes.ModuleName,
|
||||
ibcexported.ModuleName,
|
||||
// Add all remaining modules with an empty begin blocker below since cosmos 0.45.0 requires it
|
||||
vestingtypes.ModuleName,
|
||||
@ -691,8 +781,11 @@ func NewApp(
|
||||
paramstypes.ModuleName,
|
||||
authz.ModuleName,
|
||||
evmutiltypes.ModuleName,
|
||||
savingstypes.ModuleName,
|
||||
liquidtypes.ModuleName,
|
||||
earntypes.ModuleName,
|
||||
routertypes.ModuleName,
|
||||
consensusparamtypes.ModuleName,
|
||||
packetforwardtypes.ModuleName,
|
||||
)
|
||||
|
||||
// Warning: Some end blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
@ -724,8 +817,9 @@ func NewApp(
|
||||
authz.ModuleName,
|
||||
evmutiltypes.ModuleName,
|
||||
minttypes.ModuleName,
|
||||
communitytypes.ModuleName,
|
||||
metricstypes.ModuleName,
|
||||
consensusparamtypes.ModuleName,
|
||||
packetforwardtypes.ModuleName,
|
||||
)
|
||||
|
||||
// Warning: Some init genesis methods must run before others. Ensure the dependencies are understood before modifying this list
|
||||
@ -755,8 +849,10 @@ func NewApp(
|
||||
paramstypes.ModuleName,
|
||||
upgradetypes.ModuleName,
|
||||
validatorvestingtypes.ModuleName,
|
||||
liquidtypes.ModuleName,
|
||||
routertypes.ModuleName,
|
||||
metricstypes.ModuleName,
|
||||
consensusparamtypes.ModuleName,
|
||||
packetforwardtypes.ModuleName,
|
||||
crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules
|
||||
)
|
||||
|
||||
|
@ -18,11 +18,13 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
|
||||
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
|
||||
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
db "github.com/tendermint/tm-db"
|
||||
)
|
||||
|
||||
func TestNewApp(t *testing.T) {
|
||||
@ -153,7 +155,7 @@ func unmarshalJSONKeys(jsonBytes []byte) ([]string, error) {
|
||||
func removeIbcTmModule(modules []string) []string {
|
||||
var result []string
|
||||
for _, str := range modules {
|
||||
if str != ibctm.ModuleName && str != solomachine.ModuleName {
|
||||
if str != ibctm.ModuleName {
|
||||
result = append(result, str)
|
||||
}
|
||||
}
|
||||
|
279
app/upgrades.go
279
app/upgrades.go
@ -3,44 +3,72 @@ package app
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
|
||||
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
|
||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
|
||||
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
|
||||
ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations"
|
||||
)
|
||||
|
||||
const (
|
||||
UpgradeName_Mainnet = "v0.26.0"
|
||||
UpgradeName_Testnet = "v0.26.0-alpha.0"
|
||||
UpgradeName_Mainnet = "v0.25.0"
|
||||
UpgradeName_Testnet = "v0.25.0-alpha.0"
|
||||
UpgradeName_E2ETest = "v0.25.0-testing"
|
||||
)
|
||||
|
||||
CDPLiquidationBlockInterval = int64(50)
|
||||
var (
|
||||
// KAVA to ukava - 6 decimals
|
||||
kavaConversionFactor = sdk.NewInt(1000_000)
|
||||
secondsPerYear = sdk.NewInt(365 * 24 * 60 * 60)
|
||||
|
||||
// 10 Million KAVA per year in staking rewards, inflation disable time 2024-01-01T00:00:00 UTC
|
||||
// CommunityParams_Mainnet = communitytypes.NewParams(
|
||||
// time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
// // before switchover
|
||||
// sdkmath.LegacyZeroDec(),
|
||||
// // after switchover - 10M KAVA to ukava per year / seconds per year
|
||||
// sdkmath.LegacyNewDec(10_000_000).
|
||||
// MulInt(kavaConversionFactor).
|
||||
// QuoInt(secondsPerYear),
|
||||
// )
|
||||
|
||||
// Testnet -- 15 Trillion KAVA per year in staking rewards, inflation disable time 2023-11-16T00:00:00 UTC
|
||||
// CommunityParams_Testnet = communitytypes.NewParams(
|
||||
// time.Date(2023, 11, 16, 0, 0, 0, 0, time.UTC),
|
||||
// // before switchover
|
||||
// sdkmath.LegacyZeroDec(),
|
||||
// // after switchover
|
||||
// sdkmath.LegacyNewDec(15_000_000).
|
||||
// MulInt64(1_000_000). // 15M * 1M = 15T
|
||||
// MulInt(kavaConversionFactor).
|
||||
// QuoInt(secondsPerYear),
|
||||
// )
|
||||
|
||||
// CommunityParams_E2E = communitytypes.NewParams(
|
||||
// time.Now().Add(10*time.Second).UTC(), // relative time for testing
|
||||
// sdkmath.LegacyNewDec(0), // stakingRewardsPerSecond
|
||||
// sdkmath.LegacyNewDec(1000), // upgradeTimeSetstakingRewardsPerSecond
|
||||
// )
|
||||
|
||||
// ValidatorMinimumCommission is the new 5% minimum commission rate for validators
|
||||
ValidatorMinimumCommission = sdk.NewDecWithPrec(5, 2)
|
||||
)
|
||||
|
||||
// RegisterUpgradeHandlers registers the upgrade handlers for the app.
|
||||
func (app App) RegisterUpgradeHandlers() {
|
||||
app.upgradeKeeper.SetUpgradeHandler(
|
||||
UpgradeName_Mainnet,
|
||||
upgradeHandler(app, UpgradeName_Mainnet),
|
||||
)
|
||||
app.upgradeKeeper.SetUpgradeHandler(
|
||||
UpgradeName_Testnet,
|
||||
upgradeHandler(app, UpgradeName_Testnet),
|
||||
)
|
||||
// app.upgradeKeeper.SetUpgradeHandler(
|
||||
// UpgradeName_Mainnet,
|
||||
// upgradeHandler(app, UpgradeName_Mainnet, CommunityParams_Mainnet),
|
||||
// )
|
||||
// app.upgradeKeeper.SetUpgradeHandler(
|
||||
// UpgradeName_Testnet,
|
||||
// upgradeHandler(app, UpgradeName_Testnet, CommunityParams_Testnet),
|
||||
// )
|
||||
// app.upgradeKeeper.SetUpgradeHandler(
|
||||
// UpgradeName_E2ETest,
|
||||
// upgradeHandler(app, UpgradeName_Testnet, CommunityParams_E2E),
|
||||
// )
|
||||
|
||||
upgradeInfo, err := app.upgradeKeeper.ReadUpgradeInfoFromDisk()
|
||||
if err != nil {
|
||||
@ -48,14 +76,14 @@ func (app App) RegisterUpgradeHandlers() {
|
||||
}
|
||||
|
||||
doUpgrade := upgradeInfo.Name == UpgradeName_Mainnet ||
|
||||
upgradeInfo.Name == UpgradeName_Testnet
|
||||
upgradeInfo.Name == UpgradeName_Testnet ||
|
||||
upgradeInfo.Name == UpgradeName_E2ETest
|
||||
|
||||
if doUpgrade && !app.upgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
|
||||
storeUpgrades := storetypes.StoreUpgrades{
|
||||
Added: []string{
|
||||
crisistypes.ModuleName,
|
||||
consensustypes.ModuleName,
|
||||
packetforwardtypes.ModuleName,
|
||||
// x/community added store
|
||||
// communitytypes.ModuleName,
|
||||
},
|
||||
}
|
||||
|
||||
@ -68,6 +96,7 @@ func (app App) RegisterUpgradeHandlers() {
|
||||
func upgradeHandler(
|
||||
app App,
|
||||
name string,
|
||||
// communityParams communitytypes.Params,
|
||||
) upgradetypes.UpgradeHandler {
|
||||
return func(
|
||||
ctx sdk.Context,
|
||||
@ -76,58 +105,154 @@ func upgradeHandler(
|
||||
) (module.VersionMap, error) {
|
||||
app.Logger().Info(fmt.Sprintf("running %s upgrade handler", name))
|
||||
|
||||
baseAppLegacySS := app.paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
|
||||
|
||||
// Set param key table for params module migration
|
||||
for _, subspace := range app.paramsKeeper.GetSubspaces() {
|
||||
subspace := subspace
|
||||
var keyTable paramstypes.KeyTable
|
||||
switch subspace.Name() {
|
||||
// sdk
|
||||
case authtypes.ModuleName:
|
||||
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck
|
||||
case banktypes.ModuleName:
|
||||
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck,nolintlint
|
||||
case stakingtypes.ModuleName:
|
||||
keyTable = stakingtypes.ParamKeyTable()
|
||||
case minttypes.ModuleName:
|
||||
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck
|
||||
case distrtypes.ModuleName:
|
||||
keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck,nolintlint
|
||||
case slashingtypes.ModuleName:
|
||||
keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck
|
||||
case govtypes.ModuleName:
|
||||
keyTable = govv1.ParamKeyTable() //nolint:staticcheck
|
||||
case crisistypes.ModuleName:
|
||||
keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck
|
||||
|
||||
// ibc
|
||||
case ibctransfertypes.ModuleName:
|
||||
keyTable = ibctransfertypes.ParamKeyTable() //nolint:staticcheck
|
||||
|
||||
default:
|
||||
continue
|
||||
}
|
||||
if !subspace.HasKeyTable() {
|
||||
// NOTE: This modifies the internal map used to store the key table entries
|
||||
// which is a pointer.
|
||||
subspace.WithKeyTable(keyTable)
|
||||
}
|
||||
toVM, err := app.mm.RunMigrations(ctx, app.configurator, fromVM)
|
||||
if err != nil {
|
||||
return toVM, err
|
||||
}
|
||||
|
||||
// optional migration: prune expired tendermint consensus states to save storage space
|
||||
// see https://github.com/cosmos/ibc-go/blob/v7.2.0/docs/migrations/v6-to-v7.md#chains
|
||||
if _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, app.appCodec, app.ibcKeeper.ClientKeeper); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//
|
||||
// Staking validator minimum commission
|
||||
//
|
||||
UpdateValidatorMinimumCommission(ctx, app)
|
||||
|
||||
// migrate tendermint consensus parameters from x/params module to a
|
||||
// dedicated x/consensus module.
|
||||
baseapp.MigrateParams(ctx, baseAppLegacySS, &app.consensusParamsKeeper)
|
||||
//
|
||||
// Community Params
|
||||
//
|
||||
// app.communityKeeper.SetParams(ctx, communityParams)
|
||||
// app.Logger().Info(
|
||||
// "initialized x/community params",
|
||||
// "UpgradeTimeDisableInflation", communityParams.UpgradeTimeDisableInflation,
|
||||
// "StakingRewardsPerSecond", communityParams.StakingRewardsPerSecond,
|
||||
// "UpgradeTimeSetStakingRewardsPerSecond", communityParams.UpgradeTimeSetStakingRewardsPerSecond,
|
||||
// )
|
||||
|
||||
// run migrations for all modules and return new consensus version map
|
||||
versionMap, err := app.mm.RunMigrations(ctx, app.configurator, fromVM)
|
||||
//
|
||||
// Kavadist gov grant
|
||||
//
|
||||
// msgGrant, err := authz.NewMsgGrant(
|
||||
// app.accountKeeper.GetModuleAddress(kavadisttypes.ModuleName), // granter
|
||||
// app.accountKeeper.GetModuleAddress(govtypes.ModuleName), // grantee
|
||||
// authz.NewGenericAuthorization(sdk.MsgTypeURL(&banktypes.MsgSend{})), // authorization
|
||||
// nil, // expiration
|
||||
// )
|
||||
// if err != nil {
|
||||
// return toVM, err
|
||||
// }
|
||||
// _, err = app.authzKeeper.Grant(ctx, msgGrant)
|
||||
// if err != nil {
|
||||
// return toVM, err
|
||||
// }
|
||||
// app.Logger().Info("created gov grant for kavadist funds")
|
||||
|
||||
return versionMap, err
|
||||
//
|
||||
// Gov Quorum
|
||||
//
|
||||
govTallyParams := app.govKeeper.GetTallyParams(ctx)
|
||||
oldQuorum := govTallyParams.Quorum
|
||||
govTallyParams.Quorum = sdkmath.LegacyMustNewDecFromStr("0.2").String()
|
||||
app.govKeeper.SetTallyParams(ctx, govTallyParams)
|
||||
app.Logger().Info(fmt.Sprintf("updated tally quorum from %s to %s", oldQuorum, govTallyParams.Quorum))
|
||||
|
||||
//
|
||||
// Incentive Params
|
||||
//
|
||||
UpdateIncentiveParams(ctx, app)
|
||||
|
||||
return toVM, nil
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateValidatorMinimumCommission updates the commission rate for all
|
||||
// validators to be at least the new min commission rate, and sets the minimum
|
||||
// commission rate in the staking params.
|
||||
func UpdateValidatorMinimumCommission(
|
||||
ctx sdk.Context,
|
||||
app App,
|
||||
) {
|
||||
resultCount := make(map[stakingtypes.BondStatus]int)
|
||||
|
||||
// Iterate over *all* validators including inactive
|
||||
app.stakingKeeper.IterateValidators(
|
||||
ctx,
|
||||
func(index int64, validator stakingtypes.ValidatorI) (stop bool) {
|
||||
// Skip if validator commission is already >= 5%
|
||||
if validator.GetCommission().GTE(ValidatorMinimumCommission) {
|
||||
return false
|
||||
}
|
||||
|
||||
val, ok := validator.(stakingtypes.Validator)
|
||||
if !ok {
|
||||
panic("expected stakingtypes.Validator")
|
||||
}
|
||||
|
||||
// Set minimum commission rate to 5%, when commission is < 5%
|
||||
val.Commission.Rate = ValidatorMinimumCommission
|
||||
val.Commission.UpdateTime = ctx.BlockTime()
|
||||
|
||||
// Update MaxRate if necessary
|
||||
if val.Commission.MaxRate.LT(ValidatorMinimumCommission) {
|
||||
val.Commission.MaxRate = ValidatorMinimumCommission
|
||||
}
|
||||
|
||||
if err := app.stakingKeeper.BeforeValidatorModified(ctx, val.GetOperator()); err != nil {
|
||||
panic(fmt.Sprintf("failed to call BeforeValidatorModified: %s", err))
|
||||
}
|
||||
app.stakingKeeper.SetValidator(ctx, val)
|
||||
|
||||
// Keep track of counts just for logging purposes
|
||||
switch val.GetStatus() {
|
||||
case stakingtypes.Bonded:
|
||||
resultCount[stakingtypes.Bonded]++
|
||||
case stakingtypes.Unbonded:
|
||||
resultCount[stakingtypes.Unbonded]++
|
||||
case stakingtypes.Unbonding:
|
||||
resultCount[stakingtypes.Unbonding]++
|
||||
}
|
||||
|
||||
return false
|
||||
},
|
||||
)
|
||||
|
||||
app.Logger().Info(
|
||||
"updated validator minimum commission rate for all existing validators",
|
||||
stakingtypes.BondStatusBonded, resultCount[stakingtypes.Bonded],
|
||||
stakingtypes.BondStatusUnbonded, resultCount[stakingtypes.Unbonded],
|
||||
stakingtypes.BondStatusUnbonding, resultCount[stakingtypes.Unbonding],
|
||||
)
|
||||
|
||||
stakingParams := app.stakingKeeper.GetParams(ctx)
|
||||
stakingParams.MinCommissionRate = ValidatorMinimumCommission
|
||||
app.stakingKeeper.SetParams(ctx, stakingParams)
|
||||
|
||||
app.Logger().Info(
|
||||
"updated x/staking params minimum commission rate",
|
||||
"MinCommissionRate", stakingParams.MinCommissionRate,
|
||||
)
|
||||
}
|
||||
|
||||
// UpdateIncentiveParams modifies the earn rewards period for bkava to be 600K KAVA per year.
|
||||
func UpdateIncentiveParams(
|
||||
ctx sdk.Context,
|
||||
app App,
|
||||
) {
|
||||
// incentiveParams := app.incentiveKeeper.GetParams(ctx)
|
||||
|
||||
// bkava annualized rewards: 600K KAVA
|
||||
// newAmount := sdkmath.LegacyNewDec(600_000).
|
||||
// MulInt(kavaConversionFactor).
|
||||
// QuoInt(secondsPerYear).
|
||||
// TruncateInt()
|
||||
|
||||
// for i := range incentiveParams.EarnRewardPeriods {
|
||||
// if incentiveParams.EarnRewardPeriods[i].CollateralType != "bkava" {
|
||||
// continue
|
||||
// }
|
||||
|
||||
// // Update rewards per second via index
|
||||
// incentiveParams.EarnRewardPeriods[i].RewardsPerSecond = sdk.NewCoins(
|
||||
// sdk.NewCoin("ukava", newAmount),
|
||||
// )
|
||||
// }
|
||||
|
||||
// app.incentiveKeeper.SetParams(ctx, incentiveParams)
|
||||
}
|
||||
|
239
app/upgrades_test.go
Normal file
239
app/upgrades_test.go
Normal file
@ -0,0 +1,239 @@
|
||||
package app_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/evmos/ethermint/crypto/ethsecp256k1"
|
||||
"github.com/stretchr/testify/require"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
)
|
||||
|
||||
// func TestUpgradeCommunityParams_Mainnet(t *testing.T) {
|
||||
// require.Equal(
|
||||
// t,
|
||||
// sdkmath.LegacyZeroDec().String(),
|
||||
// app.CommunityParams_Mainnet.StakingRewardsPerSecond.String(),
|
||||
// )
|
||||
|
||||
// require.Equal(
|
||||
// t,
|
||||
// // Manually confirmed
|
||||
// "317097.919837645865043125",
|
||||
// app.CommunityParams_Mainnet.UpgradeTimeSetStakingRewardsPerSecond.String(),
|
||||
// "mainnet kava per second should be correct",
|
||||
// )
|
||||
// }
|
||||
|
||||
// func TestUpgradeCommunityParams_Testnet(t *testing.T) {
|
||||
// require.Equal(
|
||||
// t,
|
||||
// sdkmath.LegacyZeroDec().String(),
|
||||
// app.CommunityParams_Testnet.StakingRewardsPerSecond.String(),
|
||||
// )
|
||||
|
||||
// require.Equal(
|
||||
// t,
|
||||
// // Manually confirmed
|
||||
// "475646879756.468797564687975646",
|
||||
// app.CommunityParams_Testnet.UpgradeTimeSetStakingRewardsPerSecond.String(),
|
||||
// "testnet kava per second should be correct",
|
||||
// )
|
||||
// }
|
||||
|
||||
func TestUpdateValidatorMinimumCommission(t *testing.T) {
|
||||
tApp := app.NewTestApp()
|
||||
tApp.InitializeFromGenesisStates()
|
||||
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
||||
|
||||
sk := tApp.GetStakingKeeper()
|
||||
stakingParams := sk.GetParams(ctx)
|
||||
stakingParams.MinCommissionRate = sdk.ZeroDec()
|
||||
sk.SetParams(ctx, stakingParams)
|
||||
|
||||
// Set some validators with varying commission rates
|
||||
|
||||
vals := []struct {
|
||||
name string
|
||||
operatorAddr sdk.ValAddress
|
||||
consPriv *ethsecp256k1.PrivKey
|
||||
commissionRateMin sdk.Dec
|
||||
commissionRateMax sdk.Dec
|
||||
shouldBeUpdated bool
|
||||
}{
|
||||
{
|
||||
name: "zero commission rate",
|
||||
operatorAddr: sdk.ValAddress("val0"),
|
||||
consPriv: generateConsKey(t),
|
||||
commissionRateMin: sdk.ZeroDec(),
|
||||
commissionRateMax: sdk.ZeroDec(),
|
||||
shouldBeUpdated: true,
|
||||
},
|
||||
{
|
||||
name: "0.01 commission rate",
|
||||
operatorAddr: sdk.ValAddress("val1"),
|
||||
consPriv: generateConsKey(t),
|
||||
commissionRateMin: sdk.MustNewDecFromStr("0.01"),
|
||||
commissionRateMax: sdk.MustNewDecFromStr("0.01"),
|
||||
shouldBeUpdated: true,
|
||||
},
|
||||
{
|
||||
name: "0.05 commission rate",
|
||||
operatorAddr: sdk.ValAddress("val2"),
|
||||
consPriv: generateConsKey(t),
|
||||
commissionRateMin: sdk.MustNewDecFromStr("0.05"),
|
||||
commissionRateMax: sdk.MustNewDecFromStr("0.05"),
|
||||
shouldBeUpdated: false,
|
||||
},
|
||||
{
|
||||
name: "0.06 commission rate",
|
||||
operatorAddr: sdk.ValAddress("val3"),
|
||||
consPriv: generateConsKey(t),
|
||||
commissionRateMin: sdk.MustNewDecFromStr("0.06"),
|
||||
commissionRateMax: sdk.MustNewDecFromStr("0.06"),
|
||||
shouldBeUpdated: false,
|
||||
},
|
||||
{
|
||||
name: "0.5 commission rate",
|
||||
operatorAddr: sdk.ValAddress("val4"),
|
||||
consPriv: generateConsKey(t),
|
||||
commissionRateMin: sdk.MustNewDecFromStr("0.5"),
|
||||
commissionRateMax: sdk.MustNewDecFromStr("0.5"),
|
||||
shouldBeUpdated: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, v := range vals {
|
||||
val, err := stakingtypes.NewValidator(
|
||||
v.operatorAddr,
|
||||
v.consPriv.PubKey(),
|
||||
stakingtypes.Description{},
|
||||
)
|
||||
require.NoError(t, err)
|
||||
val.Commission.Rate = v.commissionRateMin
|
||||
val.Commission.MaxRate = v.commissionRateMax
|
||||
|
||||
err = sk.SetValidatorByConsAddr(ctx, val)
|
||||
require.NoError(t, err)
|
||||
sk.SetValidator(ctx, val)
|
||||
}
|
||||
|
||||
require.NotPanics(
|
||||
t, func() {
|
||||
app.UpdateValidatorMinimumCommission(ctx, tApp.App)
|
||||
},
|
||||
)
|
||||
|
||||
stakingParamsAfter := sk.GetParams(ctx)
|
||||
require.Equal(t, stakingParamsAfter.MinCommissionRate, app.ValidatorMinimumCommission)
|
||||
|
||||
// Check that all validators have a commission rate >= 5%
|
||||
for _, val := range vals {
|
||||
t.Run(val.name, func(t *testing.T) {
|
||||
validator, found := sk.GetValidator(ctx, val.operatorAddr)
|
||||
require.True(t, found, "validator should be found")
|
||||
|
||||
require.True(
|
||||
t,
|
||||
validator.GetCommission().GTE(app.ValidatorMinimumCommission),
|
||||
"commission rate should be >= 5%",
|
||||
)
|
||||
|
||||
require.True(
|
||||
t,
|
||||
validator.Commission.MaxRate.GTE(app.ValidatorMinimumCommission),
|
||||
"commission rate max should be >= 5%, got %s",
|
||||
validator.Commission.MaxRate,
|
||||
)
|
||||
|
||||
if val.shouldBeUpdated {
|
||||
require.Equal(
|
||||
t,
|
||||
ctx.BlockTime(),
|
||||
validator.Commission.UpdateTime,
|
||||
"commission update time should be set to block time",
|
||||
)
|
||||
} else {
|
||||
require.Equal(
|
||||
t,
|
||||
time.Unix(0, 0).UTC(),
|
||||
validator.Commission.UpdateTime,
|
||||
"commission update time should not be changed -- default value is 0",
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// func TestUpdateIncentiveParams(t *testing.T) {
|
||||
// tApp := app.NewTestApp()
|
||||
// tApp.InitializeFromGenesisStates()
|
||||
// ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
||||
|
||||
// ik := tApp.GetIncentiveKeeper()
|
||||
// params := ik.GetParams(ctx)
|
||||
|
||||
// startPeriod := time.Date(2021, 10, 26, 15, 0, 0, 0, time.UTC)
|
||||
// endPeriod := time.Date(2022, 10, 26, 15, 0, 0, 0, time.UTC)
|
||||
|
||||
// params.EarnRewardPeriods = incentivetypes.MultiRewardPeriods{
|
||||
// incentivetypes.NewMultiRewardPeriod(
|
||||
// true,
|
||||
// "bkava",
|
||||
// startPeriod,
|
||||
// endPeriod,
|
||||
// sdk.NewCoins(
|
||||
// sdk.NewCoin("ukava", sdk.NewInt(159459)),
|
||||
// ),
|
||||
// ),
|
||||
// }
|
||||
// ik.SetParams(ctx, params)
|
||||
|
||||
// beforeParams := ik.GetParams(ctx)
|
||||
// require.Equal(t, params, beforeParams, "initial incentive params should be set")
|
||||
|
||||
// // -- UPGRADE
|
||||
// app.UpdateIncentiveParams(ctx, tApp.App)
|
||||
|
||||
// // -- After
|
||||
// afterParams := ik.GetParams(ctx)
|
||||
|
||||
// require.Len(
|
||||
// t,
|
||||
// afterParams.EarnRewardPeriods[0].RewardsPerSecond,
|
||||
// 1,
|
||||
// "bkava earn reward period should only contain 1 coin",
|
||||
// )
|
||||
// require.Equal(
|
||||
// t,
|
||||
// // Manual calculation of
|
||||
// // 600,000 * 1000,000 / (365 * 24 * 60 * 60)
|
||||
// sdk.NewCoin("ukava", sdkmath.NewInt(19025)),
|
||||
// afterParams.EarnRewardPeriods[0].RewardsPerSecond[0],
|
||||
// "bkava earn reward period should be updated",
|
||||
// )
|
||||
|
||||
// // Check that other params are not changed
|
||||
// afterParams.EarnRewardPeriods[0].RewardsPerSecond[0] = beforeParams.EarnRewardPeriods[0].RewardsPerSecond[0]
|
||||
// require.Equal(
|
||||
// t,
|
||||
// beforeParams,
|
||||
// afterParams,
|
||||
// "other param values should not be changed",
|
||||
// )
|
||||
// }
|
||||
|
||||
func generateConsKey(
|
||||
t *testing.T,
|
||||
) *ethsecp256k1.PrivKey {
|
||||
t.Helper()
|
||||
|
||||
key, err := ethsecp256k1.GenerateKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
return key
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
import sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
const (
|
||||
AppName = "0gchaind"
|
||||
|
4
ci/env/kava-internal-testnet/genesis.json
vendored
4
ci/env/kava-internal-testnet/genesis.json
vendored
@ -582,10 +582,6 @@
|
||||
"denom": "erc20/axelar/wbtc",
|
||||
"amount": "1000000000"
|
||||
},
|
||||
{
|
||||
"denom": "erc20/tether/usdt",
|
||||
"amount": "100000000000"
|
||||
},
|
||||
{
|
||||
"denom": "hard",
|
||||
"amount": "1000000000"
|
||||
|
6
ci/env/kava-protonet/genesis.json
vendored
6
ci/env/kava-protonet/genesis.json
vendored
@ -3000,12 +3000,6 @@
|
||||
}
|
||||
},
|
||||
"params": null,
|
||||
"packetfowardmiddleware": {
|
||||
"params": {
|
||||
"fee_percentage": "0.000000000000000000"
|
||||
},
|
||||
"in_flight_packets": {}
|
||||
},
|
||||
"pricefeed": {
|
||||
"params": {
|
||||
"markets": [
|
||||
|
@ -16,7 +16,7 @@ The Kava gRPC client is a tool for making gRPC queries on a Kava chain.
|
||||
package main
|
||||
|
||||
import (
|
||||
kavaGrpc "github.com/0glabs/0g-chain/client/grpc"
|
||||
kavaGrpc "github.com/kava-labs/kava/client/grpc"
|
||||
)
|
||||
grpcUrl := "https://grpc.kava.io:443"
|
||||
client, err := kavaGrpc.NewClient(grpcUrl)
|
||||
@ -46,7 +46,7 @@ Example: Query Kava module `x/evmutil` for params
|
||||
|
||||
```go
|
||||
import (
|
||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
|
||||
)
|
||||
|
||||
rsp, err := client.Query.Evmutil.Params(
|
||||
|
@ -3,8 +3,8 @@ package grpc
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/0glabs/0g-chain/client/grpc/query"
|
||||
"github.com/0glabs/0g-chain/client/grpc/util"
|
||||
"github.com/kava-labs/kava/client/grpc/query"
|
||||
"github.com/kava-labs/kava/client/grpc/util"
|
||||
)
|
||||
|
||||
// KavaGrpcClient enables the usage of kava grpc query clients and query utils
|
||||
|
@ -3,7 +3,7 @@ package grpc_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/0glabs/0g-chain/client/grpc"
|
||||
"github.com/kava-labs/kava/client/grpc"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
authz "github.com/cosmos/cosmos-sdk/x/authz"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
|
||||
disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
govv1types "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
@ -24,11 +23,21 @@ import (
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
|
||||
|
||||
bep3types "github.com/0glabs/0g-chain/x/bep3/types"
|
||||
committeetypes "github.com/0glabs/0g-chain/x/committee/types"
|
||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
issuancetypes "github.com/0glabs/0g-chain/x/issuance/types"
|
||||
pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types"
|
||||
auctiontypes "github.com/kava-labs/kava/x/auction/types"
|
||||
bep3types "github.com/kava-labs/kava/x/bep3/types"
|
||||
cdptypes "github.com/kava-labs/kava/x/cdp/types"
|
||||
committeetypes "github.com/kava-labs/kava/x/committee/types"
|
||||
communitytypes "github.com/kava-labs/kava/x/community/types"
|
||||
earntypes "github.com/kava-labs/kava/x/earn/types"
|
||||
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
|
||||
hardtypes "github.com/kava-labs/kava/x/hard/types"
|
||||
incentivetypes "github.com/kava-labs/kava/x/incentive/types"
|
||||
issuancetypes "github.com/kava-labs/kava/x/issuance/types"
|
||||
kavadisttypes "github.com/kava-labs/kava/x/kavadist/types"
|
||||
liquidtypes "github.com/kava-labs/kava/x/liquid/types"
|
||||
pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
|
||||
savingstypes "github.com/kava-labs/kava/x/savings/types"
|
||||
swaptypes "github.com/kava-labs/kava/x/swap/types"
|
||||
)
|
||||
|
||||
// QueryClient is a wrapper with all Cosmos and Kava grpc query clients
|
||||
@ -49,7 +58,6 @@ type QueryClient struct {
|
||||
Slashing slashingtypes.QueryClient
|
||||
Staking stakingtypes.QueryClient
|
||||
Upgrade upgradetypes.QueryClient
|
||||
Consensus consensustypes.QueryClient
|
||||
|
||||
// 3rd party query clients
|
||||
|
||||
@ -98,7 +106,6 @@ func NewQueryClient(grpcEndpoint string) (*QueryClient, error) {
|
||||
Slashing: slashingtypes.NewQueryClient(conn),
|
||||
Staking: stakingtypes.NewQueryClient(conn),
|
||||
Upgrade: upgradetypes.NewQueryClient(conn),
|
||||
Consensus: consensustypes.NewQueryClient(conn),
|
||||
|
||||
Evm: evmtypes.NewQueryClient(conn),
|
||||
Feemarket: feemarkettypes.NewQueryClient(conn),
|
||||
|
@ -3,7 +3,7 @@ package query_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/0glabs/0g-chain/client/grpc/query"
|
||||
"github.com/kava-labs/kava/client/grpc/query"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -46,7 +46,6 @@ func TestNewQueryClient_ValidClient(t *testing.T) {
|
||||
require.NotNil(t, client.Slashing)
|
||||
require.NotNil(t, client.Staking)
|
||||
require.NotNil(t, client.Upgrade)
|
||||
require.NotNil(t, client.Consensus)
|
||||
|
||||
// validate 3rd party clients
|
||||
require.NotNil(t, client.Evm)
|
||||
|
@ -7,9 +7,9 @@ import (
|
||||
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/params"
|
||||
query "github.com/0glabs/0g-chain/client/grpc/query"
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/app/params"
|
||||
query "github.com/kava-labs/kava/client/grpc/query"
|
||||
)
|
||||
|
||||
// Util contains utility functions for the Kava gRPC client
|
||||
|
@ -132,7 +132,7 @@ func (br BaseReq) ValidateBasic(w http.ResponseWriter) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// ReadRESTReq reads and unmarshals a Request's body to the BaseReq struct.
|
||||
// ReadRESTReq reads and unmarshals a Request's body to the the BaseReq struct.
|
||||
// Writes an error response to ResponseWriter and returns false if errors occurred.
|
||||
func ReadRESTReq(w http.ResponseWriter, r *http.Request, cdc *codec.LegacyAmino, req interface{}) bool {
|
||||
body, err := io.ReadAll(r.Body)
|
||||
|
@ -30,7 +30,6 @@ import (
|
||||
const (
|
||||
flagMempoolEnableAuth = "mempool.enable-authentication"
|
||||
flagMempoolAuthAddresses = "mempool.authorized-addresses"
|
||||
flagSkipLoadLatest = "skip-load-latest"
|
||||
)
|
||||
|
||||
// appCreator holds functions used by the sdk server to control the 0g-chain app.
|
||||
@ -46,7 +45,6 @@ func (ac appCreator) newApp(
|
||||
traceStore io.Writer,
|
||||
appOpts servertypes.AppOptions,
|
||||
) servertypes.Application {
|
||||
fmt.Println("newApp")
|
||||
var cache sdk.MultiStorePersistentCache
|
||||
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
|
||||
cache = store.NewCommitKVStoreCacheManager()
|
||||
@ -102,15 +100,10 @@ func (ac appCreator) newApp(
|
||||
chainID = appGenesis.ChainID
|
||||
}
|
||||
|
||||
skipLoadLatest := false
|
||||
if appOpts.Get(flagSkipLoadLatest) != nil {
|
||||
skipLoadLatest = cast.ToBool(appOpts.Get(flagSkipLoadLatest))
|
||||
}
|
||||
|
||||
return app.NewApp(
|
||||
logger, db, homeDir, traceStore, ac.encodingConfig,
|
||||
app.Options{
|
||||
SkipLoadLatest: skipLoadLatest,
|
||||
SkipLoadLatest: false,
|
||||
SkipUpgradeHeights: skipUpgradeHeights,
|
||||
SkipGenesisInvariants: cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)),
|
||||
InvariantCheckPeriod: cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
|
||||
|
@ -1,56 +0,0 @@
|
||||
package iavlviewer
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/iavl"
|
||||
ethermintserver "github.com/evmos/ethermint/server"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newDataCmd(opts ethermintserver.StartOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "data <prefix> [version number]",
|
||||
Short: "View all keys, hash, & size of tree.",
|
||||
Args: cobra.RangeArgs(1, 2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
prefix := args[0]
|
||||
version := 0
|
||||
if len(args) == 2 {
|
||||
var err error
|
||||
version, err = parseVersion(args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
tree, err := openPrefixTree(opts, cmd, prefix, version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printKeys(tree)
|
||||
hash, err := tree.Hash()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Hash: %X\n", hash)
|
||||
fmt.Printf("Size: %X\n", tree.Size())
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func printKeys(tree *iavl.MutableTree) {
|
||||
fmt.Println("Printing all keys with hashed values (to detect diff)")
|
||||
tree.Iterate(func(key []byte, value []byte) bool { //nolint:errcheck
|
||||
printKey := parseWeaveKey(key)
|
||||
digest := sha256.Sum256(value)
|
||||
fmt.Printf(" %s\n %X\n", printKey, digest)
|
||||
return false
|
||||
})
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package iavlviewer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
ethermintserver "github.com/evmos/ethermint/server"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newHashCmd(opts ethermintserver.StartOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "hash <prefix> [version number]",
|
||||
Short: "Print the root hash of the iavl tree.",
|
||||
Args: cobra.RangeArgs(1, 2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
prefix := args[0]
|
||||
version := 0
|
||||
if len(args) == 2 {
|
||||
var err error
|
||||
version, err = parseVersion(args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
tree, err := openPrefixTree(opts, cmd, prefix, version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
hash, err := tree.Hash()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Hash: %X\n", hash)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package iavlviewer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
dbm "github.com/cometbft/cometbft-db"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
ethermintserver "github.com/evmos/ethermint/server"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/iavl"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultCacheSize int = 10000
|
||||
)
|
||||
|
||||
func NewCmd(opts ethermintserver.StartOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "iavlviewer <data|hash|shape|versions> <prefix> [version number]",
|
||||
Short: "Output various data, hashes, and calculations for an iavl tree",
|
||||
}
|
||||
|
||||
cmd.AddCommand(newDataCmd(opts))
|
||||
cmd.AddCommand(newHashCmd(opts))
|
||||
cmd.AddCommand(newShapeCmd(opts))
|
||||
cmd.AddCommand(newVersionsCmd(opts))
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func parseVersion(arg string) (int, error) {
|
||||
version, err := strconv.Atoi(arg)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("invalid version number: '%s'", arg)
|
||||
}
|
||||
return version, nil
|
||||
}
|
||||
|
||||
func openPrefixTree(opts ethermintserver.StartOptions, cmd *cobra.Command, prefix string, version int) (*iavl.MutableTree, error) {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
ctx := server.GetServerContextFromCmd(cmd)
|
||||
ctx.Config.SetRoot(clientCtx.HomeDir)
|
||||
|
||||
db, err := opts.DBOpener(ctx.Viper, clientCtx.HomeDir, server.GetAppDBBackend(ctx.Viper))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to open database at %s: %s", clientCtx.HomeDir, err)
|
||||
}
|
||||
defer func() {
|
||||
if err := db.Close(); err != nil {
|
||||
ctx.Logger.Error("error closing db", "error", err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
tree, err := readTree(db, version, []byte(prefix))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read tree with prefix %s: %s", prefix, err)
|
||||
}
|
||||
return tree, nil
|
||||
}
|
||||
|
||||
// ReadTree loads an iavl tree from the directory
|
||||
// If version is 0, load latest, otherwise, load named version
|
||||
// The prefix represents which iavl tree you want to read. The iaviwer will always set a prefix.
|
||||
func readTree(db dbm.DB, version int, prefix []byte) (*iavl.MutableTree, error) {
|
||||
if len(prefix) != 0 {
|
||||
db = dbm.NewPrefixDB(db, prefix)
|
||||
}
|
||||
|
||||
tree, err := iavl.NewMutableTree(db, DefaultCacheSize, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ver, err := tree.LoadVersion(int64(version))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Printf("Latest version: %d\n", ver)
|
||||
fmt.Printf("Got version: %d\n", version)
|
||||
return tree, err
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package iavlviewer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/iavl"
|
||||
ethermintserver "github.com/evmos/ethermint/server"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newShapeCmd(opts ethermintserver.StartOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "shape <prefix> [version number]",
|
||||
Short: "View shape of iavl tree.",
|
||||
Args: cobra.RangeArgs(1, 2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
prefix := args[0]
|
||||
version := 0
|
||||
if len(args) == 2 {
|
||||
var err error
|
||||
version, err = parseVersion(args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
tree, err := openPrefixTree(opts, cmd, prefix, version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printShape(tree)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func printShape(tree *iavl.MutableTree) {
|
||||
// shape := tree.RenderShape(" ", nil)
|
||||
// TODO: handle this error
|
||||
shape, _ := tree.RenderShape(" ", nodeEncoder)
|
||||
fmt.Println(strings.Join(shape, "\n"))
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package iavlviewer
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/iavl"
|
||||
ethermintserver "github.com/evmos/ethermint/server"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newVersionsCmd(opts ethermintserver.StartOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "versions <prefix>",
|
||||
Short: "Print all versions of iavl tree",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
prefix := args[0]
|
||||
tree, err := openPrefixTree(opts, cmd, prefix, 15)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printVersions(tree)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func printVersions(tree *iavl.MutableTree) {
|
||||
versions := tree.AvailableVersions()
|
||||
fmt.Println("Available versions:")
|
||||
for _, v := range versions {
|
||||
fmt.Printf(" %d\n", v)
|
||||
}
|
||||
}
|
||||
|
||||
// parseWeaveKey assumes a separating : where all in front should be ascii,
|
||||
// and all afterwards may be ascii or binary
|
||||
func parseWeaveKey(key []byte) string {
|
||||
cut := bytes.IndexRune(key, ':')
|
||||
if cut == -1 {
|
||||
return encodeID(key)
|
||||
}
|
||||
prefix := key[:cut]
|
||||
id := key[cut+1:]
|
||||
return fmt.Sprintf("%s:%s", encodeID(prefix), encodeID(id))
|
||||
}
|
||||
|
||||
// casts to a string if it is printable ascii, hex-encodes otherwise
|
||||
func encodeID(id []byte) string {
|
||||
for _, b := range id {
|
||||
if b < 0x20 || b >= 0x80 {
|
||||
return strings.ToUpper(hex.EncodeToString(id))
|
||||
}
|
||||
}
|
||||
return string(id)
|
||||
}
|
||||
|
||||
func nodeEncoder(id []byte, depth int, isLeaf bool) string {
|
||||
prefix := fmt.Sprintf("-%d ", depth)
|
||||
if isLeaf {
|
||||
prefix = fmt.Sprintf("*%d ", depth)
|
||||
}
|
||||
if len(id) == 0 {
|
||||
return fmt.Sprintf("%s<nil>", prefix)
|
||||
}
|
||||
return fmt.Sprintf("%s%s", prefix, parseWeaveKey(id))
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@ -52,6 +52,13 @@ The pass backend requires GnuPG: https://gnupg.org/
|
||||
addCmd := keys.AddKeyCommand()
|
||||
addCmd.Flags().Bool(ethFlag, false, "use default evm coin-type (60) and key signing algorithm (\"eth_secp256k1\")")
|
||||
|
||||
algoFlag := addCmd.Flag(flags.FlagKeyAlgorithm)
|
||||
algoFlag.DefValue = string(hd.EthSecp256k1Type)
|
||||
err := algoFlag.Value.Set(string(hd.EthSecp256k1Type))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
addCmd.RunE = runAddCmd
|
||||
|
||||
cmd.AddCommand(
|
||||
|
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
@ -12,11 +11,12 @@ import (
|
||||
|
||||
func main() {
|
||||
chaincfg.SetSDKConfig().Seal()
|
||||
|
||||
rootCmd := NewRootCmd()
|
||||
|
||||
if err := svrcmd.Execute(rootCmd, chaincfg.EnvPrefix, chaincfg.DefaultNodeHome); err != nil {
|
||||
switch e := err.(type) {
|
||||
case server.ErrorCode:
|
||||
fmt.Println("error")
|
||||
os.Exit(e.Code)
|
||||
|
||||
default:
|
||||
|
@ -27,8 +27,6 @@ import (
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/params"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/cmd/0gchaind/iavlviewer"
|
||||
"github.com/0glabs/0g-chain/cmd/0gchaind/rocksdb"
|
||||
"github.com/0glabs/0g-chain/cmd/opendb"
|
||||
"github.com/0glabs/0g-chain/crypto/vrf"
|
||||
)
|
||||
@ -50,10 +48,18 @@ func NewRootCmd() *cobra.Command {
|
||||
WithLegacyAmino(encodingConfig.Amino).
|
||||
WithInput(os.Stdin).
|
||||
WithAccountRetriever(types.AccountRetriever{}).
|
||||
<<<<<<< HEAD
|
||||
WithBroadcastMode(flags.FlagBroadcastMode).
|
||||
WithHomeDir(app.DefaultNodeHome).
|
||||
WithKeyringOptions(hd.EthSecp256k1Option()).
|
||||
WithViper(EnvPrefix)
|
||||
=======
|
||||
WithBroadcastMode(flags.BroadcastBlock).
|
||||
WithHomeDir(chaincfg.DefaultNodeHome).
|
||||
WithKeyringOptions(customKeyringOptions()).
|
||||
WithViper(chaincfg.EnvPrefix)
|
||||
>>>>>>> be1cd76f (add vrf)
|
||||
|
||||
rootCmd := &cobra.Command{
|
||||
Use: chaincfg.AppName,
|
||||
Short: "Daemon and CLI for the 0g-chain blockchain.",
|
||||
@ -87,6 +93,7 @@ func NewRootCmd() *cobra.Command {
|
||||
}
|
||||
|
||||
addSubCmds(rootCmd, encodingConfig, chaincfg.DefaultNodeHome)
|
||||
|
||||
return rootCmd
|
||||
}
|
||||
|
||||
@ -130,13 +137,12 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, de
|
||||
ac.addStartCmdFlags,
|
||||
)
|
||||
|
||||
// add keybase, auxiliary RPC, query, and tx child commands
|
||||
// add keybase, gas RPC, query, and tx child commands
|
||||
rootCmd.AddCommand(
|
||||
newQueryCmd(),
|
||||
newTxCmd(),
|
||||
keyCommands(chaincfg.DefaultNodeHome),
|
||||
keyCommands(app.DefaultNodeHome),
|
||||
rocksdb.RocksDBCmd,
|
||||
newShardCmd(opts),
|
||||
iavlviewer.NewCmd(opts),
|
||||
)
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
package main
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
dbm "github.com/cometbft/cometbft-db"
|
||||
@ -24,11 +23,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
flagShardStartBlock = "start"
|
||||
flagShardEndBlock = "end"
|
||||
flagShardOnlyAppState = "only-app-state"
|
||||
flagShardForceAppVersion = "force-app-version"
|
||||
flagShardOnlyCometbftState = "only-cometbft-state"
|
||||
flagShardStartBlock = "start"
|
||||
flagShardEndBlock = "end"
|
||||
flagShardOnlyAppState = "only-app-state"
|
||||
// TODO: --preserve flag for creating & operating on a copy?
|
||||
|
||||
// allow using -1 to mean "latest" (perform no rollbacks)
|
||||
@ -37,7 +34,7 @@ const (
|
||||
|
||||
func newShardCmd(opts ethermintserver.StartOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "shard --home <path-to-home-dir> --start <start-block> --end <end-block> [--only-app-state] [--only-cometbft-state] [--force-app-version <app-version>]",
|
||||
Use: "shard --home <path-to-home-dir> --start <start-block> --end <end-block> [--only-app-state]",
|
||||
Short: "Strip all blocks from the database outside of a given range",
|
||||
Long: `shard opens a local kava home directory's databases and removes all blocks outside a range defined by --start and --end. The range is inclusive of the end block.
|
||||
|
||||
@ -45,14 +42,8 @@ It works by first rolling back the latest state to the block before the end bloc
|
||||
|
||||
Setting the end block to -1 signals to keep the latest block (no rollbacks).
|
||||
|
||||
The application.db can be loaded at a particular height via the --force-app-version option. This is useful if the sharding process is prematurely terminated while the application.db is being sharded.
|
||||
|
||||
The --only-app-state flag can be used to skip the pruning of the blockstore and cometbft state. This matches the functionality of the cosmos-sdk's "prune" command. Note that rolled back blocks will still affect all stores.
|
||||
|
||||
Similarly, the --only-cometbft-state flag skips pruning app state. This can be useful if the shard command is prematurely terminated during the shard process.
|
||||
|
||||
The shard command only flags the iavl tree nodes for deletion. Actual removal from the databases will be performed when each database is compacted.
|
||||
|
||||
WARNING: this is a destructive action.`,
|
||||
Example: `Create a 1M block data shard (keeps blocks kava 1,000,000 to 2,000,000)
|
||||
$ kava shard --home path/to/.kava --start 1000000 --end 2000000
|
||||
@ -63,9 +54,7 @@ $ kava shard --home path/to/.kava --start 5000000 --end -1
|
||||
Prune first 1M blocks _without_ affecting blockstore or cometBFT state:
|
||||
$ kava shard --home path/to/.kava --start 1000000 --end -1 --only-app-state`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
//////////////////////////
|
||||
// parse & validate flags
|
||||
//////////////////////////
|
||||
// read & validate flags
|
||||
startBlock, err := cmd.Flags().GetInt64(flagShardStartBlock)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -81,23 +70,16 @@ $ kava shard --home path/to/.kava --start 1000000 --end -1 --only-app-state`,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
forceAppVersion, err := cmd.Flags().GetInt64(flagShardForceAppVersion)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
onlyCometbftState, err := cmd.Flags().GetBool(flagShardOnlyCometbftState)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
ctx := server.GetServerContextFromCmd(cmd)
|
||||
ctx.Config.SetRoot(clientCtx.HomeDir)
|
||||
|
||||
////////////////////////
|
||||
// manage db connection
|
||||
////////////////////////
|
||||
//////////////////////////////
|
||||
// Rollback state to endBlock
|
||||
//////////////////////////////
|
||||
|
||||
// connect to database
|
||||
db, err := opts.DBOpener(ctx.Viper, clientCtx.HomeDir, server.GetAppDBBackend(ctx.Viper))
|
||||
if err != nil {
|
||||
@ -111,59 +93,109 @@ $ kava shard --home path/to/.kava --start 1000000 --end -1 --only-app-state`,
|
||||
}
|
||||
}()
|
||||
|
||||
///////////////////
|
||||
// load multistore
|
||||
///////////////////
|
||||
// create app in order to load the multistore
|
||||
// skip loading the latest version so the desired height can be manually loaded
|
||||
ctx.Viper.Set("skip-load-latest", true)
|
||||
|
||||
app := opts.AppCreator(ctx.Logger, db, nil, ctx.Viper).(*app.App)
|
||||
if forceAppVersion == shardEndBlockLatest {
|
||||
if err := app.LoadLatestVersion(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := app.LoadVersion(forceAppVersion); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// get the multistore
|
||||
app := opts.AppCreator(ctx.Logger, db, nil, ctx.Viper)
|
||||
cms := app.CommitMultiStore()
|
||||
multistore, ok := cms.(*rootmulti.Store)
|
||||
if !ok {
|
||||
return fmt.Errorf("only sharding of rootmulti.Store type is supported")
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// shard application.db
|
||||
////////////////////////
|
||||
if !onlyCometbftState {
|
||||
if err := shardApplicationDb(multistore, startBlock, endBlock); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("[%s] skipping sharding of application.db\n", flagShardOnlyCometbftState)
|
||||
// handle desired endblock being latest
|
||||
latest := multistore.LatestVersion()
|
||||
fmt.Printf("latest height: %d\n", latest)
|
||||
if endBlock == shardEndBlockLatest {
|
||||
endBlock = latest
|
||||
}
|
||||
shardSize := endBlock - startBlock + 1
|
||||
|
||||
// error if requesting block range the database does not have
|
||||
if endBlock > latest {
|
||||
return fmt.Errorf("data does not contain end block (%d): latest version is %d", endBlock, latest)
|
||||
}
|
||||
|
||||
fmt.Printf("pruning data in %s down to heights %d - %d (%d blocks)\n", clientCtx.HomeDir, startBlock, endBlock, shardSize)
|
||||
|
||||
// set pruning options to prevent no-ops from `PruneStores`
|
||||
multistore.SetPruning(pruningtypes.PruningOptions{KeepRecent: uint64(shardSize), Interval: 0})
|
||||
|
||||
// rollback application state
|
||||
if err = multistore.RollbackToVersion(endBlock); err != nil {
|
||||
return fmt.Errorf("failed to rollback application state: %s", err)
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// shard blockstore.db & state.db
|
||||
//////////////////////////////////
|
||||
// open block store & cometbft state
|
||||
blockStore, stateStore, err := openCometBftDbs(ctx.Config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open cometbft dbs: %s", err)
|
||||
}
|
||||
|
||||
if !onlyAppState {
|
||||
if err := shardCometBftDbs(blockStore, stateStore, startBlock, endBlock); err != nil {
|
||||
return err
|
||||
// prep for outputting progress repeatedly to same line
|
||||
needsRollback := endBlock < latest
|
||||
progress := "rolling back blockstore & cometbft state to height %d"
|
||||
numChars := len(fmt.Sprintf(progress, latest))
|
||||
clearLine := fmt.Sprintf("\r%s\r", strings.Repeat(" ", numChars))
|
||||
printRollbackProgress := func(h int64) {
|
||||
fmt.Print(clearLine)
|
||||
fmt.Printf(progress, h)
|
||||
}
|
||||
|
||||
// rollback tendermint db
|
||||
height := latest
|
||||
for height > endBlock {
|
||||
printRollbackProgress(height - 1)
|
||||
height, _, err = tmstate.Rollback(blockStore, stateStore, true)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to rollback tendermint state: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if needsRollback {
|
||||
fmt.Println()
|
||||
} else {
|
||||
fmt.Printf("latest store height is already %d\n", latest)
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// Prune blocks to startBlock
|
||||
//////////////////////////////
|
||||
|
||||
// enumerate all heights to prune
|
||||
pruneHeights := make([]int64, 0, latest-shardSize)
|
||||
for i := int64(1); i < startBlock; i++ {
|
||||
pruneHeights = append(pruneHeights, i)
|
||||
}
|
||||
|
||||
if len(pruneHeights) > 0 {
|
||||
// prune application state
|
||||
fmt.Printf("pruning application state to height %d\n", startBlock)
|
||||
if err := multistore.PruneStores(true, pruneHeights); err != nil {
|
||||
return fmt.Errorf("failed to prune application state: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// get starting block of block store
|
||||
baseBlock := blockStore.Base()
|
||||
|
||||
// only prune if data exists, otherwise blockStore.PruneBlocks will panic
|
||||
if !onlyAppState && baseBlock < startBlock {
|
||||
// prune block store
|
||||
fmt.Printf("pruning block store from %d - %d\n", baseBlock, startBlock)
|
||||
if _, err := blockStore.PruneBlocks(startBlock); err != nil {
|
||||
return fmt.Errorf("failed to prune block store (retainHeight=%d): %s", startBlock, err)
|
||||
}
|
||||
|
||||
// prune cometbft state
|
||||
fmt.Printf("pruning cometbft state from %d - %d\n", baseBlock, startBlock)
|
||||
if err := stateStore.PruneStates(baseBlock, startBlock); err != nil {
|
||||
return fmt.Errorf("failed to prune cometbft state store (%d - %d): %s", baseBlock, startBlock, err)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("[%s] skipping sharding of blockstore.db and state.db\n", flagShardOnlyAppState)
|
||||
fmt.Printf("blockstore contains blocks %d - %d\n", blockStore.Base(), blockStore.Height())
|
||||
fmt.Printf("blockstore and cometbft state begins at block %d\n", baseBlock)
|
||||
}
|
||||
|
||||
// TODO: db compaction
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@ -172,129 +204,10 @@ $ kava shard --home path/to/.kava --start 1000000 --end -1 --only-app-state`,
|
||||
cmd.Flags().Int64(flagShardStartBlock, 1, "Start block of data shard (inclusive)")
|
||||
cmd.Flags().Int64(flagShardEndBlock, 0, "End block of data shard (inclusive)")
|
||||
cmd.Flags().Bool(flagShardOnlyAppState, false, "Skip pruning of blockstore & cometbft state")
|
||||
cmd.Flags().Bool(flagShardOnlyCometbftState, false, "Skip pruning of application state")
|
||||
cmd.Flags().Int64(flagShardForceAppVersion, shardEndBlockLatest, "Instead of loading latest, force set the version of the multistore that is loaded")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// shardApplicationDb prunes the multistore up to startBlock and rolls it back to endBlock
|
||||
func shardApplicationDb(multistore *rootmulti.Store, startBlock, endBlock int64) error {
|
||||
//////////////////////////////
|
||||
// Rollback state to endBlock
|
||||
//////////////////////////////
|
||||
// handle desired endblock being latest
|
||||
latest := multistore.LastCommitID().Version
|
||||
if latest == 0 {
|
||||
return fmt.Errorf("failed to find latest height >0")
|
||||
}
|
||||
fmt.Printf("latest height: %d\n", latest)
|
||||
if endBlock == shardEndBlockLatest {
|
||||
endBlock = latest
|
||||
}
|
||||
shardSize := endBlock - startBlock + 1
|
||||
|
||||
// error if requesting block range the database does not have
|
||||
if endBlock > latest {
|
||||
return fmt.Errorf("data does not contain end block (%d): latest version is %d", endBlock, latest)
|
||||
}
|
||||
|
||||
fmt.Printf("pruning data down to heights %d - %d (%d blocks)\n", startBlock, endBlock, shardSize)
|
||||
|
||||
// set pruning options to prevent no-ops from `PruneStores`
|
||||
multistore.SetPruning(pruningtypes.PruningOptions{KeepRecent: uint64(shardSize), Interval: 0})
|
||||
|
||||
// rollback application state
|
||||
if err := multistore.RollbackToVersion(endBlock); err != nil {
|
||||
return fmt.Errorf("failed to rollback application state: %s", err)
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// Prune blocks to startBlock
|
||||
//////////////////////////////
|
||||
// enumerate all heights to prune
|
||||
pruneHeights := make([]int64, 0, latest-shardSize)
|
||||
for i := int64(1); i < startBlock; i++ {
|
||||
pruneHeights = append(pruneHeights, i)
|
||||
}
|
||||
|
||||
if len(pruneHeights) > 0 {
|
||||
fmt.Printf("pruning application state to height %d\n", startBlock)
|
||||
if err := multistore.PruneStores(true, pruneHeights); err != nil {
|
||||
return fmt.Errorf("failed to prune application state: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// shardCometBftDbs shrinks blockstore.db & state.db down to the desired block range
|
||||
func shardCometBftDbs(blockStore *store.BlockStore, stateStore tmstate.Store, startBlock, endBlock int64) error {
|
||||
var err error
|
||||
latest := blockStore.Height()
|
||||
if endBlock == shardEndBlockLatest {
|
||||
endBlock = latest
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// Rollback state to endBlock
|
||||
//////////////////////////////
|
||||
// prep for outputting progress repeatedly to same line
|
||||
needsRollback := endBlock < latest
|
||||
progress := "rolling back blockstore & cometbft state to height %d"
|
||||
numChars := len(fmt.Sprintf(progress, latest))
|
||||
clearLine := fmt.Sprintf("\r%s\r", strings.Repeat(" ", numChars))
|
||||
printRollbackProgress := func(h int64) {
|
||||
fmt.Print(clearLine)
|
||||
fmt.Printf(progress, h)
|
||||
}
|
||||
|
||||
// rollback tendermint db
|
||||
height := latest
|
||||
for height > endBlock {
|
||||
beforeRollbackHeight := height
|
||||
printRollbackProgress(height - 1)
|
||||
height, _, err = tmstate.Rollback(blockStore, stateStore, true)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to rollback cometbft state: %w", err)
|
||||
}
|
||||
if beforeRollbackHeight == height {
|
||||
return fmt.Errorf("attempting to rollback cometbft state height %d failed (no rollback performed)", height)
|
||||
}
|
||||
}
|
||||
|
||||
if needsRollback {
|
||||
fmt.Println()
|
||||
} else {
|
||||
fmt.Printf("latest store height is already %d\n", latest)
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
// Prune blocks to startBlock
|
||||
//////////////////////////////
|
||||
// get starting block of block store
|
||||
baseBlock := blockStore.Base()
|
||||
|
||||
// only prune if data exists, otherwise blockStore.PruneBlocks will panic
|
||||
if baseBlock < startBlock {
|
||||
// prune block store
|
||||
fmt.Printf("pruning block store from %d - %d\n", baseBlock, startBlock)
|
||||
if _, err := blockStore.PruneBlocks(startBlock); err != nil {
|
||||
return fmt.Errorf("failed to prune block store (retainHeight=%d): %s", startBlock, err)
|
||||
}
|
||||
|
||||
// prune cometbft state
|
||||
fmt.Printf("pruning cometbft state from %d - %d\n", baseBlock, startBlock)
|
||||
if err := stateStore.PruneStates(baseBlock, startBlock); err != nil {
|
||||
return fmt.Errorf("failed to prune cometbft state store (%d - %d): %s", baseBlock, startBlock, err)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("blockstore and cometbft state begins at block %d\n", baseBlock)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// inspired by https://github.com/Kava-Labs/cometbft/blob/277b0853db3f67865a55aa1c54f59790b5f591be/node/node.go#L234
|
||||
func openCometBftDbs(config *tmconfig.Config) (blockStore *store.BlockStore, stateStore tmstate.Store, err error) {
|
||||
dbProvider := node.DefaultDBProvider
|
||||
|
@ -106,4 +106,4 @@ jq '.app_state.earn.params.allowed_vaults = [
|
||||
jq '.app_state.savings.params.supported_denoms = ["bkava-kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0"]' $DATA/config/genesis.json | sponge $DATA/config/genesis.json
|
||||
|
||||
|
||||
$BINARY config broadcast-mode sync
|
||||
$BINARY config broadcast-mode block
|
@ -5,8 +5,8 @@ package vrf
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
|
@ -6,12 +6,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
tmcrypto "github.com/cometbft/cometbft/crypto"
|
||||
vrfalgo "github.com/coniks-sys/coniks-go/crypto/vrf"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
tmcrypto "github.com/tendermint/tendermint/crypto"
|
||||
)
|
||||
|
||||
const (
|
||||
|
File diff suppressed because it is too large
Load Diff
154
go.mod
154
go.mod
@ -1,22 +1,21 @@
|
||||
module github.com/0glabs/0g-chain
|
||||
|
||||
go 1.21
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
cosmossdk.io/errors v1.0.1
|
||||
cosmossdk.io/math v1.3.0
|
||||
cosmossdk.io/errors v1.0.0
|
||||
cosmossdk.io/math v1.2.0
|
||||
cosmossdk.io/simapp v0.0.0-20231127212628-044ff4d8c015
|
||||
github.com/cenkalti/backoff/v4 v4.1.3
|
||||
github.com/cometbft/cometbft v0.37.4
|
||||
github.com/cometbft/cometbft-db v0.9.1
|
||||
github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71
|
||||
github.com/consensys/gnark-crypto v0.12.1
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.4
|
||||
github.com/cosmos/cosmos-sdk v0.47.10
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.3
|
||||
github.com/cosmos/cosmos-sdk v0.47.7
|
||||
github.com/cosmos/go-bip39 v1.0.0
|
||||
github.com/cosmos/gogoproto v1.4.10
|
||||
github.com/cosmos/iavl v0.20.1
|
||||
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3
|
||||
github.com/cosmos/ibc-go/v7 v7.4.0
|
||||
github.com/cosmos/ibc-go/v7 v7.3.1
|
||||
github.com/ethereum/go-ethereum v1.10.26
|
||||
github.com/evmos/ethermint v0.21.0
|
||||
github.com/go-kit/kit v0.12.0
|
||||
@ -24,44 +23,50 @@ require (
|
||||
github.com/golang/protobuf v1.5.3
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0
|
||||
github.com/influxdata/influxdb v1.8.3
|
||||
github.com/kava-labs/kava v0.26.1
|
||||
github.com/linxGnu/grocksdb v1.8.6
|
||||
github.com/pelletier/go-toml/v2 v2.1.0
|
||||
github.com/prometheus/client_golang v1.14.0
|
||||
github.com/shopspring/decimal v1.4.0
|
||||
github.com/spf13/cast v1.6.0
|
||||
github.com/spf13/cobra v1.7.0
|
||||
github.com/spf13/viper v1.16.0
|
||||
github.com/stretchr/testify v1.8.4
|
||||
golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb
|
||||
google.golang.org/grpc v1.59.0
|
||||
github.com/pelletier/go-toml/v2 v2.1.0
|
||||
github.com/spf13/cast v1.6.0
|
||||
github.com/spf13/cobra v1.8.0
|
||||
github.com/spf13/viper v1.18.1
|
||||
github.com/subosito/gotenv v1.6.0
|
||||
github.com/tendermint/tendermint v0.35.9
|
||||
golang.org/x/crypto v0.24.0
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0
|
||||
google.golang.org/grpc v1.60.1
|
||||
google.golang.org/protobuf v1.32.0
|
||||
sigs.k8s.io/yaml v1.4.0
|
||||
github.com/shopspring/decimal v1.4.0
|
||||
github.com/stretchr/testify v1.8.3
|
||||
github.com/tendermint/tendermint v0.34.27
|
||||
github.com/tendermint/tm-db v0.6.7
|
||||
golang.org/x/crypto v0.14.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13
|
||||
google.golang.org/grpc v1.58.3
|
||||
google.golang.org/protobuf v1.31.0
|
||||
sigs.k8s.io/yaml v1.3.0
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.111.0 // indirect
|
||||
cloud.google.com/go/compute v1.23.3 // indirect
|
||||
cloud.google.com/go v0.110.8 // indirect
|
||||
cloud.google.com/go/compute v1.23.0 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||
cloud.google.com/go/iam v1.1.5 // indirect
|
||||
cloud.google.com/go/storage v1.35.1 // indirect
|
||||
cosmossdk.io/api v0.3.1 // indirect
|
||||
cosmossdk.io/core v0.6.1 // indirect
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/simapp v0.0.0-20231127212628-044ff4d8c015 // indirect
|
||||
cosmossdk.io/tools/rosetta v0.2.1 // indirect
|
||||
filippo.io/edwards25519 v1.0.0 // indirect
|
||||
cloud.google.com/go/iam v1.1.2 // indirect
|
||||
cloud.google.com/go/storage v1.30.1 // indirect
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||
github.com/99designs/keyring v1.2.1 // indirect
|
||||
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
|
||||
cloud.google.com/go/iam v1.1.5 // indirect
|
||||
cloud.google.com/go/storage v1.35.1 // indirect
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
|
||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
|
||||
github.com/allegro/bigcache v1.2.1 // indirect
|
||||
github.com/armon/go-metrics v0.4.1 // indirect
|
||||
github.com/aws/aws-sdk-go v1.44.203 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
@ -74,7 +79,7 @@ require (
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
||||
github.com/cespare/xxhash v1.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/chzyer/readline v1.5.1 // indirect
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
|
||||
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
|
||||
github.com/cockroachdb/errors v1.10.0 // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
||||
@ -84,46 +89,54 @@ require (
|
||||
github.com/consensys/bavard v0.1.13 // indirect
|
||||
github.com/cosmos/btcutil v1.0.5 // indirect
|
||||
github.com/cosmos/gogogateway v1.2.0 // indirect
|
||||
github.com/cosmos/iavl v0.20.1 // indirect
|
||||
github.com/cosmos/ics23/go v0.10.0 // indirect
|
||||
github.com/cosmos/gogoproto v1.4.11 // indirect
|
||||
github.com/cosmos/ledger-cosmos-go v0.13.1 // indirect
|
||||
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
|
||||
github.com/creachadair/taskgroup v0.4.2 // indirect
|
||||
github.com/danieljoos/wincred v1.1.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/deckarep/golang-set v1.8.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
|
||||
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
|
||||
github.com/dgraph-io/ristretto v0.1.1 // indirect
|
||||
github.com/dgraph-io/badger/v3 v3.2103.2 // indirect
|
||||
github.com/dgraph-io/ristretto v0.1.0 // indirect
|
||||
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
|
||||
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 // indirect
|
||||
github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
|
||||
github.com/edsrzf/mmap-go v1.0.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.2 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/fatih/color v1.17.0 // indirect
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
|
||||
github.com/getsentry/sentry-go v0.23.0 // indirect
|
||||
github.com/go-kit/log v0.2.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||
github.com/go-logr/logr v1.2.4 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-logfmt/logfmt v0.5.1 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
|
||||
github.com/go-stack/stack v1.8.1 // indirect
|
||||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
|
||||
github.com/gogo/googleapis v1.4.1 // indirect
|
||||
github.com/golang/glog v1.1.2 // indirect
|
||||
github.com/gogo/gateway v1.1.0 // indirect
|
||||
github.com/golang/glog v1.1.0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/btree v1.1.2 // indirect
|
||||
github.com/google/flatbuffers v1.12.1 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/orderedcode v0.0.1 // indirect
|
||||
github.com/google/flatbuffers v1.12.1 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 // indirect
|
||||
github.com/google/s2a-go v0.1.7 // indirect
|
||||
github.com/google/uuid v1.4.0 // indirect
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
|
||||
github.com/google/orderedcode v0.0.1 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
|
||||
github.com/gorilla/handlers v1.5.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
@ -143,15 +156,16 @@ require (
|
||||
github.com/holiman/uint256 v1.2.1 // indirect
|
||||
github.com/huandu/skiplist v1.2.0 // indirect
|
||||
github.com/huin/goupnp v1.0.3 // indirect
|
||||
github.com/iancoleman/orderedmap v0.2.0 // indirect
|
||||
github.com/improbable-eng/grpc-web v0.15.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/jmhodges/levigo v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.17.0 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/klauspost/compress v1.17.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.15.15 // indirect
|
||||
github.com/lib/pq v1.10.7 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
@ -166,13 +180,15 @@ require (
|
||||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mmcloughlin/addchain v0.4.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/mtibben/percent v0.2.1 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_model v0.3.0 // indirect
|
||||
github.com/prometheus/common v0.42.0 // indirect
|
||||
github.com/prometheus/common v0.40.0 // indirect
|
||||
github.com/prometheus/procfs v0.9.0 // indirect
|
||||
github.com/prometheus/tsdb v0.7.1 // indirect
|
||||
github.com/rakyll/statik v0.1.7 // indirect
|
||||
@ -180,11 +196,16 @@ require (
|
||||
github.com/rjeczalik/notify v0.9.1 // indirect
|
||||
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
||||
github.com/rs/cors v1.8.3 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/rs/zerolog v1.32.0 // indirect
|
||||
github.com/sasha-s/go-deadlock v0.3.1 // indirect
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/afero v1.9.3 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/status-im/keycard-go v0.2.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
||||
@ -198,26 +219,42 @@ require (
|
||||
github.com/zondax/ledger-go v0.14.3 // indirect
|
||||
go.etcd.io/bbolt v1.3.8 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/otel v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.19.0 // indirect
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
github.com/ugorji/go/codec v1.2.7 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasthttp v1.53.0 // indirect
|
||||
github.com/ulikunitz/xz v0.5.10 // indirect
|
||||
github.com/zondax/hid v0.9.1 // indirect
|
||||
github.com/zondax/ledger-go v0.14.2 // indirect
|
||||
go.etcd.io/bbolt v1.3.7 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb // indirect
|
||||
golang.org/x/net v0.17.0 // indirect
|
||||
golang.org/x/oauth2 v0.10.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.15.0 // indirect
|
||||
golang.org/x/term v0.13.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||
go.uber.org/multierr v1.10.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
|
||||
golang.org/x/net v0.23.0 // indirect
|
||||
golang.org/x/oauth2 v0.15.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/sys v0.21.0 // indirect
|
||||
golang.org/x/term v0.21.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
golang.org/x/sync v0.5.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/term v0.18.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
google.golang.org/api v0.153.0 // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect
|
||||
google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
nhooyr.io/websocket v1.8.6 // indirect
|
||||
pgregory.net/rapid v1.1.0 // indirect
|
||||
pgregory.net/rapid v0.5.5 // indirect
|
||||
rsc.io/tmplfunc v0.0.3 // indirect
|
||||
)
|
||||
|
||||
@ -229,16 +266,19 @@ replace (
|
||||
github.com/cometbft/cometbft-db => github.com/kava-labs/cometbft-db v0.9.1-kava.1
|
||||
// Use cosmos-sdk fork with backported fix for unsafe-reset-all, staking transfer events, and custom tally handler support
|
||||
// github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.46.11-kava.3
|
||||
github.com/cosmos/cosmos-sdk => /home/wenhui/v047/cosmos-sdk
|
||||
github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.47.10-0glabs.0
|
||||
// See https://github.com/cosmos/cosmos-sdk/pull/13093
|
||||
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
|
||||
// Use go-ethereum fork with precompiles
|
||||
github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2
|
||||
// Use ethermint fork that respects min-gas-price with NoBaseFee true and london enabled, and includes eip712 support
|
||||
github.com/evmos/ethermint => github.com/0g-wh/ethermint v0.21.0-0glabs-v26.3.1
|
||||
github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0glabs-v26.3
|
||||
// See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320
|
||||
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
|
||||
// Downgraded to avoid bugs in following commits which causes "version does not exist" errors
|
||||
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
|
||||
golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb
|
||||
// Use cometbft fork of tendermint
|
||||
github.com/tendermint/tendermint => github.com/0glabs/cometbft v0.34.27-0glabs.0
|
||||
// Indirect dependencies still use tendermint/tm-db
|
||||
github.com/tendermint/tm-db => github.com/kava-labs/tm-db v0.6.7-kava.4
|
||||
)
|
||||
|
@ -81,7 +81,7 @@ $BINARY gentx $validatorKeyName 1000000000000000000000ua0gi --keyring-backend te
|
||||
$BINARY collect-gentxs
|
||||
|
||||
# Replace stake with ua0gi
|
||||
sed -in-place='' 's/"stake"/"ua0gi"/g' $DATA/config/genesis.json
|
||||
sed -in-place='' 's/stake/ua0gi/g' $DATA/config/genesis.json
|
||||
|
||||
# Replace the default evm denom of aphoton with neuron
|
||||
sed -in-place='' 's/aphoton/neuron/g' $DATA/config/genesis.json
|
||||
@ -121,4 +121,4 @@ cat $GENESIS | jq '.app_state.evm.params.chain_config.cancun_block = null' >$TMP
|
||||
|
||||
$BINARY config broadcast-mode sync
|
||||
|
||||
$BINARY start --home $DATA --log_output_console
|
||||
$BINARY start --home $DATA
|
||||
|
@ -1,5 +0,0 @@
|
||||
# Legacy REST Endpoint Removal
|
||||
|
||||
Kava 16 (v0.26.x) upgrades cosmos-sdk to v0.47.10+. Legacy REST endpoints, which were previously marked as deprecated, are now [removed](https://github.com/cosmos/cosmos-sdk/blob/v0.47.10/UPGRADING.md#appmodule-interface).
|
||||
|
||||
All consumers of these endpoints must migrate to the GRPC generated REST endpoints. See [Kava Chain Swagger](https://swagger.kava.io/?urls.primaryName=Edge ) for supported REST API Methods.
|
@ -1,77 +0,0 @@
|
||||
# Kava 16 Upgrade Instructions
|
||||
|
||||
## Software Version and Key Dates
|
||||
|
||||
- The version of `kava` for Kava 16 is `v0.26.0`
|
||||
- The Kava 16 chain will be shutdown with a `SoftwareUpgradeProposal` that
|
||||
activates at approximately 15:00 UTC on TBD, 2024.
|
||||
|
||||
## Dependency Changes
|
||||
|
||||
## API Changes
|
||||
|
||||
If you are a consumers of the legacy REST API known as the LCD, please note that this has been deprecated as a part of cosmos-sdk v47. [Additional details can be found here.](./legacy_rest.md)
|
||||
|
||||
### For validators using RocksDB
|
||||
|
||||
> [!NOTE]
|
||||
> If you use goleveldb or other database backends, this is not required.
|
||||
|
||||
If you use RocksDB as your database backend, you will need to update RocksDB if you are using `<= v8.1.1`. The tested and recommended RocksDB version is `v8.10.0`.
|
||||
Please reference the [RocksDB repository](https://github.com/facebook/rocksdb/tree/v8.10.0) to update your installation before building the RocksDB kava binary.
|
||||
|
||||
### On the day of the upgrade
|
||||
|
||||
The kava chain is expected to halt at block height **xxx**. **Do not stop your node and begin the upgrade before the upgrade height**, or you may go offline and be unable to recover until after the upgrade!
|
||||
|
||||
**Make sure the kava process is stopped before proceeding and that you have backed up your validator**. Failure to backup your validator could make it impossible to restart your node if the upgrade fails.
|
||||
|
||||
**Ensure you are using golang 1.21.x and not a different version.** Golang 1.20 and below may cause app hash mismatches!
|
||||
|
||||
To update to v0.26.0
|
||||
|
||||
```sh
|
||||
# check go version - look for 1.21!
|
||||
go version
|
||||
# go version go1.21.6 linux/amd64
|
||||
|
||||
# in the `kava` folder
|
||||
git fetch
|
||||
git checkout v0.26.0
|
||||
|
||||
# Note: Golang 1.21 must be installed before this step
|
||||
make install
|
||||
|
||||
# verify versions
|
||||
kava version --long
|
||||
# name: kava
|
||||
# server_name: kava
|
||||
# version: 0.26.0
|
||||
# commit: <commit placeholder>
|
||||
# build_tags: netgo ledger,
|
||||
# go: go version go1.21.6 linux/amd64
|
||||
# build_deps:
|
||||
# ...
|
||||
# cosmos_sdk_version: v0.47.10
|
||||
|
||||
# Restart node -
|
||||
kava start
|
||||
```
|
||||
|
||||
### Risks
|
||||
|
||||
As a validator, performing the upgrade procedure on your consensus nodes carries a heightened risk of double-signing and being slashed. The most important piece of this procedure is verifying your software version and genesis file hash before starting your validator and signing.
|
||||
|
||||
The riskiest thing a validator can do is discover that they made a mistake and repeat the upgrade procedure again during the network startup. If you discover a mistake in the process, the best thing to do is wait for the network to start before correcting it. If the network is halted and you have started with a different genesis file than the expected one, seek advice from a Kava developer before resetting your validator.
|
||||
|
||||
### Recovery
|
||||
|
||||
Prior to applying the Kava 16 upgrade, validators are encouraged to take a full data snapshot at the upgrade height before proceeding. Snap-shotting depends heavily on infrastructure, but generally this can be done by backing up the .kava directory.
|
||||
|
||||
It is critically important to back-up the .kava/data/priv_validator_state.json file after stopping your kava process. This file is updated every block as your validator participates in consensus rounds. It is a critical file needed to prevent double-signing, in case the upgrade fails and the previous chain needs to be restarted.
|
||||
|
||||
In the event that the upgrade does not succeed, validators and operators must downgrade back to v0.25.x of the Kava software and restore to their latest snapshot before restarting their nodes.
|
||||
|
||||
### Coordination
|
||||
|
||||
If the Kava 16 chain does not launch by TBD at 00:00 UTC, the launch should be considered a failure. In the event of launch failure, coordination will occur in the [Kava discord](https://discord.com/invite/kQzh3Uv).
|
@ -5,4 +5,4 @@ plugins:
|
||||
opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types
|
||||
- name: grpc-gateway
|
||||
out: out
|
||||
opt: logtostderr=true
|
||||
opt: logtostderr=true,allow_colon_final_segments=true
|
||||
|
@ -1,131 +0,0 @@
|
||||
syntax = "proto3";
|
||||
package zg.validatorvesting.v1beta1;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/validator-vesting/types";
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// Query defines the gRPC querier service for validator-vesting module
|
||||
service Query {
|
||||
// CirculatingSupply returns the total amount of kava tokens in circulation
|
||||
rpc CirculatingSupply(QueryCirculatingSupplyRequest) returns (QueryCirculatingSupplyResponse) {
|
||||
option (google.api.http).get = "/0g/validator-vesting/v1beta1/circulating_supply";
|
||||
}
|
||||
|
||||
// TotalSupply returns the total amount of kava tokens
|
||||
rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) {
|
||||
option (google.api.http).get = "/0g/validator-vesting/v1beta1/total_supply";
|
||||
}
|
||||
|
||||
// CirculatingSupplyHARD returns the total amount of hard tokens in circulation
|
||||
rpc CirculatingSupplyHARD(QueryCirculatingSupplyHARDRequest) returns (QueryCirculatingSupplyHARDResponse) {
|
||||
option (google.api.http).get = "/0g/validator-vesting/v1beta1/circulating_supply_hard";
|
||||
}
|
||||
|
||||
// CirculatingSupplyUSDX returns the total amount of usdx tokens in circulation
|
||||
rpc CirculatingSupplyUSDX(QueryCirculatingSupplyUSDXRequest) returns (QueryCirculatingSupplyUSDXResponse) {
|
||||
option (google.api.http).get = "/0g/validator-vesting/v1beta1/circulating_supply_usdx";
|
||||
}
|
||||
|
||||
// CirculatingSupplySWP returns the total amount of swp tokens in circulation
|
||||
rpc CirculatingSupplySWP(QueryCirculatingSupplySWPRequest) returns (QueryCirculatingSupplySWPResponse) {
|
||||
option (google.api.http).get = "/0g/validator-vesting/v1beta1/circulating_supply_swp";
|
||||
}
|
||||
|
||||
// TotalSupplyHARD returns the total amount of hard tokens
|
||||
rpc TotalSupplyHARD(QueryTotalSupplyHARDRequest) returns (QueryTotalSupplyHARDResponse) {
|
||||
option (google.api.http).get = "/0g/validator-vesting/v1beta1/total_supply_hard";
|
||||
}
|
||||
|
||||
// TotalSupplyUSDX returns the total amount of usdx tokens
|
||||
rpc TotalSupplyUSDX(QueryTotalSupplyUSDXRequest) returns (QueryTotalSupplyUSDXResponse) {
|
||||
option (google.api.http).get = "/0g/validator-vesting/v1beta1/total_supply_usdx";
|
||||
}
|
||||
}
|
||||
|
||||
// QueryCirculatingSupplyRequest is the request type for the Query/CirculatingSupply RPC method
|
||||
message QueryCirculatingSupplyRequest {}
|
||||
|
||||
// QueryCirculatingSupplyResponse is the response type for the Query/CirculatingSupply RPC method
|
||||
message QueryCirculatingSupplyResponse {
|
||||
string amount = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC method
|
||||
message QueryTotalSupplyRequest {}
|
||||
|
||||
// QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC method
|
||||
message QueryTotalSupplyResponse {
|
||||
string amount = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// QueryCirculatingSupplyHARDRequest is the request type for the Query/CirculatingSupplyHARD RPC method
|
||||
message QueryCirculatingSupplyHARDRequest {}
|
||||
|
||||
// QueryCirculatingSupplyHARDResponse is the response type for the Query/CirculatingSupplyHARD RPC method
|
||||
message QueryCirculatingSupplyHARDResponse {
|
||||
string amount = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// QueryCirculatingSupplyUSDXRequest is the request type for the Query/CirculatingSupplyUSDX RPC method
|
||||
message QueryCirculatingSupplyUSDXRequest {}
|
||||
|
||||
// QueryCirculatingSupplyUSDXResponse is the response type for the Query/CirculatingSupplyUSDX RPC method
|
||||
message QueryCirculatingSupplyUSDXResponse {
|
||||
string amount = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// QueryCirculatingSupplySWPRequest is the request type for the Query/CirculatingSupplySWP RPC method
|
||||
message QueryCirculatingSupplySWPRequest {}
|
||||
|
||||
// QueryCirculatingSupplySWPResponse is the response type for the Query/CirculatingSupplySWP RPC method
|
||||
message QueryCirculatingSupplySWPResponse {
|
||||
string amount = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// QueryTotalSupplyHARDRequest is the request type for the Query/TotalSupplyHARD RPC method
|
||||
message QueryTotalSupplyHARDRequest {}
|
||||
|
||||
// QueryTotalSupplyHARDResponse is the response type for the Query/TotalSupplyHARD RPC method
|
||||
message QueryTotalSupplyHARDResponse {
|
||||
string amount = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// QueryTotalSupplyUSDXRequest is the request type for the Query/TotalSupplyUSDX RPC method
|
||||
message QueryTotalSupplyUSDXRequest {}
|
||||
|
||||
// QueryTotalSupplyUSDXResponse is the response type for the Query/TotalSupplyUSDX RPC method
|
||||
message QueryTotalSupplyUSDXResponse {
|
||||
string amount = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
@ -9,7 +9,7 @@ option go_package = "github.com/0glabs/0g-chain/x/bep3/types";
|
||||
|
||||
// GenesisState defines the pricefeed module's genesis state.
|
||||
message GenesisState {
|
||||
// params defines all the parameters of the module.
|
||||
// params defines all the paramaters of the module.
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
|
||||
// atomic_swaps represents the state of stored atomic swaps
|
||||
|
@ -9,7 +9,7 @@ option go_package = "github.com/0glabs/0g-chain/x/issuance/types";
|
||||
|
||||
// GenesisState defines the issuance module's genesis state.
|
||||
message GenesisState {
|
||||
// params defines all the parameters of the module.
|
||||
// params defines all the paramaters of the module.
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
|
||||
repeated AssetSupply supplies = 2 [(gogoproto.nullable) = false];
|
||||
|
@ -10,7 +10,7 @@ option (gogoproto.verbose_equal_all) = true;
|
||||
|
||||
// GenesisState defines the pricefeed module's genesis state.
|
||||
message GenesisState {
|
||||
// params defines all the parameters of the module.
|
||||
// params defines all the paramaters of the module.
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
|
||||
repeated PostedPrice posted_prices = 2 [
|
||||
|
@ -8,7 +8,7 @@ E2E_RUN_KVTOOL_NETWORKS=true
|
||||
|
||||
# E2E_KVTOOL_KAVA_CONFIG_TEMPLATE is the kvtool template used to start the chain. See the `kava.configTemplate` flag in kvtool.
|
||||
# Note that the config tempalte must support overriding the docker image tag via the KAVA_TAG variable.
|
||||
E2E_KVTOOL_KAVA_CONFIG_TEMPLATE="v0.25"
|
||||
E2E_KVTOOL_KAVA_CONFIG_TEMPLATE="v0.26"
|
||||
|
||||
# E2E_INCLUDE_IBC_TESTS when true will start a 2nd chain & open an IBC channel. It will enable all IBC tests.
|
||||
E2E_INCLUDE_IBC_TESTS=true
|
||||
@ -21,12 +21,12 @@ E2E_SKIP_SHUTDOWN=false
|
||||
# E2E_INCLUDE_AUTOMATED_UPGRADE when true enables the automated upgrade & corresponding tests in the suite.
|
||||
E2E_INCLUDE_AUTOMATED_UPGRADE=true
|
||||
# E2E_KAVA_UPGRADE_NAME is the name of the upgrade that must be in the current local image.
|
||||
E2E_KAVA_UPGRADE_NAME=v0.26.0
|
||||
E2E_KAVA_UPGRADE_NAME=v0.25.0-testing
|
||||
# E2E_KAVA_UPGRADE_HEIGHT is the height at which the upgrade will be applied.
|
||||
# If IBC tests are enabled this should be >30. Otherwise, this should be >10.
|
||||
E2E_KAVA_UPGRADE_HEIGHT=35
|
||||
# E2E_KAVA_UPGRADE_BASE_IMAGE_TAG is the tag of the docker image the chain should upgrade from.
|
||||
E2E_KAVA_UPGRADE_BASE_IMAGE_TAG=v0.25.1-goleveldb
|
||||
E2E_KAVA_UPGRADE_BASE_IMAGE_TAG=v0.24.0
|
||||
|
||||
# E2E_KAVA_ERC20_ADDRESS is the address of a pre-deployed ERC20 token with the following properties:
|
||||
# - the E2E_KAVA_FUNDED_ACCOUNT_MNEMONIC has nonzero balance
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
|
||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
|
||||
)
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGrpcClientQueryCosmosModule_Balance() {
|
||||
|
@ -1,128 +1,18 @@
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
tmtypes "github.com/cometbft/cometbft/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
cdptypes "github.com/kava-labs/kava/x/cdp/types"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func (suite *IntegrationTestSuite) TestUpgradeParams_SDK() {
|
||||
// TestUpgradeHandler can be used to run tests post-upgrade. If an upgrade is enabled, all tests
|
||||
// are run against the upgraded chain. However, this file is a good place to consolidate all
|
||||
// acceptance tests for a given set of upgrade handlers.
|
||||
func (suite *IntegrationTestSuite) TestUpgradeHandler() {
|
||||
suite.SkipIfUpgradeDisabled()
|
||||
fmt.Println("An upgrade has run!")
|
||||
suite.True(true)
|
||||
|
||||
beforeUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight - 1)
|
||||
afterUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
||||
|
||||
// Before params
|
||||
grpcClient := suite.Kava.Grpc
|
||||
govParamsBefore, err := grpcClient.Query.Gov.Params(beforeUpgradeCtx, &govtypes.QueryParamsRequest{
|
||||
ParamsType: govtypes.ParamDeposit,
|
||||
})
|
||||
suite.NoError(err)
|
||||
govParamsAfter, err := grpcClient.Query.Gov.Params(afterUpgradeCtx, &govtypes.QueryParamsRequest{
|
||||
ParamsType: govtypes.ParamDeposit,
|
||||
})
|
||||
suite.NoError(err)
|
||||
|
||||
// after upgrade, querying params before upgrade height returns nil
|
||||
// since the param gprc query no longer queries x/params
|
||||
suite.Run("x/gov parameters before upgrade", func() {
|
||||
suite.Assert().Nil(
|
||||
govParamsBefore.DepositParams.MaxDepositPeriod,
|
||||
"x/gov DepositParams max deposit period before upgrade should be nil",
|
||||
)
|
||||
suite.Assert().Nil(
|
||||
govParamsBefore.DepositParams.MinDeposit,
|
||||
"x/gov DepositParams min deposit before upgrade should be 10_000_000 ukava",
|
||||
)
|
||||
})
|
||||
|
||||
suite.Run("x/gov parameters after upgrade", func() {
|
||||
suite.Assert().Equal(
|
||||
mustParseDuration("172800s"),
|
||||
govParamsAfter.DepositParams.MaxDepositPeriod,
|
||||
"x/gov DepositParams max deposit period after upgrade should be 172800s",
|
||||
)
|
||||
suite.Assert().Equal(
|
||||
[]sdk.Coin{{Denom: "ukava", Amount: sdk.NewInt(10_000_000)}},
|
||||
govParamsAfter.DepositParams.MinDeposit,
|
||||
"x/gov DepositParams min deposit after upgrade should be 10_000_000 ukava",
|
||||
)
|
||||
|
||||
expectedParams := govtypes.Params{
|
||||
MinDeposit: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(10_000_000))),
|
||||
MaxDepositPeriod: mustParseDuration("172800s"),
|
||||
VotingPeriod: mustParseDuration("30s"),
|
||||
Quorum: "0.334000000000000000",
|
||||
Threshold: "0.500000000000000000",
|
||||
VetoThreshold: "0.334000000000000000",
|
||||
MinInitialDepositRatio: "0.000000000000000000",
|
||||
BurnVoteQuorum: false,
|
||||
BurnProposalDepositPrevote: false,
|
||||
BurnVoteVeto: true,
|
||||
}
|
||||
suite.Require().Equal(expectedParams, *govParamsAfter.Params, "x/gov params after upgrade should be as expected")
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestUpgradeParams_Consensus() {
|
||||
suite.SkipIfUpgradeDisabled()
|
||||
|
||||
afterUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
||||
|
||||
grpcClient := suite.Kava.Grpc
|
||||
paramsAfter, err := grpcClient.Query.Consensus.Params(afterUpgradeCtx, &consensustypes.QueryParamsRequest{})
|
||||
suite.NoError(err)
|
||||
|
||||
// v25 consensus params from x/params should be migrated to x/consensus
|
||||
expectedParams := tmproto.ConsensusParams{
|
||||
Block: &tmproto.BlockParams{
|
||||
MaxBytes: 22020096,
|
||||
MaxGas: 20000000,
|
||||
},
|
||||
Evidence: &tmproto.EvidenceParams{
|
||||
MaxAgeNumBlocks: 100000,
|
||||
MaxAgeDuration: *mustParseDuration("172800s"),
|
||||
MaxBytes: 1048576,
|
||||
},
|
||||
Validator: &tmproto.ValidatorParams{
|
||||
PubKeyTypes: []string{
|
||||
tmtypes.ABCIPubKeyTypeEd25519,
|
||||
},
|
||||
},
|
||||
Version: nil,
|
||||
}
|
||||
suite.Require().Equal(expectedParams, *paramsAfter.Params, "x/consensus params after upgrade should be as expected")
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestUpgradeParams_CDP_Interval() {
|
||||
suite.SkipIfUpgradeDisabled()
|
||||
|
||||
beforeUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight - 1)
|
||||
afterUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
||||
|
||||
grpcClient := suite.Kava.Grpc
|
||||
|
||||
paramsBefore, err := grpcClient.Query.Cdp.Params(beforeUpgradeCtx, &cdptypes.QueryParamsRequest{})
|
||||
suite.Require().NoError(err)
|
||||
paramsAfter, err := grpcClient.Query.Cdp.Params(afterUpgradeCtx, &cdptypes.QueryParamsRequest{})
|
||||
suite.Require().NoError(err)
|
||||
|
||||
expectedParams := paramsBefore.Params
|
||||
expectedParams.LiquidationBlockInterval = int64(50)
|
||||
|
||||
suite.Require().Equal(expectedParams, paramsAfter.Params,
|
||||
"expected cdp parameters to equal previous parameters with a liquidation block interval of 100")
|
||||
}
|
||||
|
||||
func mustParseDuration(s string) *time.Duration {
|
||||
d, err := time.ParseDuration(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &d
|
||||
// Uncomment & use these contexts to compare chain state before & after the upgrade occurs.
|
||||
// beforeUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight - 1)
|
||||
// afterUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 79bb25f47d20c10e70f0539c519240fba82b3302
|
||||
Subproject commit 99214e8b5196b9ab16fa9902f956858c178921a5
|
@ -6,7 +6,7 @@ order: 2
|
||||
|
||||
## Parameters and genesis state
|
||||
|
||||
`parameters` define the rules according to which swaps are executed. Parameter updates can be made via on-chain parameter update proposals.
|
||||
`Paramaters` define the rules according to which swaps are executed. Parameter updates can be made via on-chain parameter update proposals.
|
||||
|
||||
```go
|
||||
// Params governance parameters for bep3 module
|
||||
|
@ -549,80 +549,80 @@ func init() {
|
||||
|
||||
func init() { proto.RegisterFile("zgc/bep3/v1beta1/bep3.proto", fileDescriptor_0c5f13afadd81257) }
|
||||
|
||||
var fileDescriptor_0c5f13afadd81257 = []byte{
|
||||
// 1150 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4d, 0x6f, 0x1a, 0x47,
|
||||
0x18, 0x66, 0x0d, 0x26, 0x66, 0xc0, 0x04, 0x8d, 0x93, 0x06, 0xdb, 0x29, 0x10, 0xa7, 0x6a, 0x51,
|
||||
0x54, 0x83, 0xe3, 0xe4, 0xd8, 0x1e, 0x58, 0xc0, 0x31, 0x92, 0x03, 0x68, 0xc1, 0xea, 0xc7, 0x21,
|
||||
0xdb, 0xd9, 0xdd, 0x61, 0x19, 0x99, 0xdd, 0x59, 0xed, 0x2c, 0x09, 0xce, 0x2f, 0xa8, 0xd4, 0x4b,
|
||||
0x7b, 0xeb, 0xbd, 0xb7, 0x1e, 0xab, 0xfc, 0x88, 0x1c, 0xa3, 0x9c, 0xaa, 0x1e, 0x9c, 0xca, 0xfe,
|
||||
0x17, 0x91, 0x2a, 0x55, 0xf3, 0x61, 0xc0, 0xae, 0x55, 0x71, 0xe0, 0x62, 0xef, 0xfb, 0xf5, 0xbc,
|
||||
0xef, 0xce, 0xbe, 0xcf, 0x33, 0x80, 0xed, 0xd7, 0xae, 0x5d, 0xb5, 0x70, 0xf0, 0xa4, 0xfa, 0xf2,
|
||||
0xb1, 0x85, 0x23, 0xf4, 0x58, 0x18, 0x95, 0x20, 0xa4, 0x11, 0x85, 0xb9, 0xd7, 0xae, 0x5d, 0x11,
|
||||
0xb6, 0x0a, 0x6e, 0x15, 0x6c, 0xca, 0x3c, 0xca, 0xaa, 0x16, 0x62, 0x78, 0x5a, 0x61, 0x53, 0xe2,
|
||||
0xcb, 0x8a, 0xad, 0x4d, 0x19, 0x37, 0x85, 0x55, 0x95, 0x86, 0x0a, 0xdd, 0x71, 0xa9, 0x4b, 0xa5,
|
||||
0x9f, 0x3f, 0x29, 0x6f, 0xc1, 0xa5, 0xd4, 0x1d, 0xe1, 0xaa, 0xb0, 0xac, 0xf1, 0xa0, 0xea, 0x8c,
|
||||
0x43, 0x14, 0x11, 0xaa, 0x00, 0x77, 0x5e, 0x80, 0x64, 0x17, 0x85, 0xc8, 0x63, 0xb0, 0x0f, 0x32,
|
||||
0x88, 0x31, 0x1c, 0x99, 0x81, 0xb0, 0xf3, 0x5a, 0x29, 0x5e, 0x4e, 0xef, 0xdf, 0xaf, 0x5c, 0x9f,
|
||||
0xb1, 0x52, 0xe3, 0x59, 0xa2, 0x48, 0xdf, 0x78, 0x7b, 0x56, 0x8c, 0xfd, 0xfe, 0xa1, 0x98, 0x9e,
|
||||
0xf9, 0x98, 0x91, 0x46, 0x33, 0x63, 0xe7, 0xa7, 0x55, 0x00, 0x66, 0x41, 0x78, 0x07, 0xac, 0x3a,
|
||||
0xd8, 0xa7, 0x5e, 0x5e, 0x2b, 0x69, 0xe5, 0x94, 0x21, 0x0d, 0xf8, 0x10, 0xdc, 0xe2, 0xef, 0x68,
|
||||
0x12, 0x27, 0xbf, 0x52, 0xd2, 0xca, 0x71, 0x1d, 0x9c, 0x9f, 0x15, 0x93, 0x75, 0x4a, 0xfc, 0x56,
|
||||
0xc3, 0x48, 0xf2, 0x50, 0xcb, 0x81, 0x07, 0x20, 0xc3, 0xc6, 0x41, 0x30, 0x3a, 0x35, 0x47, 0xc4,
|
||||
0x23, 0x51, 0x3e, 0x5e, 0xd2, 0xca, 0xe9, 0xfd, 0x4f, 0xff, 0x3b, 0x5f, 0x4f, 0x64, 0x1d, 0xf1,
|
||||
0x24, 0x3d, 0xc1, 0x07, 0x34, 0xd2, 0x6c, 0xe6, 0x82, 0x9f, 0x80, 0x24, 0xb2, 0x23, 0xf2, 0x12,
|
||||
0xe7, 0x13, 0x25, 0xad, 0xbc, 0x66, 0x28, 0x0b, 0x52, 0x90, 0x75, 0x70, 0x30, 0x8e, 0x4e, 0x4d,
|
||||
0xe4, 0x38, 0x21, 0x66, 0x2c, 0xbf, 0x5a, 0xd2, 0xca, 0x19, 0xfd, 0xf0, 0xe3, 0x59, 0x71, 0xd7,
|
||||
0x25, 0xd1, 0x70, 0x6c, 0x55, 0x6c, 0xea, 0xa9, 0x43, 0x57, 0xff, 0x76, 0x99, 0x73, 0x52, 0x8d,
|
||||
0x4e, 0x03, 0xcc, 0x2a, 0x35, 0xdb, 0xae, 0xc9, 0xc2, 0xf7, 0x6f, 0x76, 0x37, 0xd4, 0xa7, 0x51,
|
||||
0x1e, 0xfd, 0x34, 0xc2, 0xcc, 0x58, 0x97, 0xf8, 0xca, 0x07, 0xbf, 0x03, 0xa9, 0x01, 0x99, 0x60,
|
||||
0xc7, 0x1c, 0x60, 0x9c, 0x4f, 0xf2, 0xf3, 0xd0, 0xbf, 0xe2, 0xe3, 0xfe, 0x75, 0x56, 0xfc, 0x7c,
|
||||
0x81, 0x7e, 0x2d, 0x3f, 0x7a, 0xff, 0x66, 0x17, 0xa8, 0x46, 0x2d, 0x3f, 0x32, 0xd6, 0x04, 0xdc,
|
||||
0x01, 0xc6, 0xd0, 0x01, 0xb7, 0x3d, 0xe2, 0x9b, 0xec, 0x15, 0x0a, 0x4c, 0xe4, 0xd1, 0xb1, 0x1f,
|
||||
0xe5, 0x6f, 0x2d, 0xa1, 0xc1, 0xba, 0x47, 0xfc, 0xde, 0x2b, 0x14, 0xd4, 0x04, 0xa4, 0xe8, 0x82,
|
||||
0x26, 0x57, 0xba, 0xac, 0x2d, 0xa5, 0x0b, 0x9a, 0xcc, 0x75, 0xf9, 0x0c, 0x64, 0xf9, 0xbb, 0x58,
|
||||
0x23, 0x6a, 0x9f, 0x98, 0xfc, 0x4f, 0x3e, 0x55, 0xd2, 0xca, 0x09, 0x23, 0xe3, 0x11, 0x5f, 0xe7,
|
||||
0xf6, 0x11, 0xb5, 0x4f, 0x44, 0x16, 0x9a, 0xcc, 0x67, 0x01, 0x95, 0x85, 0x26, 0xd3, 0xac, 0x9d,
|
||||
0x3f, 0x56, 0x40, 0x7a, 0x6e, 0x3d, 0xa0, 0x01, 0x56, 0xe5, 0x32, 0x69, 0x4b, 0x98, 0x5b, 0x42,
|
||||
0xc1, 0x07, 0x20, 0x13, 0x11, 0x0f, 0xcb, 0x2d, 0xc5, 0x72, 0xa3, 0xd7, 0x8c, 0x34, 0xf7, 0x1d,
|
||||
0x49, 0x17, 0x6c, 0x00, 0x61, 0x9a, 0x01, 0x0e, 0x09, 0x75, 0xd4, 0x26, 0x6f, 0x56, 0x24, 0x55,
|
||||
0x2b, 0x97, 0x54, 0xad, 0x34, 0x14, 0x55, 0xf5, 0x35, 0x3e, 0xd7, 0xaf, 0x1f, 0x8a, 0x9a, 0x01,
|
||||
0x78, 0x5d, 0x57, 0x94, 0xc1, 0x01, 0xc8, 0x09, 0x14, 0xae, 0x15, 0x8e, 0x22, 0x45, 0x62, 0x09,
|
||||
0xef, 0x91, 0xe5, 0xa8, 0x3a, 0x07, 0x15, 0xf3, 0xee, 0xfc, 0xc3, 0x29, 0x1c, 0x51, 0x8f, 0xd8,
|
||||
0xfc, 0xab, 0x40, 0x1b, 0x24, 0xd5, 0xc7, 0x96, 0x0a, 0xb1, 0x59, 0x51, 0xb5, 0x7c, 0x8e, 0x29,
|
||||
0x09, 0x39, 0x79, 0xf5, 0x3d, 0x25, 0x0f, 0xe5, 0x05, 0xe6, 0xe0, 0x05, 0xcc, 0x50, 0xd0, 0xd0,
|
||||
0x02, 0x30, 0x44, 0xbe, 0x43, 0x3d, 0xd3, 0x1f, 0x7b, 0x16, 0x0e, 0xcd, 0x21, 0x62, 0x43, 0x71,
|
||||
0x94, 0x19, 0xfd, 0xe9, 0xc7, 0xb3, 0xe2, 0xde, 0x15, 0x44, 0x0f, 0x47, 0xd6, 0x20, 0x9a, 0x3d,
|
||||
0x8c, 0x88, 0xc5, 0xaa, 0x16, 0xe7, 0x5c, 0xe5, 0x10, 0x4f, 0x24, 0xf9, 0x72, 0x12, 0xaf, 0x2d,
|
||||
0xe0, 0x0e, 0x11, 0x1b, 0xc2, 0x87, 0x60, 0x1d, 0x4f, 0x02, 0x12, 0x62, 0x73, 0x88, 0x89, 0x3b,
|
||||
0x94, 0x8a, 0x92, 0x30, 0x32, 0xd2, 0x79, 0x28, 0x7c, 0xf0, 0x3e, 0x48, 0xf1, 0xe3, 0x60, 0x11,
|
||||
0xf2, 0x02, 0x71, 0xba, 0x71, 0x63, 0xe6, 0x80, 0x3f, 0x80, 0x24, 0xc3, 0xbe, 0x83, 0xc3, 0xa5,
|
||||
0x6b, 0x85, 0xc2, 0x85, 0x03, 0x90, 0x0a, 0xb1, 0x4d, 0x02, 0x82, 0xfd, 0x48, 0x88, 0xc4, 0x32,
|
||||
0x9b, 0xcc, 0xa0, 0xe1, 0x97, 0x00, 0xca, 0x8e, 0x26, 0x8d, 0x86, 0x38, 0x34, 0xed, 0x21, 0x22,
|
||||
0xbe, 0x14, 0x0d, 0x23, 0x27, 0x23, 0x1d, 0x1e, 0xa8, 0x73, 0x3f, 0xdc, 0x07, 0x77, 0xa7, 0xa5,
|
||||
0x57, 0x0a, 0x04, 0xff, 0x8d, 0x8d, 0x69, 0x70, 0xae, 0xe6, 0x01, 0xc8, 0xd8, 0x23, 0xca, 0x57,
|
||||
0xd5, 0x9a, 0xb2, 0x38, 0x6e, 0xa4, 0xa5, 0x4f, 0x50, 0x14, 0x3e, 0x05, 0x49, 0x16, 0xa1, 0x68,
|
||||
0xcc, 0x04, 0x79, 0xb3, 0x37, 0x5d, 0x3e, 0x7c, 0x05, 0x7b, 0x22, 0xc7, 0x50, 0xb9, 0xb0, 0x08,
|
||||
0xd2, 0x76, 0x48, 0x19, 0x53, 0x23, 0xa4, 0x05, 0xdf, 0x80, 0x70, 0xc9, 0xce, 0x5f, 0x83, 0x94,
|
||||
0x43, 0x42, 0x6c, 0x73, 0x2e, 0xe5, 0x33, 0x02, 0xb9, 0x78, 0x33, 0x72, 0xe3, 0x32, 0xcd, 0x98,
|
||||
0x55, 0xec, 0xfc, 0x12, 0x07, 0xf2, 0x7e, 0x93, 0xca, 0x01, 0x0f, 0xc1, 0x6d, 0xe2, 0xdb, 0xd4,
|
||||
0x23, 0xbe, 0x6b, 0xca, 0x8b, 0x45, 0xc8, 0xc7, 0xff, 0x32, 0x41, 0xde, 0x43, 0xd9, 0xcb, 0xba,
|
||||
0x19, 0x12, 0x1d, 0x47, 0x2e, 0x9d, 0x43, 0x5a, 0x59, 0x10, 0xe9, 0xb2, 0x4e, 0x21, 0x1d, 0x80,
|
||||
0xac, 0x3d, 0x0e, 0x43, 0xfe, 0x39, 0x14, 0x50, 0x7c, 0x31, 0xa0, 0x75, 0x55, 0xa6, 0x70, 0x5e,
|
||||
0x80, 0xed, 0x79, 0xf1, 0x32, 0xaf, 0x81, 0x26, 0x16, 0x03, 0xcd, 0xcf, 0x89, 0x5d, 0xfd, 0x0a,
|
||||
0xfe, 0x81, 0x12, 0x47, 0x3c, 0x42, 0x01, 0xc3, 0x8e, 0xa0, 0xcd, 0x82, 0xd2, 0x27, 0x24, 0xb3,
|
||||
0x29, 0xeb, 0x1e, 0x9d, 0x02, 0x30, 0xdb, 0x04, 0xb8, 0x0d, 0xee, 0xf5, 0xbe, 0xa9, 0x75, 0xcd,
|
||||
0x5e, 0xbf, 0xd6, 0x3f, 0xee, 0x99, 0xc7, 0xed, 0x5e, 0xb7, 0x59, 0x6f, 0x1d, 0xb4, 0x9a, 0x8d,
|
||||
0x5c, 0x0c, 0xde, 0x01, 0xb9, 0xf9, 0x60, 0xa7, 0xdb, 0x6c, 0xe7, 0x34, 0xb8, 0x09, 0xee, 0xce,
|
||||
0x7b, 0xeb, 0x9d, 0xe7, 0xdd, 0xa3, 0x66, 0xbf, 0xd9, 0xc8, 0xad, 0xc0, 0x7b, 0x60, 0x63, 0x3e,
|
||||
0xd4, 0xfc, 0xb6, 0xdb, 0x32, 0x9a, 0x8d, 0x5c, 0x7c, 0x2b, 0xf1, 0xe3, 0x6f, 0x85, 0xd8, 0x23,
|
||||
0x0a, 0xd6, 0xaf, 0xac, 0x0a, 0x2c, 0x80, 0x2d, 0x91, 0xdf, 0x68, 0x19, 0xcd, 0x7a, 0xbf, 0xd5,
|
||||
0x69, 0x5f, 0x1b, 0xe0, 0x72, 0xba, 0x59, 0xbc, 0xd5, 0xae, 0x77, 0x9e, 0xb7, 0xda, 0xcf, 0x72,
|
||||
0xda, 0x0d, 0xc1, 0xce, 0x71, 0xff, 0x59, 0x87, 0x07, 0x57, 0x64, 0x43, 0xbd, 0xf6, 0xf6, 0xbc,
|
||||
0xa0, 0xbd, 0x3b, 0x2f, 0x68, 0x7f, 0x9f, 0x17, 0xb4, 0x9f, 0x2f, 0x0a, 0xb1, 0x77, 0x17, 0x85,
|
||||
0xd8, 0x9f, 0x17, 0x85, 0xd8, 0xf7, 0x5f, 0xcc, 0xa9, 0xc0, 0x9e, 0x3b, 0x42, 0x16, 0xab, 0xee,
|
||||
0xb9, 0xbb, 0x82, 0x06, 0xd5, 0x89, 0xfc, 0xd5, 0x29, 0xa4, 0xc0, 0x4a, 0x8a, 0x83, 0x7d, 0xf2,
|
||||
0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd7, 0xf8, 0xaf, 0x5c, 0x8e, 0x0a, 0x00, 0x00,
|
||||
var fileDescriptor_01a01937d931b013 = []byte{
|
||||
// 1147 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4d, 0x6f, 0x1a, 0x57,
|
||||
0x17, 0xf6, 0x18, 0x4c, 0xec, 0x03, 0x26, 0xbc, 0xd7, 0xc9, 0x1b, 0xec, 0xa4, 0x40, 0x9c, 0xaa,
|
||||
0x42, 0x51, 0x0d, 0xf9, 0x68, 0x77, 0x55, 0x55, 0x06, 0x70, 0x8c, 0xe4, 0x00, 0x1a, 0x6c, 0xf5,
|
||||
0x63, 0xd1, 0xe9, 0x9d, 0x99, 0x0b, 0x5c, 0x99, 0x99, 0x3b, 0x9a, 0x3b, 0x24, 0xf8, 0x1f, 0x74,
|
||||
0xd1, 0x45, 0xbb, 0xeb, 0xbe, 0xbb, 0x2e, 0xab, 0xfc, 0x88, 0x2c, 0xa3, 0xac, 0xaa, 0x2e, 0x9c,
|
||||
0xca, 0xf9, 0x17, 0xd9, 0xb4, 0xba, 0x1f, 0x06, 0x9c, 0xba, 0x15, 0x0b, 0x36, 0xf6, 0x9c, 0xaf,
|
||||
0xe7, 0x9c, 0xb9, 0x73, 0x9e, 0xe7, 0x02, 0x77, 0x4e, 0xf0, 0x33, 0x5c, 0x75, 0x48, 0xf8, 0xb8,
|
||||
0xfa, 0xec, 0xa1, 0x43, 0x62, 0xfc, 0x50, 0x1a, 0x95, 0x30, 0x62, 0x31, 0x43, 0xff, 0x13, 0xd1,
|
||||
0x8a, 0x74, 0xe8, 0xe8, 0x4e, 0xc1, 0x65, 0xdc, 0x67, 0xbc, 0xea, 0x60, 0x4e, 0xa6, 0x25, 0x2e,
|
||||
0xa3, 0x81, 0x2a, 0xd9, 0xd9, 0x56, 0x71, 0x5b, 0x5a, 0x55, 0x65, 0xe8, 0xd0, 0x8d, 0x01, 0x1b,
|
||||
0x30, 0xe5, 0x17, 0x4f, 0xda, 0x5b, 0x18, 0x30, 0x36, 0x18, 0x91, 0xaa, 0xb4, 0x9c, 0x71, 0xbf,
|
||||
0xea, 0x8d, 0x23, 0x1c, 0x53, 0xa6, 0x01, 0x77, 0x6d, 0x48, 0x75, 0x71, 0x84, 0x7d, 0x8e, 0x8e,
|
||||
0x21, 0x83, 0x39, 0x27, 0xb1, 0x1d, 0x4a, 0x3b, 0x6f, 0x94, 0x12, 0xe5, 0xf4, 0xa3, 0x0f, 0x2a,
|
||||
0xff, 0x18, 0xb2, 0x52, 0x13, 0x69, 0xb2, 0xca, 0xdc, 0x7a, 0x79, 0x56, 0x5c, 0xf9, 0xf5, 0x4d,
|
||||
0x31, 0x3d, 0xf3, 0x71, 0x2b, 0x8d, 0x67, 0xc6, 0xee, 0x0f, 0x6b, 0x00, 0xb3, 0x20, 0xba, 0x01,
|
||||
0x6b, 0x1e, 0x09, 0x98, 0x9f, 0x37, 0x4a, 0x46, 0x79, 0xc3, 0x52, 0x06, 0xba, 0x07, 0xd7, 0xc4,
|
||||
0x4b, 0xda, 0xd4, 0xcb, 0xaf, 0x96, 0x8c, 0x72, 0xc2, 0x84, 0xf3, 0xb3, 0x62, 0xaa, 0xce, 0x68,
|
||||
0xd0, 0x6a, 0x58, 0x29, 0x11, 0x6a, 0x79, 0xe8, 0x09, 0x64, 0xf8, 0x38, 0x0c, 0x47, 0xa7, 0xf6,
|
||||
0x88, 0xfa, 0x34, 0xce, 0x27, 0x4a, 0x46, 0x39, 0xfd, 0xa8, 0x70, 0xc5, 0x80, 0x3d, 0x99, 0x76,
|
||||
0x28, 0xb2, 0xcc, 0xa4, 0x98, 0xd0, 0x4a, 0xf3, 0x99, 0x0b, 0xfd, 0x1f, 0x52, 0xd8, 0x8d, 0xe9,
|
||||
0x33, 0x92, 0x4f, 0x96, 0x8c, 0xf2, 0xba, 0xa5, 0x2d, 0xc4, 0x20, 0xeb, 0x91, 0x70, 0x1c, 0x9f,
|
||||
0xda, 0xd8, 0xf3, 0x22, 0xc2, 0x79, 0x7e, 0xad, 0x64, 0x94, 0x33, 0xe6, 0xc1, 0xbb, 0xb3, 0xe2,
|
||||
0xde, 0x80, 0xc6, 0xc3, 0xb1, 0x53, 0x71, 0x99, 0xaf, 0x8f, 0x5d, 0xff, 0xdb, 0xe3, 0xde, 0x49,
|
||||
0x35, 0x3e, 0x0d, 0x09, 0xaf, 0xd4, 0x5c, 0xb7, 0xa6, 0x0a, 0x5f, 0xbf, 0xd8, 0xdb, 0xd2, 0x1f,
|
||||
0x47, 0x7b, 0xcc, 0xd3, 0x98, 0x70, 0x6b, 0x53, 0xe1, 0x6b, 0x1f, 0xfa, 0x1a, 0x36, 0xfa, 0x74,
|
||||
0x42, 0x3c, 0xbb, 0x4f, 0x48, 0x3e, 0x25, 0x0e, 0xc4, 0xfc, 0x4c, 0x8c, 0xfb, 0xc7, 0x59, 0xf1,
|
||||
0xa3, 0x05, 0xfa, 0xb5, 0x82, 0xf8, 0xf5, 0x8b, 0x3d, 0xd0, 0x8d, 0x5a, 0x41, 0x6c, 0xad, 0x4b,
|
||||
0xb8, 0x7d, 0x42, 0x90, 0x07, 0xd7, 0x7d, 0x1a, 0xd8, 0xfc, 0x39, 0x0e, 0x6d, 0xec, 0xb3, 0x71,
|
||||
0x10, 0xe7, 0xaf, 0x2d, 0xa1, 0xc1, 0xa6, 0x4f, 0x83, 0xde, 0x73, 0x1c, 0xd6, 0x24, 0xa4, 0xec,
|
||||
0x82, 0x27, 0x97, 0xba, 0xac, 0x2f, 0xa5, 0x0b, 0x9e, 0xcc, 0x75, 0xf9, 0x10, 0xb2, 0xe2, 0x5d,
|
||||
0x9c, 0x11, 0x73, 0x4f, 0x6c, 0xf1, 0x27, 0xbf, 0x51, 0x32, 0xca, 0x49, 0x2b, 0xe3, 0xd3, 0xc0,
|
||||
0x14, 0xf6, 0x21, 0x73, 0x4f, 0x64, 0x16, 0x9e, 0xcc, 0x67, 0x81, 0xce, 0xc2, 0x93, 0x69, 0xd6,
|
||||
0xee, 0x6f, 0xab, 0x90, 0x9e, 0x5b, 0x0f, 0x64, 0xc1, 0x9a, 0xda, 0x26, 0x63, 0x09, 0x73, 0x2b,
|
||||
0x28, 0x74, 0x17, 0x32, 0x31, 0xf5, 0x89, 0x5a, 0x53, 0xa2, 0x56, 0x7a, 0xdd, 0x4a, 0x0b, 0xdf,
|
||||
0xa1, 0x72, 0xa1, 0x06, 0x48, 0xd3, 0x0e, 0x49, 0x44, 0x99, 0xa7, 0x57, 0x79, 0xbb, 0xa2, 0xc8,
|
||||
0x5a, 0xb9, 0x20, 0x6b, 0xa5, 0xa1, 0xc9, 0x6a, 0xae, 0x8b, 0xb9, 0x7e, 0x7e, 0x53, 0x34, 0x2c,
|
||||
0x10, 0x75, 0x5d, 0x59, 0x86, 0xfa, 0x90, 0x93, 0x28, 0x42, 0x2d, 0x3c, 0xcd, 0x8a, 0xe4, 0x12,
|
||||
0xde, 0x23, 0x2b, 0x50, 0x4d, 0x01, 0x2a, 0xe7, 0xdd, 0xfd, 0x4b, 0x70, 0x38, 0x66, 0x3e, 0x75,
|
||||
0xc5, 0x57, 0x41, 0x2e, 0xa4, 0xf4, 0xc7, 0x56, 0x1a, 0xb1, 0x5d, 0xd1, 0xb5, 0x62, 0x8e, 0x29,
|
||||
0x09, 0x05, 0x7b, 0xcd, 0x07, 0x5a, 0x1f, 0xca, 0x0b, 0xcc, 0x21, 0x0a, 0xb8, 0xa5, 0xa1, 0x91,
|
||||
0x03, 0x28, 0xc2, 0x81, 0xc7, 0x7c, 0x3b, 0x18, 0xfb, 0x0e, 0x89, 0xec, 0x21, 0xe6, 0x43, 0x79,
|
||||
0x94, 0x19, 0xf3, 0x93, 0x77, 0x67, 0xc5, 0x07, 0x97, 0x10, 0x7d, 0x12, 0x3b, 0xfd, 0x78, 0xf6,
|
||||
0x30, 0xa2, 0x0e, 0xaf, 0x3a, 0x82, 0x73, 0x95, 0x03, 0x32, 0x51, 0xe4, 0xcb, 0x29, 0xbc, 0xb6,
|
||||
0x84, 0x3b, 0xc0, 0x7c, 0x88, 0xee, 0xc1, 0x26, 0x99, 0x84, 0x34, 0x22, 0xf6, 0x90, 0xd0, 0xc1,
|
||||
0x50, 0x49, 0x4a, 0xd2, 0xca, 0x28, 0xe7, 0x81, 0xf4, 0xa1, 0x3b, 0xb0, 0x21, 0x8e, 0x83, 0xc7,
|
||||
0xd8, 0x0f, 0xe5, 0xe9, 0x26, 0xac, 0x99, 0x03, 0x7d, 0x07, 0x29, 0x4e, 0x02, 0x8f, 0x44, 0x4b,
|
||||
0xd7, 0x0a, 0x8d, 0x8b, 0xfa, 0xb0, 0x11, 0x11, 0x97, 0x86, 0x94, 0x04, 0xb1, 0x14, 0x89, 0x65,
|
||||
0x36, 0x99, 0x41, 0xa3, 0x8f, 0x01, 0xa9, 0x8e, 0x36, 0x8b, 0x87, 0x24, 0xb2, 0xdd, 0x21, 0xa6,
|
||||
0x81, 0x12, 0x0d, 0x2b, 0xa7, 0x22, 0x1d, 0x11, 0xa8, 0x0b, 0x3f, 0x7a, 0x04, 0x37, 0xa7, 0xa5,
|
||||
0x97, 0x0a, 0x24, 0xff, 0xad, 0xad, 0x69, 0x70, 0xae, 0xe6, 0x2e, 0x64, 0xdc, 0x11, 0x13, 0xab,
|
||||
0xea, 0x4c, 0x59, 0x9c, 0xb0, 0xd2, 0xca, 0x27, 0x29, 0x8a, 0x3e, 0x85, 0x14, 0x8f, 0x71, 0x3c,
|
||||
0xe6, 0x92, 0xbc, 0xd9, 0x2b, 0xaf, 0x1f, 0xb1, 0x83, 0x3d, 0x99, 0x64, 0xe9, 0x64, 0x54, 0x84,
|
||||
0xb4, 0x1b, 0x31, 0xce, 0xf5, 0x0c, 0x69, 0x49, 0x38, 0x90, 0x2e, 0xd5, 0xfa, 0x73, 0xd8, 0xf0,
|
||||
0x68, 0x44, 0x5c, 0x41, 0xa6, 0x7c, 0x46, 0x42, 0x97, 0xfe, 0x05, 0xba, 0x71, 0x91, 0x67, 0xcd,
|
||||
0x4a, 0x76, 0x7f, 0x4a, 0x80, 0xba, 0xe2, 0x94, 0x76, 0xa0, 0x03, 0xb8, 0x4e, 0x03, 0x97, 0xf9,
|
||||
0x34, 0x18, 0xd8, 0xea, 0x6a, 0x91, 0x02, 0xf2, 0x9f, 0x5c, 0x50, 0x37, 0x51, 0xf6, 0xa2, 0x6e,
|
||||
0x86, 0xc4, 0xc6, 0xf1, 0x80, 0xcd, 0x21, 0xad, 0x2e, 0x88, 0x74, 0x51, 0xa7, 0x91, 0xf6, 0x21,
|
||||
0xeb, 0x8e, 0xa3, 0x48, 0x7c, 0x10, 0x0d, 0x94, 0x58, 0x0c, 0x68, 0x53, 0x97, 0x69, 0x9c, 0x6f,
|
||||
0xe1, 0xf6, 0xbc, 0x7c, 0xd9, 0xef, 0x81, 0x26, 0x17, 0x03, 0xcd, 0xcf, 0xc9, 0x5d, 0xfd, 0x12,
|
||||
0xfe, 0xbe, 0x96, 0x47, 0x32, 0xc2, 0x21, 0x27, 0x9e, 0x24, 0xce, 0x82, 0xe2, 0x27, 0x45, 0xb3,
|
||||
0xa9, 0xea, 0xee, 0x9f, 0x02, 0xcc, 0x56, 0x01, 0xdd, 0x86, 0x5b, 0xbd, 0x2f, 0x6b, 0x5d, 0xbb,
|
||||
0x77, 0x54, 0x3b, 0x3a, 0xee, 0xd9, 0xc7, 0xed, 0x5e, 0xb7, 0x59, 0x6f, 0xed, 0xb7, 0x9a, 0x8d,
|
||||
0xdc, 0x0a, 0xba, 0x01, 0xb9, 0xf9, 0x60, 0xa7, 0xdb, 0x6c, 0xe7, 0x0c, 0xb4, 0x0d, 0x37, 0xe7,
|
||||
0xbd, 0xf5, 0xce, 0xd3, 0xee, 0x61, 0xf3, 0xa8, 0xd9, 0xc8, 0xad, 0xa2, 0x5b, 0xb0, 0x35, 0x1f,
|
||||
0x6a, 0x7e, 0xd5, 0x6d, 0x59, 0xcd, 0x46, 0x2e, 0xb1, 0x93, 0xfc, 0xfe, 0x97, 0xc2, 0xca, 0x7d,
|
||||
0x06, 0x9b, 0x97, 0x56, 0x05, 0x15, 0x60, 0x47, 0xe6, 0x37, 0x5a, 0x56, 0xb3, 0x7e, 0xd4, 0xea,
|
||||
0xb4, 0xdf, 0x1b, 0xe0, 0x62, 0xba, 0x59, 0xbc, 0xd5, 0xae, 0x77, 0x9e, 0xb6, 0xda, 0x4f, 0x72,
|
||||
0xc6, 0x15, 0xc1, 0xce, 0xf1, 0xd1, 0x93, 0x8e, 0x08, 0xae, 0xaa, 0x86, 0xe6, 0x17, 0x2f, 0xcf,
|
||||
0x0b, 0xc6, 0xab, 0xf3, 0x82, 0xf1, 0xe7, 0x79, 0xc1, 0xf8, 0xf1, 0x6d, 0x61, 0xe5, 0xd5, 0xdb,
|
||||
0xc2, 0xca, 0xef, 0x6f, 0x0b, 0x2b, 0xdf, 0xcc, 0x2b, 0xbc, 0x58, 0xe8, 0xbd, 0x11, 0x76, 0xb8,
|
||||
0x7c, 0xaa, 0x4e, 0xd4, 0x2f, 0x4f, 0xa9, 0x05, 0x4e, 0x4a, 0x9e, 0xeb, 0xe3, 0xbf, 0x03, 0x00,
|
||||
0x00, 0xff, 0xff, 0x79, 0xfe, 0xe7, 0xb2, 0x93, 0x0a, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Params) Marshal() (dAtA []byte, err error) {
|
||||
|
@ -29,7 +29,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// GenesisState defines the pricefeed module's genesis state.
|
||||
type GenesisState struct {
|
||||
// params defines all the parameters of the module.
|
||||
// params defines all the paramaters of the module.
|
||||
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
||||
// atomic_swaps represents the state of stored atomic swaps
|
||||
AtomicSwaps AtomicSwaps `protobuf:"bytes,2,rep,name=atomic_swaps,json=atomicSwaps,proto3,castrepeated=AtomicSwaps" json:"atomic_swaps"`
|
||||
|
83
x/bep3/types/querier.go
Normal file
83
x/bep3/types/querier.go
Normal file
@ -0,0 +1,83 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
tmbytes "github.com/cometbft/cometbft/libs/bytes"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
const (
|
||||
// QueryGetAssetSupply command for getting info about an asset's supply
|
||||
QueryGetAssetSupply = "supply"
|
||||
// QueryGetAssetSupplies command for getting a list of asset supplies
|
||||
QueryGetAssetSupplies = "supplies"
|
||||
// QueryGetAtomicSwap command for getting info about an atomic swap
|
||||
QueryGetAtomicSwap = "swap"
|
||||
// QueryGetAtomicSwaps command for getting a list of atomic swaps
|
||||
QueryGetAtomicSwaps = "swaps"
|
||||
// QueryGetParams command for getting module params
|
||||
QueryGetParams = "parameters"
|
||||
)
|
||||
|
||||
// Legacy querier requests
|
||||
|
||||
// QueryAssetSupply contains the params for query 'custom/bep3/supply'
|
||||
type QueryAssetSupply struct {
|
||||
Denom string `json:"denom" yaml:"denom"`
|
||||
}
|
||||
|
||||
// NewQueryAssetSupply creates a new QueryAssetSupply
|
||||
func NewQueryAssetSupply(denom string) QueryAssetSupply {
|
||||
return QueryAssetSupply{
|
||||
Denom: denom,
|
||||
}
|
||||
}
|
||||
|
||||
// QueryAssetSupplies contains the params for an AssetSupplies query
|
||||
type QueryAssetSupplies struct {
|
||||
Page int `json:"page" yaml:"page"`
|
||||
Limit int `json:"limit" yaml:"limit"`
|
||||
}
|
||||
|
||||
// NewQueryAssetSupplies creates a new QueryAssetSupplies
|
||||
func NewQueryAssetSupplies(page int, limit int) QueryAssetSupplies {
|
||||
return QueryAssetSupplies{
|
||||
Page: page,
|
||||
Limit: limit,
|
||||
}
|
||||
}
|
||||
|
||||
// QueryAtomicSwapByID contains the params for query 'custom/bep3/swap'
|
||||
type QueryAtomicSwapByID struct {
|
||||
SwapID tmbytes.HexBytes `json:"swap_id" yaml:"swap_id"`
|
||||
}
|
||||
|
||||
// NewQueryAtomicSwapByID creates a new QueryAtomicSwapByID
|
||||
func NewQueryAtomicSwapByID(swapBytes tmbytes.HexBytes) QueryAtomicSwapByID {
|
||||
return QueryAtomicSwapByID{
|
||||
SwapID: swapBytes,
|
||||
}
|
||||
}
|
||||
|
||||
// QueryAtomicSwaps contains the params for an AtomicSwaps query
|
||||
type QueryAtomicSwaps struct {
|
||||
Page int `json:"page" yaml:"page"`
|
||||
Limit int `json:"limit" yaml:"limit"`
|
||||
Involve sdk.AccAddress `json:"involve" yaml:"involve"`
|
||||
Expiration uint64 `json:"expiration" yaml:"expiration"`
|
||||
Status SwapStatus `json:"status" yaml:"status"`
|
||||
Direction SwapDirection `json:"direction" yaml:"direction"`
|
||||
}
|
||||
|
||||
// NewQueryAtomicSwaps creates a new instance of QueryAtomicSwaps
|
||||
func NewQueryAtomicSwaps(page, limit int, involve sdk.AccAddress, expiration uint64,
|
||||
status SwapStatus, direction SwapDirection,
|
||||
) QueryAtomicSwaps {
|
||||
return QueryAtomicSwaps{
|
||||
Page: page,
|
||||
Limit: limit,
|
||||
Involve: involve,
|
||||
Expiration: expiration,
|
||||
Status: status,
|
||||
Direction: direction,
|
||||
}
|
||||
}
|
@ -479,15 +479,15 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "bep3", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "bep3", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_AssetSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "bep3", "v1beta1", "assetsupply", "denom"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_AssetSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "bep3", "v1beta1", "assetsupply", "denom"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_AssetSupplies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "bep3", "v1beta1", "assetsupplies"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_AssetSupplies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "bep3", "v1beta1", "assetsupplies"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_AtomicSwap_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "bep3", "v1beta1", "atomicswap", "swap_id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_AtomicSwap_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "bep3", "v1beta1", "atomicswap", "swap_id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_AtomicSwaps_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "bep3", "v1beta1", "atomicswaps"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_AtomicSwaps_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "bep3", "v1beta1", "atomicswaps"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -3,6 +3,7 @@ package v2
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/kava-labs/kava/x/cdp/types"
|
||||
)
|
||||
|
||||
// MigrateStore performs in-place store migrations for consensus version 2
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
|
||||
v2cdp "github.com/kava-labs/kava/x/cdp/migrations/v2"
|
||||
"github.com/kava-labs/kava/x/cdp/types"
|
||||
)
|
||||
|
||||
func TestStoreMigrationAddsKeyTableIncludingNewParam(t *testing.T) {
|
||||
|
@ -1,9 +1,14 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
|
||||
@ -57,3 +62,99 @@ func QueryProposer(cliCtx client.Context, proposalID uint64) (Proposer, error) {
|
||||
|
||||
return Proposer{}, fmt.Errorf("failed to find the proposer for proposalID %d", proposalID)
|
||||
}
|
||||
|
||||
// QueryProposalByID returns a proposal from state if present or fallbacks to searching old blocks
|
||||
func QueryProposalByID(cliCtx client.Context, cdc *codec.LegacyAmino, queryRoute string, proposalID uint64) (*types.Proposal, int64, error) {
|
||||
bz, err := cdc.MarshalJSON(types.NewQueryProposalParams(proposalID))
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryProposal), bz)
|
||||
|
||||
if err == nil {
|
||||
var proposal types.Proposal
|
||||
cdc.MustUnmarshalJSON(res, &proposal)
|
||||
|
||||
return &proposal, height, nil
|
||||
}
|
||||
|
||||
// NOTE: !errors.Is(err, types.ErrUnknownProposal) does not work here
|
||||
if err != nil && !strings.Contains(err.Error(), "proposal not found") {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
res, height, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryNextProposalID), nil)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
var nextProposalID uint64
|
||||
cdc.MustUnmarshalJSON(res, &nextProposalID)
|
||||
|
||||
if proposalID >= nextProposalID {
|
||||
return nil, 0, errorsmod.Wrapf(types.ErrUnknownProposal, "%d", proposalID)
|
||||
}
|
||||
|
||||
events := []string{
|
||||
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgSubmitProposal),
|
||||
fmt.Sprintf("%s.%s='%s'", types.EventTypeProposalSubmit, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", proposalID))),
|
||||
}
|
||||
|
||||
searchResult, err := authtx.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit, "")
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
for _, info := range searchResult.Txs {
|
||||
for _, msg := range info.GetTx().GetMsgs() {
|
||||
if subMsg, ok := msg.(*types.MsgSubmitProposal); ok {
|
||||
deadline, err := calculateDeadline(cliCtx, cdc, queryRoute, subMsg.CommitteeID, info.Height)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
proposal, err := types.NewProposal(subMsg.GetPubProposal(), proposalID, subMsg.CommitteeID, deadline)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return &proposal, height, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, 0, errorsmod.Wrapf(types.ErrUnknownProposal, "%d", proposalID)
|
||||
}
|
||||
|
||||
// calculateDeadline returns the proposal deadline for a committee and block height
|
||||
func calculateDeadline(cliCtx client.Context, cdc *codec.LegacyAmino, queryRoute string, committeeID uint64, blockHeight int64) (time.Time, error) {
|
||||
var deadline time.Time
|
||||
|
||||
bz, err := cdc.MarshalJSON(types.NewQueryCommitteeParams(committeeID))
|
||||
if err != nil {
|
||||
return deadline, err
|
||||
}
|
||||
|
||||
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryCommittee), bz)
|
||||
if err != nil {
|
||||
return deadline, err
|
||||
}
|
||||
|
||||
var committee types.Committee
|
||||
err = cdc.UnmarshalJSON(res, &committee)
|
||||
if err != nil {
|
||||
return deadline, err
|
||||
}
|
||||
|
||||
node, err := cliCtx.GetNode()
|
||||
if err != nil {
|
||||
return deadline, err
|
||||
}
|
||||
|
||||
resultBlock, err := node.Block(context.Background(), &blockHeight)
|
||||
if err != nil {
|
||||
return deadline, err
|
||||
}
|
||||
|
||||
deadline = resultBlock.Block.Header.Time.Add(committee.GetProposalDuration())
|
||||
return deadline, nil
|
||||
}
|
||||
|
@ -4,4 +4,4 @@ order: 5
|
||||
|
||||
# Parameters
|
||||
|
||||
The committee module has no parameters. Committees are created using the `x/gov` module and inherit the parameters controlling governance proposals from `x/gov`.
|
||||
The committee module has no parameters. Committees are created using the `x/gov` module and and inherit the parameters controlling governance proposals from `x/gov`.
|
||||
|
62
x/committee/types/querier.go
Normal file
62
x/committee/types/querier.go
Normal file
@ -0,0 +1,62 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// Query endpoints supported by the Querier
|
||||
const (
|
||||
QueryCommittees = "committees"
|
||||
QueryCommittee = "committee"
|
||||
QueryProposals = "proposals"
|
||||
QueryProposal = "proposal"
|
||||
QueryNextProposalID = "next-proposal-id"
|
||||
QueryVotes = "votes"
|
||||
QueryVote = "vote"
|
||||
QueryTally = "tally"
|
||||
QueryRawParams = "raw_params"
|
||||
)
|
||||
|
||||
type QueryCommitteeParams struct {
|
||||
CommitteeID uint64 `json:"committee_id" yaml:"committee_id"`
|
||||
}
|
||||
|
||||
func NewQueryCommitteeParams(committeeID uint64) QueryCommitteeParams {
|
||||
return QueryCommitteeParams{
|
||||
CommitteeID: committeeID,
|
||||
}
|
||||
}
|
||||
|
||||
type QueryProposalParams struct {
|
||||
ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"`
|
||||
}
|
||||
|
||||
func NewQueryProposalParams(proposalID uint64) QueryProposalParams {
|
||||
return QueryProposalParams{
|
||||
ProposalID: proposalID,
|
||||
}
|
||||
}
|
||||
|
||||
type QueryVoteParams struct {
|
||||
ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"`
|
||||
Voter sdk.AccAddress `json:"voter" yaml:"voter"`
|
||||
}
|
||||
|
||||
func NewQueryVoteParams(proposalID uint64, voter sdk.AccAddress) QueryVoteParams {
|
||||
return QueryVoteParams{
|
||||
ProposalID: proposalID,
|
||||
Voter: voter,
|
||||
}
|
||||
}
|
||||
|
||||
type QueryRawParamsParams struct {
|
||||
Subspace string
|
||||
Key string
|
||||
}
|
||||
|
||||
func NewQueryRawParamsParams(subspace, key string) QueryRawParamsParams {
|
||||
return QueryRawParamsParams{
|
||||
Subspace: subspace,
|
||||
Key: key,
|
||||
}
|
||||
}
|
@ -889,23 +889,23 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_Committees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "committee", "v1beta1", "committees"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Committees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "committee", "v1beta1", "committees"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Committee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "committee", "v1beta1", "committees", "committee_id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Committee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "committee", "v1beta1", "committees", "committee_id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Proposals_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "committee", "v1beta1", "proposals"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Proposals_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "committee", "v1beta1", "proposals"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Proposal_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "committee", "v1beta1", "proposals", "proposal_id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Proposal_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "committee", "v1beta1", "proposals", "proposal_id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_NextProposalID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "committee", "v1beta1", "next-proposal-id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_NextProposalID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "committee", "v1beta1", "next-proposal-id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Votes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"0g", "committee", "v1beta1", "proposals", "proposal_id", "votes"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Votes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"0g", "committee", "v1beta1", "proposals", "proposal_id", "votes"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Vote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"0g", "committee", "v1beta1", "proposals", "proposal_id", "votes", "voter"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Vote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"0g", "committee", "v1beta1", "proposals", "proposal_id", "votes", "voter"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Tally_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"0g", "committee", "v1beta1", "proposals", "proposal_id", "tally"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Tally_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"0g", "committee", "v1beta1", "proposals", "proposal_id", "tally"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_RawParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "committee", "v1beta1", "raw-params"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_RawParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "committee", "v1beta1", "raw-params"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -3,8 +3,8 @@ package keeper
|
||||
import (
|
||||
"sort"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
)
|
||||
|
||||
type Ballot struct {
|
||||
|
@ -4,12 +4,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"github.com/cometbft/cometbft/libs/log"
|
||||
"github.com/coniks-sys/coniks-go/crypto/vrf"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/council/v1/types"
|
||||
)
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@ -16,6 +15,7 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/council/v1/client/cli"
|
||||
"github.com/0glabs/0g-chain/x/council/v1/keeper"
|
||||
@ -117,9 +117,17 @@ func (AppModule) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
// Route returns evmutil module's message route.
|
||||
func (am AppModule) Route() sdk.Route { return sdk.Route{} }
|
||||
|
||||
// QuerierRoute returns evmutil module's query routing key.
|
||||
func (AppModule) QuerierRoute() string { return "" }
|
||||
|
||||
// LegacyQuerierHandler returns evmutil module's Querier.
|
||||
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterInvariants registers the inflation module invariants.
|
||||
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
|
||||
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "google.golang.org/protobuf/types/known/timestamppb"
|
||||
io "io"
|
||||
math "math"
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
grpc1 "github.com/cosmos/gogoproto/grpc"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
|
@ -206,9 +206,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_CurrentCouncilID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0gchain", "council", "v1", "current-council-id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_CurrentCouncilID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0gchain", "council", "v1", "current-council-id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_RegisteredVoters_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0gchain", "council", "v1", "registered-voters"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_RegisteredVoters_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0gchain", "council", "v1", "registered-voters"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
grpc1 "github.com/cosmos/gogoproto/grpc"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"sort"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
)
|
||||
|
||||
type Ballot struct {
|
||||
|
@ -5,12 +5,12 @@ import (
|
||||
"math/big"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
"github.com/cometbft/cometbft/libs/log"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@ -16,6 +15,7 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/client/cli"
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/keeper"
|
||||
@ -116,9 +116,17 @@ func (AppModule) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
// Route returns dasigners module's message route.
|
||||
func (am AppModule) Route() sdk.Route { return sdk.Route{} }
|
||||
|
||||
// QuerierRoute returns dasigners module's query routing key.
|
||||
func (AppModule) QuerierRoute() string { return types.QuerierRoute }
|
||||
|
||||
// LegacyQuerierHandler returns dasigners module's Querier.
|
||||
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterInvariants registers the inflation module invariants.
|
||||
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
|
||||
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "google.golang.org/protobuf/types/known/durationpb"
|
||||
io "io"
|
||||
math "math"
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "google.golang.org/protobuf/types/known/timestamppb"
|
||||
io "io"
|
||||
math "math"
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
grpc1 "github.com/cosmos/gogoproto/grpc"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
|
@ -540,17 +540,17 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_EpochNumber_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "epoch-number"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_EpochNumber_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "epoch-number"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_QuorumCount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "quorum-count"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_QuorumCount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "quorum-count"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_EpochQuorum_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "epoch-quorum"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_EpochQuorum_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "epoch-quorum"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_EpochQuorumRow_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "epoch-quorum-row"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_EpochQuorumRow_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "epoch-quorum-row"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_AggregatePubkeyG1_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "aggregate-pubkey-g1"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_AggregatePubkeyG1_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "aggregate-pubkey-g1"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Signer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "signer"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Signer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "signer"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
grpc1 "github.com/cosmos/gogoproto/grpc"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
@ -164,16 +164,6 @@ func (k EvmBankKeeper) BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coi
|
||||
return k.evmDenomKeeper.RemoveBalance(ctx, moduleAddr, baseDemonCnt)
|
||||
}
|
||||
|
||||
// IsSendEnabledCoins checks the coins provided and returns an ErrSendDisabled
|
||||
// if any of the coins are not configured for sending. Returns nil if sending is
|
||||
// enabled for all provided coins.
|
||||
func (k EvmBankKeeper) IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error {
|
||||
// IsSendEnabledCoins method is not used by the evm module, but is required by the
|
||||
// evmtypes.BankKeeper interface. This must be updated if the evm module
|
||||
// is updated to use IsSendEnabledCoins.
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
// ConvertOnegasDenomToEvmDenomIfNeeded converts 1 gas denom to evm denom for an address if
|
||||
// its evm denom balance is smaller than the evmDenomCnt amount.
|
||||
func (k EvmBankKeeper) ConvertOneGasDenomToEvmDenomIfNeeded(ctx sdk.Context, addr sdk.AccAddress, evmDenomCnt sdkmath.Int) error {
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
)
|
||||
|
||||
type evmBankKeeperTestSuite struct {
|
||||
|
@ -71,15 +71,7 @@ func (k Keeper) ConvertCoinToERC20(
|
||||
return err
|
||||
}
|
||||
|
||||
// handle bep3 conversion pair (8 decimals sdk.Coin -> 18 decimals erc20)
|
||||
// when converting bep3 bank coins to erc20, we will need to unlock the 18
|
||||
// decimals erc20 equivalent of the 8 decimals bep3 sdk.Coins
|
||||
amountToUnlock := coin.Amount.BigInt()
|
||||
if isBep3Asset(pair.Denom) {
|
||||
amountToUnlock = convertBep3CoinAmountToERC20Amount(coin.Amount.BigInt())
|
||||
}
|
||||
|
||||
if err := k.UnlockERC20Tokens(ctx, pair, amountToUnlock, receiverAccount); err != nil {
|
||||
if err := k.UnlockERC20Tokens(ctx, pair, coin.Amount.BigInt(), receiverAccount); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -110,23 +102,13 @@ func (k Keeper) ConvertERC20ToCoin(
|
||||
return err
|
||||
}
|
||||
|
||||
amountToLock := amount.BigInt()
|
||||
amountToMint := amount.BigInt()
|
||||
|
||||
if isBep3Asset(pair.Denom) {
|
||||
amountToMint, amountToLock, err = bep3ERC20AmountToCoinMintAndERC20LockAmount(amount.BigInt())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// lock erc20 tokens
|
||||
if err := k.LockERC20Tokens(ctx, pair, amountToLock, initiator); err != nil {
|
||||
if err := k.LockERC20Tokens(ctx, pair, amount.BigInt(), initiator); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// mint conversion pair coin
|
||||
coin, err := k.MintConversionPairCoin(ctx, pair, amountToMint, receiver)
|
||||
coin, err := k.MintConversionPairCoin(ctx, pair, amount.BigInt(), receiver)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1,55 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
)
|
||||
|
||||
var (
|
||||
bep3Denoms = map[string]bool{
|
||||
"bnb": true,
|
||||
"busd": true,
|
||||
"btcb": true,
|
||||
"xrpb": true,
|
||||
}
|
||||
|
||||
bep3ConversionFactor = new(big.Int).Exp(big.NewInt(10), big.NewInt(10), nil)
|
||||
)
|
||||
|
||||
func isBep3Asset(denom string) bool {
|
||||
return bep3Denoms[denom]
|
||||
}
|
||||
|
||||
// convertBep3CoinAmountToERC20Amount converts a bep3 coin amount with 8 decimals
|
||||
// to the equivalent ERC20 token with 18 decimals.
|
||||
func convertBep3CoinAmountToERC20Amount(amount *big.Int) (erc20Amount *big.Int) {
|
||||
return new(big.Int).Mul(amount, bep3ConversionFactor)
|
||||
}
|
||||
|
||||
// convertBep3ERC20AmountToCoinAmount converts a bep3 ERC20 token with 18 decimals
|
||||
// to the equivalent coin amount with 8 decimals, and dropping the remainder.
|
||||
func convertBep3ERC20AmountToCoinAmount(amount *big.Int) (coinAmount *big.Int) {
|
||||
return new(big.Int).Div(amount, bep3ConversionFactor)
|
||||
}
|
||||
|
||||
// bep3ERC20AmountToCoinMintAndERC20LockAmount converts 18 decimals erc20 bep3
|
||||
// amount to the equivalent 8 decimals coin amount to mint, and the
|
||||
// 18 decimals erc20 bep3 amount to lock for the converted coin amount.
|
||||
func bep3ERC20AmountToCoinMintAndERC20LockAmount(amount *big.Int) (
|
||||
amountToMint *big.Int, amountToLock *big.Int, err error,
|
||||
) {
|
||||
amountToMint = convertBep3ERC20AmountToCoinAmount(amount)
|
||||
|
||||
// make sure we have at least 1 sdk.Coin to mint
|
||||
if amountToMint.Cmp(big.NewInt(0)) == 0 {
|
||||
err := errorsmod.Wrapf(
|
||||
types.ErrInsufficientConversionAmount,
|
||||
"unable to convert bep3 coin due converting less than 1 native unit",
|
||||
)
|
||||
return nil, nil, err
|
||||
}
|
||||
amountToLock = convertBep3CoinAmountToERC20Amount(amountToMint)
|
||||
return amountToMint, amountToLock, nil
|
||||
}
|
@ -1,415 +0,0 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/evmutil/testutil"
|
||||
"github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
)
|
||||
|
||||
type Bep3ConversionTestSuite struct {
|
||||
testutil.Suite
|
||||
}
|
||||
|
||||
var (
|
||||
bep3Denoms = []string{"bnb", "busd", "btcb", "xrpb"}
|
||||
)
|
||||
|
||||
func TestBep3ConversionTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(Bep3ConversionTestSuite))
|
||||
}
|
||||
|
||||
func (suite *Bep3ConversionTestSuite) TestConvertCoinToERC20_Bep3() {
|
||||
for _, denom := range bep3Denoms {
|
||||
suite.testConvertBep3CoinToERC20(denom)
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *Bep3ConversionTestSuite) TestConvertERC20ToCoin_Bep3() {
|
||||
for _, denom := range bep3Denoms {
|
||||
suite.testConvertBep3ERC20ToCoin(denom)
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *Bep3ConversionTestSuite) setEnabledConversionPairDenom(denom string) {
|
||||
params := suite.Keeper.GetParams(suite.Ctx)
|
||||
params.EnabledConversionPairs[0].Denom = denom
|
||||
suite.Keeper.SetParams(suite.Ctx, params)
|
||||
}
|
||||
|
||||
func (suite *Bep3ConversionTestSuite) testConvertBep3CoinToERC20(denom string) {
|
||||
invoker, err := sdk.AccAddressFromBech32("kava123fxg0l602etulhhcdm0vt7l57qya5wjcrwhzz")
|
||||
receiverAddr := testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
|
||||
suite.Require().NoError(err)
|
||||
|
||||
type errArgs struct {
|
||||
expectPass bool
|
||||
contains string
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
userBankBalance sdkmath.Int
|
||||
expUserErc20Balance sdkmath.Int
|
||||
moduleErc20Balance sdkmath.Int
|
||||
expModuleErc20Balance sdkmath.Int
|
||||
disablePair bool
|
||||
conversionDenom string
|
||||
coinToConvert sdk.Coin
|
||||
errArgs errArgs
|
||||
}{
|
||||
{
|
||||
name: "success",
|
||||
userBankBalance: sdkmath.NewInt(1_234),
|
||||
moduleErc20Balance: sdkmath.NewInt(10e13),
|
||||
expUserErc20Balance: sdkmath.NewInt(1.234e13),
|
||||
expModuleErc20Balance: sdkmath.NewInt(8.766e13),
|
||||
coinToConvert: sdk.NewCoin(denom, sdkmath.NewInt(1_234)),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "success - convert smallest unit",
|
||||
userBankBalance: sdkmath.NewInt(2),
|
||||
moduleErc20Balance: sdkmath.NewInt(10e13),
|
||||
expUserErc20Balance: sdkmath.NewInt(1e10),
|
||||
expModuleErc20Balance: sdkmath.NewInt(9.999e13),
|
||||
coinToConvert: sdk.NewCoin(denom, sdkmath.NewInt(1)),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "success - no change when 0 amount converted",
|
||||
userBankBalance: sdkmath.NewInt(1234),
|
||||
moduleErc20Balance: sdkmath.NewInt(1e14),
|
||||
expUserErc20Balance: sdkmath.ZeroInt(),
|
||||
expModuleErc20Balance: sdkmath.NewInt(1e14),
|
||||
coinToConvert: sdk.NewCoin(denom, sdkmath.NewInt(0)),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "error - bep3 not enabled",
|
||||
userBankBalance: sdkmath.NewInt(1_234),
|
||||
moduleErc20Balance: sdkmath.NewInt(1e14),
|
||||
disablePair: true,
|
||||
coinToConvert: sdk.NewCoin(denom, sdkmath.NewInt(1_234)),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: fmt.Sprintf("%s: ERC20 token not enabled to convert to sdk.Coin", denom),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "error - module account does not have enough balance to unlock",
|
||||
userBankBalance: sdkmath.NewInt(1_234),
|
||||
moduleErc20Balance: sdkmath.NewInt(1e9),
|
||||
coinToConvert: sdk.NewCoin(denom, sdkmath.NewInt(1)),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: "execution reverted: ERC20: transfer amount exceeds balance",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "success - not bep3 conversion",
|
||||
conversionDenom: "hard",
|
||||
userBankBalance: sdkmath.NewInt(1_234),
|
||||
moduleErc20Balance: sdkmath.NewInt(2_000),
|
||||
expUserErc20Balance: sdkmath.NewInt(1_234),
|
||||
expModuleErc20Balance: sdkmath.NewInt(766),
|
||||
coinToConvert: sdk.NewCoin("hard", sdkmath.NewInt(1_234)),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "error - user converting more than user balance",
|
||||
userBankBalance: sdkmath.NewInt(1_234),
|
||||
moduleErc20Balance: sdkmath.NewInt(1e14),
|
||||
coinToConvert: sdk.NewCoin(denom, sdkmath.NewInt(20_000)),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: fmt.Sprintf("spendable balance 1234%s is smaller than 20000%s: insufficient funds", denom, denom),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
suite.Run(fmt.Sprintf("%s: %s", denom, tc.name), func() {
|
||||
suite.SetupTest()
|
||||
contractAddr := suite.DeployERC20()
|
||||
|
||||
// override conversion denom if needed
|
||||
conversionDenom := tc.conversionDenom
|
||||
if conversionDenom == "" {
|
||||
conversionDenom = denom
|
||||
}
|
||||
|
||||
if !tc.disablePair {
|
||||
suite.setEnabledConversionPairDenom(conversionDenom)
|
||||
}
|
||||
|
||||
pair := types.NewConversionPair(
|
||||
contractAddr,
|
||||
conversionDenom,
|
||||
)
|
||||
|
||||
// fund user & module account
|
||||
if tc.userBankBalance.GT(sdkmath.ZeroInt()) {
|
||||
err = suite.App.FundAccount(
|
||||
suite.Ctx,
|
||||
invoker,
|
||||
sdk.NewCoins(sdk.NewCoin(conversionDenom, tc.userBankBalance)),
|
||||
)
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
if tc.moduleErc20Balance.GT(sdkmath.ZeroInt()) {
|
||||
err := suite.Keeper.MintERC20(
|
||||
suite.Ctx,
|
||||
pair.GetAddress(), // contractAddr
|
||||
types.NewInternalEVMAddress(types.ModuleEVMAddress), //receiver
|
||||
tc.moduleErc20Balance.BigInt(),
|
||||
)
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
// execute bep3 conversion
|
||||
err := suite.Keeper.ConvertCoinToERC20(suite.Ctx, invoker, receiverAddr, tc.coinToConvert)
|
||||
|
||||
if tc.errArgs.expectPass {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// validate user balance
|
||||
bal := suite.GetERC20BalanceOf(
|
||||
types.ERC20MintableBurnableContract.ABI,
|
||||
pair.GetAddress(),
|
||||
receiverAddr,
|
||||
)
|
||||
suite.Require().Equal(
|
||||
tc.expUserErc20Balance.BigInt().Int64(),
|
||||
bal.Int64(),
|
||||
"user erc20 balance should match expected amount",
|
||||
)
|
||||
|
||||
// validate module balance
|
||||
bal = suite.GetERC20BalanceOf(
|
||||
types.ERC20MintableBurnableContract.ABI,
|
||||
pair.GetAddress(),
|
||||
types.NewInternalEVMAddress(types.ModuleEVMAddress),
|
||||
)
|
||||
suite.Require().Equal(
|
||||
tc.expModuleErc20Balance.BigInt().Int64(),
|
||||
bal.Int64(),
|
||||
"module erc20 balance should match expected amount",
|
||||
)
|
||||
|
||||
// keeper event
|
||||
suite.EventsContains(suite.GetEvents(),
|
||||
sdk.NewEvent(
|
||||
types.EventTypeConvertCoinToERC20,
|
||||
sdk.NewAttribute(types.AttributeKeyInitiator, invoker.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyReceiver, receiverAddr.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyERC20Address, pair.GetAddress().String()),
|
||||
sdk.NewAttribute(types.AttributeKeyAmount, tc.coinToConvert.String()),
|
||||
))
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
suite.Require().Contains(err.Error(), tc.errArgs.contains)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *Bep3ConversionTestSuite) testConvertBep3ERC20ToCoin(denom string) {
|
||||
invoker := testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
|
||||
invokerCosmosAddr, err := sdk.AccAddressFromHexUnsafe(invoker.String()[2:])
|
||||
suite.Require().NoError(err)
|
||||
|
||||
type errArgs struct {
|
||||
expectPass bool
|
||||
contains string
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
contractAddr string
|
||||
conversionDenom string
|
||||
disablePair bool
|
||||
userErc20Balance sdkmath.Int
|
||||
expUserBankBalance sdkmath.Int
|
||||
expUserErc20Balance sdkmath.Int
|
||||
convertAmount sdkmath.Int
|
||||
errArgs errArgs
|
||||
}{
|
||||
{
|
||||
name: "success - conversion with no dust",
|
||||
userErc20Balance: sdkmath.NewInt(1.12e18),
|
||||
expUserBankBalance: sdkmath.NewInt(1.0031e8),
|
||||
expUserErc20Balance: sdkmath.NewInt(0.1169e18),
|
||||
convertAmount: sdkmath.NewInt(1.0031e18),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "success - convert smallest bank unit",
|
||||
userErc20Balance: sdkmath.NewInt(2e18),
|
||||
expUserBankBalance: sdkmath.NewInt(1),
|
||||
expUserErc20Balance: sdkmath.NewInt(1.99999999e18),
|
||||
convertAmount: sdkmath.NewInt(1.12e10),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "success - bnb conversion with dust",
|
||||
userErc20Balance: sdkmath.NewInt(2e18),
|
||||
expUserBankBalance: sdkmath.NewInt(12),
|
||||
expUserErc20Balance: sdkmath.NewInt(1.99999988e18),
|
||||
convertAmount: sdkmath.NewInt(12.123e10),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "fail - converting less than 1 bank unit",
|
||||
userErc20Balance: sdkmath.NewInt(2e18),
|
||||
convertAmount: sdkmath.NewInt(12e8),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: "unable to convert bep3 coin due converting less than 1 native unit",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "fail - contract not enabled",
|
||||
disablePair: true,
|
||||
contractAddr: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
||||
userErc20Balance: sdkmath.NewInt(2e18),
|
||||
convertAmount: sdkmath.NewInt(2e18),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: "ERC20 token not enabled to convert",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "fail - converting 0 amount of bep3 erc20 token",
|
||||
userErc20Balance: sdkmath.NewInt(2e18),
|
||||
convertAmount: sdkmath.NewInt(0),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: "unable to convert bep3 coin due converting less than 1 native unit",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "success - not bep3 conversion",
|
||||
conversionDenom: "xrp",
|
||||
userErc20Balance: sdkmath.NewInt(2.5e18),
|
||||
expUserBankBalance: sdkmath.NewInt(2.1e18),
|
||||
expUserErc20Balance: sdkmath.NewInt(0.4e18),
|
||||
convertAmount: sdkmath.NewInt(2.1e18),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "fail - user converting more than user balance",
|
||||
userErc20Balance: sdkmath.NewInt(2e18),
|
||||
convertAmount: sdkmath.NewInt(2.3e18),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: "transfer amount exceeds balance",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "success - user converting more than balance but only by dust amount",
|
||||
userErc20Balance: sdkmath.NewInt(2e18),
|
||||
expUserBankBalance: sdkmath.NewInt(2e8),
|
||||
expUserErc20Balance: sdkmath.NewInt(0),
|
||||
convertAmount: sdkmath.NewInt(2.0000000091e18),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
suite.Run(fmt.Sprintf("%s: %s", denom, tc.name), func() {
|
||||
suite.SetupTest()
|
||||
contractAddr := suite.DeployERC20()
|
||||
|
||||
// override conversion denom if needed
|
||||
conversionDenom := tc.conversionDenom
|
||||
if conversionDenom == "" {
|
||||
conversionDenom = denom
|
||||
}
|
||||
|
||||
if !tc.disablePair {
|
||||
suite.setEnabledConversionPairDenom(conversionDenom)
|
||||
}
|
||||
|
||||
if tc.contractAddr != "" {
|
||||
contractAddr = testutil.MustNewInternalEVMAddressFromString(tc.contractAddr)
|
||||
}
|
||||
|
||||
pair := types.NewConversionPair(
|
||||
contractAddr,
|
||||
conversionDenom,
|
||||
)
|
||||
|
||||
// fund user erc20 balance
|
||||
if tc.userErc20Balance.GT(sdkmath.ZeroInt()) {
|
||||
err := suite.Keeper.MintERC20(
|
||||
suite.Ctx,
|
||||
pair.GetAddress(),
|
||||
invoker,
|
||||
tc.userErc20Balance.BigInt(),
|
||||
)
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
// create user account, otherwise `CallEVMWithData` will fail due to failing to get user account when finding its sequence.
|
||||
err = suite.App.FundAccount(suite.Ctx, invokerCosmosAddr, sdk.NewCoins(sdk.NewCoin(conversionDenom, sdk.ZeroInt())))
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// execute bep3 conversion
|
||||
err := suite.Keeper.ConvertERC20ToCoin(suite.Ctx, invoker, invokerCosmosAddr, pair.GetAddress(), tc.convertAmount)
|
||||
|
||||
if tc.errArgs.expectPass {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// validate user balance after conversion
|
||||
bal := suite.GetERC20BalanceOf(
|
||||
types.ERC20MintableBurnableContract.ABI,
|
||||
pair.GetAddress(),
|
||||
testutil.MustNewInternalEVMAddressFromString(invoker.String()),
|
||||
)
|
||||
suite.Require().Equal(tc.expUserErc20Balance.BigInt().Int64(), bal.Int64(), "user erc20 balance is invalid")
|
||||
|
||||
// validate user coin balance
|
||||
coinBal := suite.App.GetBankKeeper().GetBalance(suite.Ctx, invokerCosmosAddr, pair.Denom)
|
||||
suite.Require().Equal(tc.expUserBankBalance, coinBal.Amount, "user coin balance is invalid")
|
||||
|
||||
// keeper event
|
||||
suite.EventsContains(suite.GetEvents(),
|
||||
sdk.NewEvent(
|
||||
types.EventTypeConvertERC20ToCoin,
|
||||
sdk.NewAttribute(types.AttributeKeyERC20Address, pair.GetAddress().String()),
|
||||
sdk.NewAttribute(types.AttributeKeyInitiator, invoker.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyReceiver, invokerCosmosAddr.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyAmount, sdk.NewCoin(pair.Denom, tc.expUserBankBalance).String()),
|
||||
))
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
suite.Require().Contains(err.Error(), tc.errArgs.contains)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -1,312 +0,0 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
sdkmath "cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/evmutil/testutil"
|
||||
"github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
)
|
||||
|
||||
func (suite *MsgServerSuite) TestConvertCoinToERC20_Bep3() {
|
||||
invoker, err := sdk.AccAddressFromBech32("kava123fxg0l602etulhhcdm0vt7l57qya5wjcrwhzz")
|
||||
receiverAddr := testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
|
||||
suite.Require().NoError(err)
|
||||
|
||||
type errArgs struct {
|
||||
expectPass bool
|
||||
contains string
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
msg types.MsgConvertCoinToERC20
|
||||
userBankBalance sdkmath.Int
|
||||
expUserErc20Balance sdkmath.Int
|
||||
moduleErc20Balance sdkmath.Int
|
||||
expModuleErc20Balance sdkmath.Int
|
||||
errArgs errArgs
|
||||
}{
|
||||
{
|
||||
name: "valid",
|
||||
msg: types.NewMsgConvertCoinToERC20(
|
||||
invoker.String(),
|
||||
receiverAddr.String(),
|
||||
sdk.NewCoin("bnb", sdkmath.NewInt(1234)),
|
||||
),
|
||||
userBankBalance: sdkmath.NewInt(1_234),
|
||||
moduleErc20Balance: sdkmath.NewInt(10e13),
|
||||
expUserErc20Balance: sdkmath.NewInt(1.234e13),
|
||||
expModuleErc20Balance: sdkmath.NewInt(8.766e13),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid - invalid receiver address",
|
||||
msg: types.NewMsgConvertCoinToERC20(
|
||||
invoker.String(),
|
||||
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc",
|
||||
sdk.NewCoin("bnb", sdkmath.NewInt(1234)),
|
||||
),
|
||||
userBankBalance: sdkmath.NewInt(1_234),
|
||||
moduleErc20Balance: sdkmath.NewInt(1e14),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: "invalid Receiver address: string is not a hex address",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid - initiator receiver address",
|
||||
msg: types.NewMsgConvertCoinToERC20(
|
||||
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc",
|
||||
receiverAddr.String(),
|
||||
sdk.NewCoin("bnb", sdkmath.NewInt(1234)),
|
||||
),
|
||||
userBankBalance: sdkmath.NewInt(1_234),
|
||||
moduleErc20Balance: sdkmath.NewInt(1e14),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: "invalid Initiator address",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
suite.Run(tc.name, func() {
|
||||
suite.SetupTest()
|
||||
contractAddr := suite.DeployERC20()
|
||||
|
||||
// enable conversion pair
|
||||
params := suite.Keeper.GetParams(suite.Ctx)
|
||||
params.EnabledConversionPairs[0].Denom = tc.msg.Amount.Denom
|
||||
suite.Keeper.SetParams(suite.Ctx, params)
|
||||
|
||||
pair := types.NewConversionPair(
|
||||
contractAddr,
|
||||
tc.msg.Amount.Denom,
|
||||
)
|
||||
|
||||
// fund user & module account
|
||||
if tc.userBankBalance.GT(sdkmath.ZeroInt()) {
|
||||
err = suite.App.FundAccount(
|
||||
suite.Ctx,
|
||||
invoker,
|
||||
sdk.NewCoins(sdk.NewCoin(pair.Denom, tc.userBankBalance)),
|
||||
)
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
if tc.moduleErc20Balance.GT(sdkmath.ZeroInt()) {
|
||||
err := suite.Keeper.MintERC20(
|
||||
suite.Ctx,
|
||||
pair.GetAddress(), // contractAddr
|
||||
types.NewInternalEVMAddress(types.ModuleEVMAddress), //receiver
|
||||
tc.moduleErc20Balance.BigInt(),
|
||||
)
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
_, err = suite.msgServer.ConvertCoinToERC20(sdk.WrapSDKContext(suite.Ctx), &tc.msg)
|
||||
|
||||
if tc.errArgs.expectPass {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// validate user balance
|
||||
bal := suite.GetERC20BalanceOf(
|
||||
types.ERC20MintableBurnableContract.ABI,
|
||||
pair.GetAddress(),
|
||||
receiverAddr,
|
||||
)
|
||||
suite.Require().Equal(
|
||||
tc.expUserErc20Balance.BigInt().Int64(),
|
||||
bal.Int64(),
|
||||
"user erc20 balance should match expected amount",
|
||||
)
|
||||
|
||||
// validate module balance
|
||||
bal = suite.GetERC20BalanceOf(
|
||||
types.ERC20MintableBurnableContract.ABI,
|
||||
pair.GetAddress(),
|
||||
types.NewInternalEVMAddress(types.ModuleEVMAddress),
|
||||
)
|
||||
suite.Require().Equal(
|
||||
tc.expModuleErc20Balance.BigInt().Int64(),
|
||||
bal.Int64(),
|
||||
"module erc20 balance should match expected amount",
|
||||
)
|
||||
|
||||
// msg server event
|
||||
suite.EventsContains(suite.GetEvents(),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, tc.msg.Initiator),
|
||||
))
|
||||
|
||||
// keeper event
|
||||
suite.EventsContains(suite.GetEvents(),
|
||||
sdk.NewEvent(
|
||||
types.EventTypeConvertCoinToERC20,
|
||||
sdk.NewAttribute(types.AttributeKeyInitiator, tc.msg.Initiator),
|
||||
sdk.NewAttribute(types.AttributeKeyReceiver, tc.msg.Receiver),
|
||||
sdk.NewAttribute(types.AttributeKeyERC20Address, pair.GetAddress().String()),
|
||||
sdk.NewAttribute(types.AttributeKeyAmount, tc.msg.Amount.String()),
|
||||
))
|
||||
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
suite.Require().Contains(err.Error(), tc.errArgs.contains)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *MsgServerSuite) TestConvertERC20ToCoin_Bep3() {
|
||||
invoker := testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
|
||||
invokerCosmosAddr, err := sdk.AccAddressFromHexUnsafe(invoker.String()[2:])
|
||||
suite.Require().NoError(err)
|
||||
contractAddr := suite.DeployERC20()
|
||||
|
||||
type errArgs struct {
|
||||
expectPass bool
|
||||
contains string
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
msg types.MsgConvertERC20ToCoin
|
||||
userErc20Balance sdkmath.Int
|
||||
expUserBankBalance sdkmath.Int
|
||||
expUserErc20Balance sdkmath.Int
|
||||
errArgs errArgs
|
||||
}{
|
||||
{
|
||||
name: "valid",
|
||||
msg: types.NewMsgConvertERC20ToCoin(
|
||||
invoker,
|
||||
invokerCosmosAddr,
|
||||
contractAddr,
|
||||
sdkmath.NewInt(1.0031e18),
|
||||
),
|
||||
userErc20Balance: sdkmath.NewInt(1.12e18),
|
||||
expUserBankBalance: sdkmath.NewInt(1.0031e8),
|
||||
expUserErc20Balance: sdkmath.NewInt(0.1169e18),
|
||||
errArgs: errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid - invalid initiator address",
|
||||
msg: types.MsgConvertERC20ToCoin{
|
||||
Initiator: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc",
|
||||
Receiver: invokerCosmosAddr.String(),
|
||||
KavaERC20Address: contractAddr.String(),
|
||||
Amount: sdkmath.NewInt(12e8),
|
||||
},
|
||||
userErc20Balance: sdkmath.NewInt(2e18),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: "invalid initiator address: string is not a hex address",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid - invalid receiver address",
|
||||
msg: types.MsgConvertERC20ToCoin{
|
||||
Initiator: invoker.String(),
|
||||
Receiver: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc",
|
||||
KavaERC20Address: contractAddr.String(),
|
||||
Amount: sdkmath.NewInt(12e8),
|
||||
},
|
||||
userErc20Balance: sdkmath.NewInt(2e18),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: "invalid receiver address",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid - invalid contract address",
|
||||
msg: types.MsgConvertERC20ToCoin{
|
||||
Initiator: invoker.String(),
|
||||
Receiver: invokerCosmosAddr.String(),
|
||||
KavaERC20Address: invokerCosmosAddr.String(),
|
||||
Amount: sdkmath.NewInt(12e8),
|
||||
},
|
||||
userErc20Balance: sdkmath.NewInt(2e18),
|
||||
errArgs: errArgs{
|
||||
expectPass: false,
|
||||
contains: "invalid contract address",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
suite.Run(tc.name, func() {
|
||||
suite.SetupTest()
|
||||
contractAddr := suite.DeployERC20()
|
||||
|
||||
conversionDenom := "bnb"
|
||||
params := suite.Keeper.GetParams(suite.Ctx)
|
||||
params.EnabledConversionPairs[0].Denom = conversionDenom
|
||||
suite.Keeper.SetParams(suite.Ctx, params)
|
||||
|
||||
pair := types.NewConversionPair(
|
||||
contractAddr,
|
||||
conversionDenom,
|
||||
)
|
||||
|
||||
// fund user erc20 balance
|
||||
if tc.userErc20Balance.GT(sdkmath.ZeroInt()) {
|
||||
err := suite.Keeper.MintERC20(
|
||||
suite.Ctx,
|
||||
pair.GetAddress(),
|
||||
invoker,
|
||||
tc.userErc20Balance.BigInt(),
|
||||
)
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
// create user account, otherwise `CallEVMWithData` will fail due to failing to get user account when finding its sequence.
|
||||
err = suite.App.FundAccount(suite.Ctx, invokerCosmosAddr, sdk.NewCoins(sdk.NewCoin(conversionDenom, sdk.ZeroInt())))
|
||||
suite.Require().NoError(err)
|
||||
|
||||
_, err := suite.msgServer.ConvertERC20ToCoin(sdk.WrapSDKContext(suite.Ctx), &tc.msg)
|
||||
|
||||
if tc.errArgs.expectPass {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// validate user balance after conversion
|
||||
bal := suite.GetERC20BalanceOf(
|
||||
types.ERC20MintableBurnableContract.ABI,
|
||||
pair.GetAddress(),
|
||||
testutil.MustNewInternalEVMAddressFromString(invoker.String()),
|
||||
)
|
||||
suite.Require().Equal(tc.expUserErc20Balance.BigInt().Int64(), bal.Int64(), "user erc20 balance is invalid")
|
||||
|
||||
// validate user coin balance
|
||||
coinBal := suite.App.GetBankKeeper().GetBalance(suite.Ctx, invokerCosmosAddr, pair.Denom)
|
||||
suite.Require().Equal(tc.expUserBankBalance, coinBal.Amount, "user coin balance is invalid")
|
||||
|
||||
// msg server event
|
||||
suite.EventsContains(suite.GetEvents(),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, tc.msg.Initiator),
|
||||
))
|
||||
|
||||
// keeper event
|
||||
suite.EventsContains(suite.GetEvents(),
|
||||
sdk.NewEvent(
|
||||
types.EventTypeConvertERC20ToCoin,
|
||||
sdk.NewAttribute(types.AttributeKeyERC20Address, pair.GetAddress().String()),
|
||||
sdk.NewAttribute(types.AttributeKeyInitiator, tc.msg.Initiator),
|
||||
sdk.NewAttribute(types.AttributeKeyReceiver, tc.msg.Receiver),
|
||||
sdk.NewAttribute(types.AttributeKeyAmount, sdk.NewCoin(pair.Denom, tc.expUserBankBalance).String()),
|
||||
))
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
suite.Require().Contains(err.Error(), tc.errArgs.contains)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -4,12 +4,11 @@ import errorsmod "cosmossdk.io/errors"
|
||||
|
||||
// errors
|
||||
var (
|
||||
ErrABIPack = errorsmod.Register(ModuleName, 2, "contract ABI pack failed")
|
||||
ErrEVMCall = errorsmod.Register(ModuleName, 3, "EVM call unexpected error")
|
||||
ErrEVMConversionNotEnabled = errorsmod.Register(ModuleName, 4, "ERC20 token not enabled to convert to sdk.Coin")
|
||||
ErrBalanceInvariance = errorsmod.Register(ModuleName, 5, "post EVM transfer balance invariant failed")
|
||||
ErrUnexpectedContractEvent = errorsmod.Register(ModuleName, 6, "unexpected contract event")
|
||||
ErrInvalidCosmosDenom = errorsmod.Register(ModuleName, 7, "invalid cosmos denom")
|
||||
ErrSDKConversionNotEnabled = errorsmod.Register(ModuleName, 8, "sdk.Coin not enabled to convert to ERC20 token")
|
||||
ErrInsufficientConversionAmount = errorsmod.Register(ModuleName, 9, "insufficient conversion amount")
|
||||
ErrABIPack = errorsmod.Register(ModuleName, 2, "contract ABI pack failed")
|
||||
ErrEVMCall = errorsmod.Register(ModuleName, 3, "EVM call unexpected error")
|
||||
ErrEVMConversionNotEnabled = errorsmod.Register(ModuleName, 4, "ERC20 token not enabled to convert to sdk.Coin")
|
||||
ErrBalanceInvariance = errorsmod.Register(ModuleName, 5, "post EVM transfer balance invariant failed")
|
||||
ErrUnexpectedContractEvent = errorsmod.Register(ModuleName, 6, "unexpected contract event")
|
||||
ErrInvalidCosmosDenom = errorsmod.Register(ModuleName, 7, "invalid cosmos denom")
|
||||
ErrSDKConversionNotEnabled = errorsmod.Register(ModuleName, 8, "sdk.Coin not enabled to convert to ERC20 token")
|
||||
)
|
||||
|
@ -37,15 +37,6 @@ func TestMsgConvertCoinToERC20(t *testing.T) {
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
"valid-bnb",
|
||||
"kava123fxg0l602etulhhcdm0vt7l57qya5wjcrwhzz",
|
||||
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
||||
sdk.NewCoin("bnb", sdkmath.NewInt(1234)),
|
||||
errArgs{
|
||||
expectPass: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
"invalid - odd length hex address",
|
||||
"0g1ffv7nhd3z6sych2qpqkk03ec6hzkmufyhp5hf8",
|
||||
|
@ -224,9 +224,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "evmutil", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "evmutil", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_DeployedCosmosCoinContracts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "evmutil", "v1beta1", "deployed_cosmos_coin_contracts"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_DeployedCosmosCoinContracts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "evmutil", "v1beta1", "deployed_cosmos_coin_contracts"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1,7 +0,0 @@
|
||||
package types
|
||||
|
||||
// MoneyMarketInterestRates is a slice of MoneyMarketInterestRate
|
||||
type MoneyMarketInterestRates []MoneyMarketInterestRate
|
||||
|
||||
// InterestFactors is a slice of InterestFactor
|
||||
type InterestFactors []InterestFactor
|
@ -31,7 +31,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// GenesisState defines the issuance module's genesis state.
|
||||
type GenesisState struct {
|
||||
// params defines all the parameters of the module.
|
||||
// params defines all the paramaters of the module.
|
||||
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
||||
Supplies []AssetSupply `protobuf:"bytes,2,rep,name=supplies,proto3" json:"supplies"`
|
||||
}
|
||||
|
12
x/issuance/types/querier.go
Normal file
12
x/issuance/types/querier.go
Normal file
@ -0,0 +1,12 @@
|
||||
package types
|
||||
|
||||
// Querier routes for the issuance module
|
||||
const (
|
||||
QueryGetParams = "parameters"
|
||||
QueryGetAsset = "asset"
|
||||
)
|
||||
|
||||
// QueryAssetParams params for querying an asset by denom
|
||||
type QueryAssetParams struct {
|
||||
Denom string `json:"denom" yaml:"denom"`
|
||||
}
|
@ -145,7 +145,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "issuance", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "issuance", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -6,7 +6,7 @@ order: 2
|
||||
|
||||
## Parameters and genesis state
|
||||
|
||||
`parameters` determine which markets are tracked by the pricefeed and which oracles are authorized to post prices for a given market. There is only one active parameter set at any given time. Updates to parameters can be made via on-chain parameter update proposals.
|
||||
`Paramaters` determine which markets are tracked by the pricefeed and which oracles are authorized to post prices for a given market. There is only one active parameter set at any given time. Updates to parameters can be made via on-chain parameter update proposals.
|
||||
|
||||
```go
|
||||
// Params params for pricefeed. Can be altered via governance
|
||||
|
@ -25,7 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// GenesisState defines the pricefeed module's genesis state.
|
||||
type GenesisState struct {
|
||||
// params defines all the parameters of the module.
|
||||
// params defines all the paramaters of the module.
|
||||
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
||||
PostedPrices PostedPrices `protobuf:"bytes,2,rep,name=posted_prices,json=postedPrices,proto3,castrepeated=PostedPrices" json:"posted_prices"`
|
||||
}
|
||||
|
32
x/pricefeed/types/querier.go
Normal file
32
x/pricefeed/types/querier.go
Normal file
@ -0,0 +1,32 @@
|
||||
package types
|
||||
|
||||
// price Takes an [assetcode] and returns CurrentPrice for that asset
|
||||
// pricefeed Takes an [assetcode] and returns the raw []PostedPrice for that asset
|
||||
// assets Returns []Assets in the pricefeed system
|
||||
|
||||
const (
|
||||
// QueryGetParams command for params query
|
||||
QueryGetParams = "parameters"
|
||||
// QueryMarkets command for assets query
|
||||
QueryMarkets = "markets"
|
||||
// QueryOracles command for oracles query
|
||||
QueryOracles = "oracles"
|
||||
// QueryRawPrices command for raw price queries
|
||||
QueryRawPrices = "rawprices"
|
||||
// QueryPrice command for price queries
|
||||
QueryPrice = "price"
|
||||
// QueryPrices command for quering all prices
|
||||
QueryPrices = "prices"
|
||||
)
|
||||
|
||||
// QueryWithMarketIDParams fields for querying information from a specific market
|
||||
type QueryWithMarketIDParams struct {
|
||||
MarketID string
|
||||
}
|
||||
|
||||
// NewQueryWithMarketIDParams creates a new instance of QueryWithMarketIDParams
|
||||
func NewQueryWithMarketIDParams(marketID string) QueryWithMarketIDParams {
|
||||
return QueryWithMarketIDParams{
|
||||
MarketID: marketID,
|
||||
}
|
||||
}
|
@ -558,17 +558,17 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "pricefeed", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "pricefeed", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Price_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "pricefeed", "v1beta1", "prices", "market_id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Price_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "pricefeed", "v1beta1", "prices", "market_id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Prices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "pricefeed", "v1beta1", "prices"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Prices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "pricefeed", "v1beta1", "prices"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_RawPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "pricefeed", "v1beta1", "rawprices", "market_id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_RawPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "pricefeed", "v1beta1", "rawprices", "market_id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Oracles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "pricefeed", "v1beta1", "oracles", "market_id"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Oracles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"0g", "pricefeed", "v1beta1", "oracles", "market_id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_Markets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "pricefeed", "v1beta1", "markets"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_Markets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "pricefeed", "v1beta1", "markets"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@ -48,12 +48,19 @@ func queryCirculatingSupply() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.CirculatingSupply(context.Background(), &types.QueryCirculatingSupplyRequest{})
|
||||
// Query
|
||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupply), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cliCtx.PrintString(res.Amount.String())
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
|
||||
// Decode and print results
|
||||
var out int64
|
||||
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal supply: %w", err)
|
||||
}
|
||||
return cliCtx.PrintObjectLegacy(out)
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -69,12 +76,20 @@ func queryTotalSupply() *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.TotalSupply(context.Background(), &types.QueryTotalSupplyRequest{})
|
||||
|
||||
// Query
|
||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupply), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cliCtx.PrintString(res.Amount.String())
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
|
||||
// Decode and print results
|
||||
var out int64
|
||||
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal supply: %w", err)
|
||||
}
|
||||
return cliCtx.PrintObjectLegacy(out)
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -91,12 +106,19 @@ func queryCirculatingSupplyHARD() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.CirculatingSupplyHARD(context.Background(), &types.QueryCirculatingSupplyHARDRequest{})
|
||||
// Query
|
||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplyHARD), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cliCtx.PrintString(res.Amount.String())
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
|
||||
// Decode and print results
|
||||
var out int64
|
||||
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal supply: %w", err)
|
||||
}
|
||||
return cliCtx.PrintObjectLegacy(out)
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -113,12 +135,19 @@ func queryCirculatingSupplyUSDX() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.CirculatingSupplyUSDX(context.Background(), &types.QueryCirculatingSupplyUSDXRequest{})
|
||||
// Query
|
||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplyUSDX), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cliCtx.PrintString(res.Amount.String())
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
|
||||
// Decode and print results
|
||||
var out int64
|
||||
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal supply: %w", err)
|
||||
}
|
||||
return cliCtx.PrintObjectLegacy(out)
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -135,12 +164,19 @@ func queryCirculatingSupplySWP() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.CirculatingSupplySWP(context.Background(), &types.QueryCirculatingSupplySWPRequest{})
|
||||
// Query
|
||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplySWP), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cliCtx.PrintString(res.Amount.String())
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
|
||||
// Decode and print results
|
||||
var out int64
|
||||
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal supply: %w", err)
|
||||
}
|
||||
return cliCtx.PrintObjectLegacy(out)
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -157,12 +193,19 @@ func queryTotalSupplyHARD() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.TotalSupplyHARD(context.Background(), &types.QueryTotalSupplyHARDRequest{})
|
||||
// Query
|
||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupplyHARD), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cliCtx.PrintString(res.Amount.String())
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
|
||||
// Decode and print results
|
||||
var out int64
|
||||
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal supply: %w", err)
|
||||
}
|
||||
return cliCtx.PrintObjectLegacy(out)
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -179,12 +222,19 @@ func queryTotalSupplyUSDX() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.TotalSupplyUSDX(context.Background(), &types.QueryTotalSupplyUSDXRequest{})
|
||||
// Query
|
||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupplyUSDX), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cliCtx.PrintString(res.Amount.String())
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
|
||||
// Decode and print results
|
||||
var out int64
|
||||
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal supply: %w", err)
|
||||
}
|
||||
return cliCtx.PrintObjectLegacy(out)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@ -26,18 +25,37 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) {
|
||||
|
||||
func getTotalSupplyHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.TotalSupply(context.Background(), &types.QueryTotalSupplyRequest{})
|
||||
params := types.NewBaseQueryParams(page, limit)
|
||||
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
||||
return
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupply)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(res.Amount.Int64())
|
||||
var totalSupply int64
|
||||
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &totalSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(totalSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@ -48,18 +66,38 @@ func getTotalSupplyHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
|
||||
func getCirculatingSupplyHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.CirculatingSupply(context.Background(), &types.QueryCirculatingSupplyRequest{})
|
||||
params := types.NewBaseQueryParams(page, limit)
|
||||
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
||||
return
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupply)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(res.Amount.Int64())
|
||||
|
||||
var circSupply int64
|
||||
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &circSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(circSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@ -70,18 +108,38 @@ func getCirculatingSupplyHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
|
||||
func getCirculatingSupplyHARDHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.CirculatingSupplyHARD(context.Background(), &types.QueryCirculatingSupplyHARDRequest{})
|
||||
params := types.NewBaseQueryParams(page, limit)
|
||||
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
||||
return
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplyHARD)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(res.Amount.Int64())
|
||||
|
||||
var circSupply int64
|
||||
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &circSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(circSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@ -92,18 +150,38 @@ func getCirculatingSupplyHARDHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
|
||||
func getCirculatingSupplyUSDXHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.CirculatingSupplyUSDX(context.Background(), &types.QueryCirculatingSupplyUSDXRequest{})
|
||||
params := types.NewBaseQueryParams(page, limit)
|
||||
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
||||
return
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplyUSDX)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(res.Amount.Int64())
|
||||
|
||||
var circSupply int64
|
||||
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &circSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(circSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@ -114,18 +192,38 @@ func getCirculatingSupplyUSDXHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
|
||||
func getCirculatingSupplySWPHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.CirculatingSupplySWP(context.Background(), &types.QueryCirculatingSupplySWPRequest{})
|
||||
params := types.NewBaseQueryParams(page, limit)
|
||||
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
||||
return
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplySWP)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(res.Amount.Int64())
|
||||
|
||||
var circSupply int64
|
||||
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &circSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(circSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@ -136,18 +234,37 @@ func getCirculatingSupplySWPHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
|
||||
func getTotalSupplyHARDHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.TotalSupplyHARD(context.Background(), &types.QueryTotalSupplyHARDRequest{})
|
||||
params := types.NewBaseQueryParams(page, limit)
|
||||
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
||||
return
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupplyHARD)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(res.Amount.Int64())
|
||||
var totalSupply int64
|
||||
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &totalSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(totalSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@ -158,18 +275,37 @@ func getTotalSupplyHARDHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
|
||||
func getTotalSupplyUSDXHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(cliCtx)
|
||||
res, err := queryClient.TotalSupplyUSDX(context.Background(), &types.QueryTotalSupplyUSDXRequest{})
|
||||
params := types.NewBaseQueryParams(page, limit)
|
||||
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
||||
return
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupplyUSDX)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(res.Amount.Int64())
|
||||
var totalSupply int64
|
||||
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &totalSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resBytes, err := json.Marshal(totalSupply)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user