mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
Compare commits
98 Commits
1d2504b085
...
14401bd2fb
Author | SHA1 | Date | |
---|---|---|---|
|
14401bd2fb | ||
|
3b67405fe2 | ||
|
b4b51d2ef8 | ||
|
faa7000efe | ||
|
4d8001de22 | ||
|
2a63bffa89 | ||
|
f590e8b738 | ||
|
e5f54f891e | ||
|
d382cd10ec | ||
|
be974c4b0c | ||
|
ee61e39769 | ||
|
c42d1f1181 | ||
|
8b0604651f | ||
|
563d255930 | ||
|
32ca84c90b | ||
|
f3f9b706ea | ||
|
b37e27e58b | ||
|
455d173924 | ||
|
344f8b0565 | ||
|
0f2f82d98f | ||
|
b8ed70c775 | ||
|
d2acd8bf79 | ||
|
141796f158 | ||
|
f22eaea78a | ||
|
bb71f37b49 | ||
|
2ab492da82 | ||
|
429946d0f2 | ||
|
ff01dec980 | ||
|
7feec1d03b | ||
|
35a9c8376e | ||
|
1e01260353 | ||
|
4762d5acda | ||
|
9216f3dfc9 | ||
|
dd17b8f33d | ||
|
217d4cb048 | ||
|
8bdba3d46d | ||
|
e84a7b02ff | ||
|
eb1614dfde | ||
|
63c1689224 | ||
|
5389e161fe | ||
|
5db21cba18 | ||
|
578897f69f | ||
|
838a2d9ae9 | ||
|
a4ed55e9f3 | ||
|
b7ae5a4254 | ||
|
f8cf8525a4 | ||
|
db3d8316ef | ||
|
5489b140da | ||
|
cb39713e5d | ||
|
a501d1dae1 | ||
|
4f8d519a4d | ||
|
93595837ca | ||
|
0cc08ddba9 | ||
|
b14d8118fc | ||
|
dd986de448 | ||
|
3f7ae266fb | ||
|
015f6224bd | ||
|
c7a31a1a9f | ||
|
0709f2e129 | ||
|
7bc25a060f | ||
|
2a1d44c2d1 | ||
|
14e7e097fb | ||
|
df8931b401 | ||
|
18b6199c1d | ||
|
119762996e | ||
|
70b145ed41 | ||
|
758c81e481 | ||
|
71b48e64ad | ||
|
aef6312f70 | ||
|
9b4a1e6b32 | ||
|
b4064b7d9f | ||
|
9926bd7169 | ||
|
e012f3b35e | ||
|
d98f766000 | ||
|
62fe3fb50e | ||
|
8eb3b881fc | ||
|
ebff3e752d | ||
|
de94f36095 | ||
|
d7101481c0 | ||
|
7991406367 | ||
|
c0f3951b40 | ||
|
5d11dcab48 | ||
|
522d69e0a8 | ||
|
6eb38a0aa4 | ||
|
4c21606bb5 | ||
|
b995c16abd | ||
|
c2af9df57f | ||
|
55dee00b2c | ||
|
916f251143 | ||
|
e6244b7e89 | ||
|
2f42984449 | ||
|
1f82949c56 | ||
|
803f54113a | ||
|
821d67a20b | ||
|
c1e6321179 | ||
|
1db1e8da8a | ||
|
72063ddda9 | ||
|
802f1c8112 |
20
.github/mergify.yml
vendored
20
.github/mergify.yml
vendored
@ -25,8 +25,6 @@ pull_request_rules:
|
||||
- release/v0.21.x
|
||||
- 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:
|
||||
@ -81,21 +79,3 @@ pull_request_rules:
|
||||
backport:
|
||||
branches:
|
||||
- release/v0.24.x
|
||||
|
||||
- name: Backport patches to the release/v0.25.x branch
|
||||
conditions:
|
||||
- base=master
|
||||
- label=A:backport/v0.25.x
|
||||
actions:
|
||||
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
|
||||
|
54
.github/workflows/cd-protonet-manual.yml
vendored
54
.github/workflows/cd-protonet-manual.yml
vendored
@ -1,54 +0,0 @@
|
||||
name: Manual Deployment (Protonet)
|
||||
# allow to be triggered manually
|
||||
on: workflow_dispatch
|
||||
|
||||
jobs:
|
||||
# in order:
|
||||
# enter standby (prevents autoscaling group from killing node during deploy)
|
||||
# stop kava
|
||||
# take ebs + zfs snapshots
|
||||
# download updated binary and genesis
|
||||
# reset application database state (only done on internal testnet)
|
||||
reset-chain-to-zero-state:
|
||||
uses: ./.github/workflows/cd-reset-internal-testnet.yml
|
||||
with:
|
||||
aws-region: us-east-1
|
||||
chain-id: proto_2221-17000
|
||||
ssm-document-name: kava-testnet-internal-node-update
|
||||
playbook-name: reset-protonet-playbook.yml
|
||||
playbook-infrastructure-branch: master
|
||||
secrets: inherit
|
||||
|
||||
# start kava with new binary and genesis state on api, peer and seed nodes, place nodes in service once they start and are synched to live
|
||||
start-chain-api:
|
||||
uses: ./.github/workflows/cd-start-chain.yml
|
||||
with:
|
||||
aws-region: us-east-1
|
||||
chain-id: proto_2221-17000
|
||||
ssm-document-name: kava-testnet-internal-node-update
|
||||
playbook-name: start-chain-api-playbook.yml
|
||||
playbook-infrastructure-branch: master
|
||||
secrets: inherit
|
||||
needs: [reset-chain-to-zero-state]
|
||||
|
||||
# setup test and development accounts and balances, deploy contracts by calling the chain's api
|
||||
seed-chain-state:
|
||||
uses: ./.github/workflows/cd-seed-chain.yml
|
||||
with:
|
||||
chain-api-url: https://rpc.app.protonet.us-east.production.kava.io:443
|
||||
chain-id: proto_2221-17000
|
||||
seed-script-filename: seed-protonet.sh
|
||||
erc20-deployer-network-name: protonet
|
||||
genesis_validator_addresses: "kavavaloper14w4avgdvqrlpww6l5dhgj4egfn6ln7gmtp7r2m"
|
||||
kava_version_filepath: ./ci/env/kava-protonet/KAVA.VERSION
|
||||
secrets: inherit
|
||||
needs: [start-chain-api]
|
||||
post-pipeline-metrics:
|
||||
uses: ./.github/workflows/metric-pipeline.yml
|
||||
if: always() # always run so we metric failures and successes
|
||||
with:
|
||||
aws-region: us-east-1
|
||||
metric-name: kava.deploys.testnet.proto
|
||||
namespace: Kava/ContinuousDeployment
|
||||
secrets: inherit
|
||||
needs: [seed-chain-state]
|
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 }}
|
||||
|
2
.github/workflows/ci-master.yml
vendored
2
.github/workflows/ci-master.yml
vendored
@ -29,7 +29,7 @@ jobs:
|
||||
- name: build rocksdb dependency
|
||||
run: bash ${GITHUB_WORKSPACE}/.github/scripts/install-rocksdb.sh
|
||||
env:
|
||||
ROCKSDB_VERSION: v8.10.0
|
||||
ROCKSDB_VERSION: v8.1.1
|
||||
- name: Build and upload release artifacts
|
||||
run: bash ${GITHUB_WORKSPACE}/.github/scripts/publish-internal-release-artifacts.sh
|
||||
env:
|
||||
|
2
.github/workflows/ci-rocksdb-build.yml
vendored
2
.github/workflows/ci-rocksdb-build.yml
vendored
@ -1,7 +1,7 @@
|
||||
name: Continuous Integration (Rocksdb Build)
|
||||
|
||||
env:
|
||||
ROCKSDB_VERSION: v8.10.0
|
||||
ROCKSDB_VERSION: v8.1.1
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
6
.github/workflows/upload-release-assets.yml
vendored
6
.github/workflows/upload-release-assets.yml
vendored
@ -12,11 +12,11 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.21'
|
||||
go-version: '1.20'
|
||||
- name: Build
|
||||
run: sudo LINK_STATICALLY=true make build-release
|
||||
run: make build
|
||||
- name: Rename file
|
||||
run: sudo mv ./out/linux/0gchaind ./out/linux/0gchaind-linux-${{ github.ref_name }}
|
||||
run: mv ./out/linux/0gchaind ./out/linux/0gchaind-linux-${{ github.ref_name }}
|
||||
- name: Upload Release Asset
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
|
@ -1,2 +1,2 @@
|
||||
golang 1.21
|
||||
golang 1.20
|
||||
nodejs 18.16.0
|
||||
|
45
CHANGELOG.md
45
CHANGELOG.md
@ -36,19 +36,6 @@ 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
|
||||
|
||||
## [v0.25.0]
|
||||
|
||||
### Features
|
||||
@ -56,12 +43,11 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
- (community) [#1704] Add module params
|
||||
- (community) [#1706] Add disable inflation upgrade
|
||||
- (community) [#1745] Enable params update via governance with `MsgUpdateParams`
|
||||
- (client) [#1784] Add Kava gRPC client
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- (ethermint) [#1788] Fixes issue where tracing a transaction could show it's status as successful when isolated in simulation even if the tx when executed on the chain failed due to an error such as exhausting the block gas meter
|
||||
- (evmutil) [#1655] Initialize x/evmutil module account in InitGenesis
|
||||
- (deps) [#1770] Bump ledger-cosmos-go to v0.13.1 to resolve signing error with
|
||||
cosmos ledger app 2.34.12
|
||||
|
||||
## State Machine Breaking
|
||||
@ -74,19 +60,9 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
- (community) [#1755] Keep funds in `x/community` in `CommunityPoolLendWithdrawProposal` handler
|
||||
- (staking) [#1761] Set validator minimum commission to 5% for all validators under 5%
|
||||
|
||||
## [v0.24.3]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- (deps) [#1770] Bump ledger-cosmos-go to v0.13.1 to resolve signing error with
|
||||
- (rocksdb) [#1767] Fix resolution of rocksdb database path introduced in v0.24.2
|
||||
|
||||
**Note**: There was a bug released as v0.24.2. The tag has been removed and the commit should not be used.
|
||||
|
||||
## [v0.24.1]
|
||||
|
||||
### Features
|
||||
|
||||
- (metrics) [#1668] Adds non-state breaking x/metrics module for custom telemetry.
|
||||
- (metrics) [#1669] Add performance timing metrics to all Begin/EndBlockers
|
||||
- (community) [#1751] Add `AnnualizedRewards` query endpoint
|
||||
@ -330,15 +306,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
|
||||
[#1784]: https://github.com/Kava-Labs/kava/pull/1784
|
||||
[#1770]: https://github.com/Kava-Labs/kava/pull/1770
|
||||
[#1755]: https://github.com/Kava-Labs/kava/pull/1755
|
||||
[#1761]: https://github.com/Kava-Labs/kava/pull/1761
|
||||
@ -392,12 +359,14 @@ the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/CHANGELOG.md).
|
||||
[#750]: https://github.com/Kava-Labs/kava/pull/750
|
||||
[#751]: https://github.com/Kava-Labs/kava/pull/751
|
||||
[#780]: https://github.com/Kava-Labs/kava/pull/780
|
||||
|
||||
[unreleased]: https://github.com/Kava-Labs/kava/compare/v0.25.0...HEAD
|
||||
[v0.25.0]: https://github.com/Kava-Labs/kava/compare/v0.25.0...v0.24.3
|
||||
[v0.24.3]: https://github.com/Kava-Labs/kava/compare/v0.24.3...v0.24.1
|
||||
[v0.24.1]: https://github.com/Kava-Labs/kava/compare/v0.24.1...v0.24.0
|
||||
[v0.24.0]: https://github.com/Kava-Labs/kava/compare/v0.24.0...v0.23.2
|
||||
|
||||
[v0.25.0]: https://github.com/Kava-Labs/kava/compare/v0.24.1...v0.25.0
|
||||
[v0.24.1]: https://github.com/Kava-Labs/kava/compare/v0.24.0...v0.24.1
|
||||
[v0.24.0]: https://github.com/Kava-Labs/kava/compare/v0.23.2...v0.24.0
|
||||
[v0.23.2]: https://github.com/Kava-Labs/kava/compare/v0.23.1...v0.23.2
|
||||
[v0.23.1]: https://github.com/Kava-Labs/kava/compare/v0.23.0...v0.23.1
|
||||
[v0.23.0]: https://github.com/Kava-Labs/kava/compare/v0.21.1...v0.23.0
|
||||
[v0.16.1]: https://github.com/Kava-Labs/kava/compare/v0.16.0...v0.16.1
|
||||
[v0.16.0]: https://github.com/Kava-Labs/kava/compare/v0.15.2...v0.16.0
|
||||
|
12
Dockerfile
12
Dockerfile
@ -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
|
||||
@ -19,15 +19,6 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
go version && go mod download
|
||||
|
||||
# Cosmwasm - Download correct libwasmvm version
|
||||
RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \
|
||||
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \
|
||||
-O /lib/libwasmvm.$ARCH.a && \
|
||||
# verify checksum
|
||||
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
|
||||
sha256sum /lib/libwasmvm.$ARCH.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1)
|
||||
|
||||
|
||||
# Add source files
|
||||
COPY . .
|
||||
|
||||
@ -36,7 +27,6 @@ COPY . .
|
||||
# Mount go build and mod caches as container caches, persisted between builder invocations
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
LINK_STATICALLY=true \
|
||||
make install
|
||||
|
||||
FROM alpine:3.15
|
||||
|
@ -10,7 +10,7 @@ WORKDIR /root
|
||||
# default home directory is /root
|
||||
|
||||
# install rocksdb
|
||||
ARG rocksdb_version=v8.10.0
|
||||
ARG rocksdb_version=v8.1.1
|
||||
ENV ROCKSDB_VERSION=$rocksdb_version
|
||||
|
||||
RUN git clone https://github.com/facebook/rocksdb.git \
|
||||
|
15
Makefile
15
Makefile
@ -6,8 +6,6 @@ BINARY_NAME := 0gchaind
|
||||
MAIN_ENTRY := ./cmd/$(BINARY_NAME)
|
||||
DOCKER_IMAGE_NAME := 0glabs/$(PROJECT_NAME)
|
||||
GO_BIN ?= go
|
||||
ARCH := $(shell uname -m)
|
||||
WASMVM_VERSION := $(shell $(GO_BIN) list -m github.com/CosmWasm/wasmvm | sed 's/.* //')
|
||||
|
||||
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
||||
GIT_COMMIT := $(shell git rev-parse HEAD)
|
||||
@ -32,7 +30,7 @@ VERSION := $(GIT_COMMIT_SHORT)
|
||||
VERSION_NUMBER := $(VERSION)
|
||||
endif
|
||||
|
||||
TENDERMINT_VERSION := $(shell $(GO_BIN) list -m github.com/cometbft/cometbft | sed 's:.* ::')
|
||||
TENDERMINT_VERSION := $(shell $(GO_BIN) list -m github.com/tendermint/tendermint | sed 's:.* ::')
|
||||
COSMOS_SDK_VERSION := $(shell $(GO_BIN) list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
|
||||
|
||||
.PHONY: print-git-info
|
||||
@ -151,7 +149,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(PROJECT_NAME) \
|
||||
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION_NUMBER) \
|
||||
-X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_COMMIT) \
|
||||
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
|
||||
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(TENDERMINT_VERSION)
|
||||
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TENDERMINT_VERSION)
|
||||
|
||||
# DB backend selection
|
||||
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
|
||||
@ -176,10 +174,6 @@ endif
|
||||
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
|
||||
ldflags += -w -s
|
||||
endif
|
||||
|
||||
ifeq ($(LINK_STATICALLY),true)
|
||||
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static -lm"
|
||||
endif
|
||||
ldflags += $(LDFLAGS)
|
||||
ldflags := $(strip $(ldflags))
|
||||
|
||||
@ -201,10 +195,6 @@ else
|
||||
$(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/$(BINARY_NAME) $(MAIN_ENTRY)
|
||||
endif
|
||||
|
||||
build-release: go.sum
|
||||
wget -q https://github.com/CosmWasm/wasmvm/releases/download/$(WASMVM_VERSION)/libwasmvm_muslc.$(ARCH).a -O /lib/libwasmvm.$(ARCH).a
|
||||
$(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/$(BINARY_NAME) $(MAIN_ENTRY)
|
||||
|
||||
build-linux: go.sum
|
||||
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
|
||||
|
||||
@ -343,7 +333,6 @@ start-remote-sims:
|
||||
-—container-override environment=[{SIM_NAME=master-$(VERSION)}]
|
||||
|
||||
update-kvtool:
|
||||
git submodule init || true
|
||||
git submodule update
|
||||
cd tests/e2e/kvtool && make install
|
||||
|
||||
|
@ -11,15 +11,15 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
dbm "github.com/cometbft/cometbft-db"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cometbft/cometbft/libs/log"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
@ -275,7 +275,7 @@ func TestAppStateDeterminism(t *testing.T) {
|
||||
config.ExportParamsPath = ""
|
||||
config.OnOperation = false
|
||||
config.AllInvariants = false
|
||||
config.ChainID = sims.SimAppChainID
|
||||
config.ChainID = helpers.SimAppChainID
|
||||
|
||||
numTimesToRunPerSeed := 2
|
||||
appHashList := make([]json.RawMessage, numTimesToRunPerSeed)
|
||||
|
@ -11,10 +11,6 @@ import (
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
tmbytes "github.com/cometbft/cometbft/libs/bytes"
|
||||
ctypes "github.com/cometbft/cometbft/rpc/core/types"
|
||||
jsonrpctypes "github.com/cometbft/cometbft/rpc/jsonrpc/types"
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
@ -23,6 +19,10 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmbytes "github.com/tendermint/tendermint/libs/bytes"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
jsonrpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
|
||||
)
|
||||
|
||||
type SimulateRequestTestSuite struct {
|
||||
|
@ -5,16 +5,16 @@ import (
|
||||
"runtime/debug"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
tmlog "github.com/cometbft/cometbft/libs/log"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
|
||||
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
|
||||
ibcante "github.com/cosmos/ibc-go/v6/modules/core/ante"
|
||||
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
|
||||
evmante "github.com/evmos/ethermint/app/ante"
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
tmlog "github.com/tendermint/tendermint/libs/log"
|
||||
)
|
||||
|
||||
// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
|
||||
|
@ -7,13 +7,9 @@ import (
|
||||
"time"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
tmdb "github.com/cometbft/cometbft-db"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cometbft/cometbft/libs/log"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
@ -21,6 +17,9 @@ import (
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmdb "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
@ -58,11 +57,10 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
|
||||
nil,
|
||||
encodingConfig,
|
||||
opts,
|
||||
baseapp.SetChainID(app.TestChainId),
|
||||
),
|
||||
}
|
||||
|
||||
chainID := app.TestChainId
|
||||
chainID := "kavatest_1-1"
|
||||
tApp = tApp.InitializeFromGenesisStatesWithTimeAndChainID(
|
||||
time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
chainID,
|
||||
@ -109,7 +107,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
|
||||
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
stdTx, err := sims.GenSignedMockTx(
|
||||
stdTx, err := helpers.GenSignedMockTx(
|
||||
rand.New(rand.NewSource(time.Now().UnixNano())),
|
||||
encodingConfig.TxConfig,
|
||||
[]sdk.Msg{
|
||||
@ -120,7 +118,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
sims.DefaultGenTxGas,
|
||||
helpers.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{0},
|
||||
[]uint64{0}, // fixed sequence numbers will cause tests to fail sig verification if the same address is used twice
|
||||
@ -212,7 +210,7 @@ func TestAppAnteHandler_RejectMsgsInAuthz(t *testing.T) {
|
||||
return msg
|
||||
}
|
||||
|
||||
chainID := app.TestChainId
|
||||
chainID := "kavatest_1-1"
|
||||
encodingConfig := app.MakeEncodingConfig()
|
||||
|
||||
testcases := []struct {
|
||||
@ -241,12 +239,12 @@ func TestAppAnteHandler_RejectMsgsInAuthz(t *testing.T) {
|
||||
chainID,
|
||||
)
|
||||
|
||||
stdTx, err := sims.GenSignedMockTx(
|
||||
stdTx, err := helpers.GenSignedMockTx(
|
||||
rand.New(rand.NewSource(time.Now().UnixNano())),
|
||||
encodingConfig.TxConfig,
|
||||
[]sdk.Msg{tc.msg},
|
||||
sdk.NewCoins(), // no fee
|
||||
sims.DefaultGenTxGas,
|
||||
helpers.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{0},
|
||||
[]uint64{0},
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -39,7 +39,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_NotCheckTx(t *testing.T) {
|
||||
fetcher := mockAddressFetcher(testAddresses[1:]...)
|
||||
|
||||
decorator := ante.NewAuthenticatedMempoolDecorator(fetcher)
|
||||
tx, err := sims.GenSignedMockTx(
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
rand.New(rand.NewSource(time.Now().UnixNano())),
|
||||
txConfig,
|
||||
[]sdk.Msg{
|
||||
@ -50,7 +50,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_NotCheckTx(t *testing.T) {
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
sims.DefaultGenTxGas,
|
||||
helpers.DefaultGenTxGas,
|
||||
"testing-chain-id",
|
||||
[]uint64{0},
|
||||
[]uint64{0},
|
||||
@ -74,7 +74,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Pass(t *testing.T) {
|
||||
|
||||
decorator := ante.NewAuthenticatedMempoolDecorator(fetcher)
|
||||
|
||||
tx, err := sims.GenSignedMockTx(
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
rand.New(rand.NewSource(time.Now().UnixNano())),
|
||||
txConfig,
|
||||
[]sdk.Msg{
|
||||
@ -90,7 +90,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Pass(t *testing.T) {
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
sims.DefaultGenTxGas,
|
||||
helpers.DefaultGenTxGas,
|
||||
"testing-chain-id",
|
||||
[]uint64{0, 123},
|
||||
[]uint64{0, 123},
|
||||
@ -115,7 +115,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Reject(t *testing.T) {
|
||||
|
||||
decorator := ante.NewAuthenticatedMempoolDecorator(fetcher)
|
||||
|
||||
tx, err := sims.GenSignedMockTx(
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
rand.New(rand.NewSource(time.Now().UnixNano())),
|
||||
txConfig,
|
||||
[]sdk.Msg{
|
||||
@ -126,7 +126,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Reject(t *testing.T) {
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
sims.DefaultGenTxGas,
|
||||
helpers.DefaultGenTxGas,
|
||||
"testing-chain-id",
|
||||
[]uint64{0},
|
||||
[]uint64{0},
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
@ -213,12 +213,12 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
tx, err := sims.GenSignedMockTx(
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
rand.New(rand.NewSource(time.Now().UnixNano())),
|
||||
txConfig,
|
||||
tc.msgs,
|
||||
sdk.NewCoins(),
|
||||
sims.DefaultGenTxGas,
|
||||
helpers.DefaultGenTxGas,
|
||||
"testing-chain-id",
|
||||
[]uint64{0},
|
||||
[]uint64{0},
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
|
||||
@ -20,11 +20,6 @@ import (
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cometbft/cometbft/crypto/tmhash"
|
||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
tmversion "github.com/cometbft/cometbft/proto/tendermint/version"
|
||||
"github.com/cometbft/cometbft/version"
|
||||
"github.com/evmos/ethermint/crypto/ethsecp256k1"
|
||||
"github.com/evmos/ethermint/ethereum/eip712"
|
||||
"github.com/evmos/ethermint/tests"
|
||||
@ -32,6 +27,11 @@ import (
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
@ -42,7 +42,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ChainID = app.TestChainId
|
||||
ChainID = "kavatest_1-1"
|
||||
USDCCoinDenom = "erc20/usdc"
|
||||
USDCCDPType = "erc20-usdc"
|
||||
)
|
||||
@ -137,7 +137,6 @@ func (suite *EIP712TestSuite) createTestEIP712CosmosTxBuilder(
|
||||
func (suite *EIP712TestSuite) SetupTest() {
|
||||
tApp := app.NewTestApp()
|
||||
suite.tApp = tApp
|
||||
|
||||
cdc := tApp.AppCodec()
|
||||
suite.evmutilKeeper = tApp.GetEvmutilKeeper()
|
||||
|
||||
@ -291,11 +290,6 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
)
|
||||
suite.usdcEVMAddr = pair.GetAddress()
|
||||
|
||||
// update consensus params
|
||||
cParams := tApp.GetConsensusParams(suite.ctx)
|
||||
cParams.Block.MaxGas = sims.DefaultGenTxGas * 20
|
||||
tApp.StoreConsensusParams(suite.ctx, cParams)
|
||||
|
||||
// Add a contract to evmutil conversion pair
|
||||
evmutilParams := suite.evmutilKeeper.GetParams(suite.ctx)
|
||||
evmutilParams.EnabledConversionPairs =
|
||||
@ -461,7 +455,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
var option *codectypes.Any
|
||||
option, _ = codectypes.NewAnyWithValue(ðerminttypes.ExtensionOptionsWeb3Tx{
|
||||
FeePayer: suite.testAddr.String(),
|
||||
TypedDataChainID: 2221,
|
||||
TypedDataChainID: 1,
|
||||
FeePayerSig: []byte("sig"),
|
||||
})
|
||||
builder, _ := txBuilder.(authtx.ExtensionOptionsTxBuilder)
|
||||
@ -490,7 +484,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
return suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, "kavatest_12-1", uint64(sims.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
suite.testAddr, suite.testPrivKey, "kavatest_12-1", uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -503,7 +497,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
return suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr2, suite.testPrivKey2, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
suite.testAddr2, suite.testPrivKey2, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -531,7 +525,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
txBuilder := suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
if tc.updateTx != nil {
|
||||
txBuilder = tc.updateTx(txBuilder, msgs)
|
||||
@ -605,7 +599,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {
|
||||
// deliver deposit msg
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
txBuilder := suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, depositMsgs,
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, depositMsgs,
|
||||
)
|
||||
txBytes, err := encodingConfig.TxConfig.TxEncoder()(txBuilder.GetTx())
|
||||
suite.Require().NoError(err)
|
||||
@ -639,7 +633,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {
|
||||
|
||||
// deliver withdraw msg
|
||||
txBuilder = suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, withdrawMsgs,
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, withdrawMsgs,
|
||||
)
|
||||
txBytes, err = encodingConfig.TxConfig.TxEncoder()(txBuilder.GetTx())
|
||||
suite.Require().NoError(err)
|
||||
|
@ -4,12 +4,12 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
tmtime "github.com/cometbft/cometbft/types/time"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
@ -73,14 +73,14 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tx, err := sims.GenSignedMockTx(
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
rand.New(rand.NewSource(time.Now().UnixNano())),
|
||||
txConfig,
|
||||
[]sdk.Msg{
|
||||
tt.msg,
|
||||
},
|
||||
sdk.NewCoins(),
|
||||
sims.DefaultGenTxGas,
|
||||
helpers.DefaultGenTxGas,
|
||||
"testing-chain-id",
|
||||
[]uint64{0},
|
||||
[]uint64{0},
|
||||
|
292
app/app.go
292
app/app.go
@ -5,10 +5,6 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
dbm "github.com/cometbft/cometbft-db"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
tmjson "github.com/cometbft/cometbft/libs/json"
|
||||
tmlog "github.com/cometbft/cometbft/libs/log"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
|
||||
@ -24,7 +20,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
||||
@ -39,13 +34,11 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/capability"
|
||||
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
|
||||
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
|
||||
consensus "github.com/cosmos/cosmos-sdk/x/consensus"
|
||||
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
|
||||
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis"
|
||||
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
|
||||
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
|
||||
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
|
||||
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
@ -77,24 +70,16 @@ 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"
|
||||
ibcwasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm"
|
||||
ibcwasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper"
|
||||
ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/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"
|
||||
ibc "github.com/cosmos/ibc-go/v7/modules/core"
|
||||
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"
|
||||
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"
|
||||
transfer "github.com/cosmos/ibc-go/v6/modules/apps/transfer"
|
||||
ibctransferkeeper "github.com/cosmos/ibc-go/v6/modules/apps/transfer/keeper"
|
||||
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
|
||||
ibc "github.com/cosmos/ibc-go/v6/modules/core"
|
||||
ibcclient "github.com/cosmos/ibc-go/v6/modules/core/02-client"
|
||||
ibcclientclient "github.com/cosmos/ibc-go/v6/modules/core/02-client/client"
|
||||
ibcclienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
|
||||
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
|
||||
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"
|
||||
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
|
||||
evmante "github.com/evmos/ethermint/app/ante"
|
||||
ethermintconfig "github.com/evmos/ethermint/server/config"
|
||||
"github.com/evmos/ethermint/x/evm"
|
||||
@ -105,6 +90,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"
|
||||
@ -143,7 +133,7 @@ var (
|
||||
// ModuleBasics manages simple versions of full app modules.
|
||||
// It's used for things such as codec registration and genesis file verification.
|
||||
ModuleBasics = module.NewBasicManager(
|
||||
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
|
||||
genutil.AppModuleBasic{},
|
||||
auth.AppModuleBasic{},
|
||||
bank.AppModuleBasic{},
|
||||
capability.AppModuleBasic{},
|
||||
@ -151,6 +141,7 @@ var (
|
||||
distr.AppModuleBasic{},
|
||||
gov.NewAppModuleBasic([]govclient.ProposalHandler{
|
||||
paramsclient.ProposalHandler,
|
||||
distrclient.ProposalHandler,
|
||||
upgradeclient.LegacyProposalHandler,
|
||||
upgradeclient.LegacyCancelProposalHandler,
|
||||
ibcclientclient.UpdateClientProposalHandler,
|
||||
@ -161,9 +152,6 @@ var (
|
||||
crisis.AppModuleBasic{},
|
||||
slashing.AppModuleBasic{},
|
||||
ibc.AppModuleBasic{},
|
||||
ibctm.AppModuleBasic{},
|
||||
solomachine.AppModuleBasic{},
|
||||
packetforward.AppModuleBasic{},
|
||||
upgrade.AppModuleBasic{},
|
||||
evidence.AppModuleBasic{},
|
||||
authzmodule.AppModuleBasic{},
|
||||
@ -180,8 +168,6 @@ var (
|
||||
mint.AppModuleBasic{},
|
||||
council.AppModuleBasic{},
|
||||
dasigners.AppModuleBasic{},
|
||||
consensus.AppModuleBasic{},
|
||||
ibcwasm.AppModuleBasic{},
|
||||
)
|
||||
|
||||
// module account permissions
|
||||
@ -204,7 +190,8 @@ var (
|
||||
|
||||
// Verify app interface at compile time
|
||||
var (
|
||||
_ servertypes.Application = (*App)(nil)
|
||||
_ servertypes.Application = (*App)(nil)
|
||||
_ servertypes.ApplicationQueryService = (*App)(nil)
|
||||
)
|
||||
|
||||
// Options bundles several configuration params for an App.
|
||||
@ -240,34 +227,31 @@ type App struct {
|
||||
memKeys map[string]*storetypes.MemoryStoreKey
|
||||
|
||||
// keepers from all the modules
|
||||
accountKeeper authkeeper.AccountKeeper
|
||||
bankKeeper bankkeeper.Keeper
|
||||
capabilityKeeper *capabilitykeeper.Keeper
|
||||
stakingKeeper *stakingkeeper.Keeper
|
||||
distrKeeper distrkeeper.Keeper
|
||||
govKeeper govkeeper.Keeper
|
||||
paramsKeeper paramskeeper.Keeper
|
||||
authzKeeper authzkeeper.Keeper
|
||||
crisisKeeper crisiskeeper.Keeper
|
||||
slashingKeeper slashingkeeper.Keeper
|
||||
ibcWasmClientKeeper ibcwasmkeeper.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
|
||||
issuanceKeeper issuancekeeper.Keeper
|
||||
bep3Keeper bep3keeper.Keeper
|
||||
pricefeedKeeper pricefeedkeeper.Keeper
|
||||
committeeKeeper committeekeeper.Keeper
|
||||
vestingKeeper vestingkeeper.VestingKeeper
|
||||
mintKeeper mintkeeper.Keeper
|
||||
dasignersKeeper dasignerskeeper.Keeper
|
||||
consensusParamsKeeper consensusparamkeeper.Keeper
|
||||
accountKeeper authkeeper.AccountKeeper
|
||||
bankKeeper bankkeeper.Keeper
|
||||
capabilityKeeper *capabilitykeeper.Keeper
|
||||
stakingKeeper stakingkeeper.Keeper
|
||||
distrKeeper distrkeeper.Keeper
|
||||
govKeeper govkeeper.Keeper
|
||||
paramsKeeper paramskeeper.Keeper
|
||||
authzKeeper authzkeeper.Keeper
|
||||
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
|
||||
evmKeeper *evmkeeper.Keeper
|
||||
evmutilKeeper evmutilkeeper.Keeper
|
||||
feeMarketKeeper feemarketkeeper.Keeper
|
||||
upgradeKeeper upgradekeeper.Keeper
|
||||
evidenceKeeper evidencekeeper.Keeper
|
||||
transferKeeper ibctransferkeeper.Keeper
|
||||
CouncilKeeper councilkeeper.Keeper
|
||||
issuanceKeeper issuancekeeper.Keeper
|
||||
bep3Keeper bep3keeper.Keeper
|
||||
pricefeedKeeper pricefeedkeeper.Keeper
|
||||
committeeKeeper committeekeeper.Keeper
|
||||
vestingKeeper vestingkeeper.VestingKeeper
|
||||
mintKeeper mintkeeper.Keeper
|
||||
dasignersKeeper dasignerskeeper.Keeper
|
||||
|
||||
// make scoped keepers public for test purposes
|
||||
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
|
||||
@ -307,8 +291,8 @@ func NewApp(
|
||||
|
||||
keys := sdk.NewKVStoreKeys(
|
||||
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
|
||||
distrtypes.StoreKey, slashingtypes.StoreKey, packetforwardtypes.StoreKey,
|
||||
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey,
|
||||
distrtypes.StoreKey, slashingtypes.StoreKey,
|
||||
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey,
|
||||
upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey,
|
||||
evmtypes.StoreKey, feemarkettypes.StoreKey, authzkeeper.StoreKey,
|
||||
capabilitytypes.StoreKey,
|
||||
@ -318,15 +302,12 @@ func NewApp(
|
||||
counciltypes.StoreKey,
|
||||
dasignerstypes.StoreKey,
|
||||
vestingtypes.StoreKey,
|
||||
consensusparamtypes.StoreKey, crisistypes.StoreKey,
|
||||
ibcwasmtypes.StoreKey,
|
||||
)
|
||||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
|
||||
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
||||
|
||||
// Authority for gov proposals, using the x/gov module account address
|
||||
govAuthAddr := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
govAuthAddrStr := govAuthAddr.String()
|
||||
govAuthorityAddr := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
|
||||
app := &App{
|
||||
BaseApp: bApp,
|
||||
@ -355,20 +336,18 @@ func NewApp(
|
||||
issuanceSubspace := app.paramsKeeper.Subspace(issuancetypes.ModuleName)
|
||||
bep3Subspace := app.paramsKeeper.Subspace(bep3types.ModuleName)
|
||||
pricefeedSubspace := app.paramsKeeper.Subspace(pricefeedtypes.ModuleName)
|
||||
ibcSubspace := app.paramsKeeper.Subspace(ibcexported.ModuleName)
|
||||
ibcSubspace := app.paramsKeeper.Subspace(ibchost.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)
|
||||
mintSubspace := app.paramsKeeper.Subspace(minttypes.ModuleName)
|
||||
|
||||
// set the BaseApp's parameter store
|
||||
app.consensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], govAuthAddrStr)
|
||||
bApp.SetParamStore(&app.consensusParamsKeeper)
|
||||
|
||||
bApp.SetParamStore(
|
||||
app.paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()),
|
||||
)
|
||||
app.capabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
|
||||
scopedIBCKeeper := app.capabilityKeeper.ScopeToModule(ibcexported.ModuleName)
|
||||
scopedIBCKeeper := app.capabilityKeeper.ScopeToModule(ibchost.ModuleName)
|
||||
scopedTransferKeeper := app.capabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
|
||||
app.capabilityKeeper.Seal()
|
||||
|
||||
@ -376,17 +355,17 @@ func NewApp(
|
||||
app.accountKeeper = authkeeper.NewAccountKeeper(
|
||||
appCodec,
|
||||
keys[authtypes.StoreKey],
|
||||
authSubspace,
|
||||
authtypes.ProtoBaseAccount,
|
||||
mAccPerms,
|
||||
sdk.GetConfig().GetBech32AccountAddrPrefix(),
|
||||
govAuthAddrStr,
|
||||
)
|
||||
app.bankKeeper = bankkeeper.NewBaseKeeper(
|
||||
appCodec,
|
||||
keys[banktypes.StoreKey],
|
||||
app.accountKeeper,
|
||||
bankSubspace,
|
||||
app.loadBlockedMaccAddrs(),
|
||||
govAuthAddrStr,
|
||||
)
|
||||
app.vestingKeeper = vestingkeeper.NewVestingKeeper(app.accountKeeper, app.bankKeeper, keys[vestingtypes.StoreKey])
|
||||
|
||||
@ -396,7 +375,7 @@ func NewApp(
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
app.vestingKeeper,
|
||||
govAuthAddrStr,
|
||||
stakingSubspace,
|
||||
)
|
||||
app.authzKeeper = authzkeeper.NewKeeper(
|
||||
keys[authzkeeper.StoreKey],
|
||||
@ -407,68 +386,52 @@ func NewApp(
|
||||
app.distrKeeper = distrkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[distrtypes.StoreKey],
|
||||
distrSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
app.stakingKeeper,
|
||||
&app.stakingKeeper,
|
||||
authtypes.FeeCollectorName,
|
||||
govAuthAddrStr,
|
||||
)
|
||||
app.slashingKeeper = slashingkeeper.NewKeeper(
|
||||
appCodec,
|
||||
app.legacyAmino,
|
||||
keys[slashingtypes.StoreKey],
|
||||
app.stakingKeeper,
|
||||
govAuthAddrStr,
|
||||
&app.stakingKeeper,
|
||||
slashingSubspace,
|
||||
)
|
||||
app.crisisKeeper = *crisiskeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[crisistypes.StoreKey],
|
||||
app.crisisKeeper = crisiskeeper.NewKeeper(
|
||||
crisisSubspace,
|
||||
options.InvariantCheckPeriod,
|
||||
app.bankKeeper,
|
||||
authtypes.FeeCollectorName,
|
||||
govAuthAddrStr,
|
||||
)
|
||||
app.upgradeKeeper = *upgradekeeper.NewKeeper(
|
||||
app.upgradeKeeper = upgradekeeper.NewKeeper(
|
||||
options.SkipUpgradeHeights,
|
||||
keys[upgradetypes.StoreKey],
|
||||
appCodec,
|
||||
homePath,
|
||||
app.BaseApp,
|
||||
govAuthAddrStr,
|
||||
govAuthorityAddr.String(),
|
||||
)
|
||||
app.evidenceKeeper = *evidencekeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[evidencetypes.StoreKey],
|
||||
app.stakingKeeper,
|
||||
&app.stakingKeeper,
|
||||
app.slashingKeeper,
|
||||
)
|
||||
|
||||
app.ibcKeeper = ibckeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[ibcexported.StoreKey],
|
||||
keys[ibchost.StoreKey],
|
||||
ibcSubspace,
|
||||
app.stakingKeeper,
|
||||
app.upgradeKeeper,
|
||||
scopedIBCKeeper,
|
||||
)
|
||||
|
||||
app.ibcWasmClientKeeper = ibcwasmkeeper.NewKeeperWithConfig(
|
||||
appCodec,
|
||||
keys[ibcwasmtypes.StoreKey],
|
||||
app.ibcKeeper.ClientKeeper,
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
ibcwasmtypes.WasmConfig{
|
||||
DataDir: "ibc_08-wasm",
|
||||
SupportedCapabilities: "iterator,stargate",
|
||||
ContractDebugMode: false,
|
||||
},
|
||||
app.GRPCQueryRouter(),
|
||||
)
|
||||
|
||||
// Create Ethermint keepers
|
||||
app.feeMarketKeeper = feemarketkeeper.NewKeeper(
|
||||
appCodec,
|
||||
govAuthAddr,
|
||||
govAuthorityAddr,
|
||||
keys[feemarkettypes.StoreKey],
|
||||
tkeys[feemarkettypes.TransientKey],
|
||||
feemarketSubspace,
|
||||
@ -495,7 +458,7 @@ func NewApp(
|
||||
// evm keeper
|
||||
app.evmKeeper = evmkeeper.NewKeeper(
|
||||
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey],
|
||||
govAuthAddr,
|
||||
govAuthorityAddr,
|
||||
app.accountKeeper, evmBankKeeper, app.stakingKeeper, app.feeMarketKeeper,
|
||||
options.EVMTrace,
|
||||
evmSubspace,
|
||||
@ -504,49 +467,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(
|
||||
@ -573,11 +510,11 @@ func NewApp(
|
||||
app.mintKeeper = mintkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[minttypes.StoreKey],
|
||||
mintSubspace,
|
||||
app.stakingKeeper,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
authtypes.FeeCollectorName,
|
||||
govAuthAddrStr,
|
||||
)
|
||||
|
||||
// create committee keeper with router
|
||||
@ -585,7 +522,8 @@ func NewApp(
|
||||
committeeGovRouter.
|
||||
AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
|
||||
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
|
||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.upgradeKeeper))
|
||||
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)).
|
||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper))
|
||||
// Note: the committee proposal handler is not registered on the committee router. This means committees cannot create or update other committees.
|
||||
// Adding the committee proposal handler to the router is possible but awkward as the handler depends on the keeper which depends on the handler.
|
||||
app.committeeKeeper = committeekeeper.NewKeeper(
|
||||
@ -598,11 +536,12 @@ func NewApp(
|
||||
)
|
||||
|
||||
// register the staking hooks
|
||||
app.stakingKeeper.SetHooks(
|
||||
// NOTE: These keepers are passed by reference above, so they will contain these hooks.
|
||||
app.stakingKeeper = *(app.stakingKeeper.SetHooks(
|
||||
stakingtypes.NewMultiStakingHooks(
|
||||
app.distrKeeper.Hooks(),
|
||||
app.slashingKeeper.Hooks(),
|
||||
))
|
||||
)))
|
||||
|
||||
// create gov keeper with router
|
||||
// NOTE this must be done after any keepers referenced in the gov router (ie committee) are defined
|
||||
@ -610,27 +549,27 @@ func NewApp(
|
||||
govRouter.
|
||||
AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
|
||||
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
|
||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.upgradeKeeper)).
|
||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper)).
|
||||
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper)).
|
||||
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)).
|
||||
AddRoute(committeetypes.RouterKey, committee.NewProposalHandler(app.committeeKeeper))
|
||||
|
||||
govConfig := govtypes.DefaultConfig()
|
||||
govKeeper := govkeeper.NewKeeper(
|
||||
app.govKeeper = govkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[govtypes.StoreKey],
|
||||
govSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
app.stakingKeeper,
|
||||
&app.stakingKeeper,
|
||||
govRouter,
|
||||
app.MsgServiceRouter(),
|
||||
govConfig,
|
||||
govAuthAddrStr,
|
||||
)
|
||||
govKeeper.SetLegacyRouter(govRouter)
|
||||
app.govKeeper = *govKeeper
|
||||
|
||||
// override x/gov tally handler with custom implementation
|
||||
tallyHandler := NewTallyHandler(
|
||||
app.govKeeper, *app.stakingKeeper, app.bankKeeper,
|
||||
app.govKeeper, app.stakingKeeper, app.bankKeeper,
|
||||
)
|
||||
app.govKeeper.SetTallyHandler(tallyHandler)
|
||||
|
||||
@ -642,24 +581,22 @@ func NewApp(
|
||||
// must be passed by reference here.)
|
||||
app.mm = module.NewManager(
|
||||
genutil.NewAppModule(app.accountKeeper, app.stakingKeeper, app.BaseApp.DeliverTx, encodingConfig.TxConfig),
|
||||
auth.NewAppModule(appCodec, app.accountKeeper, authsims.RandomGenesisAccounts, authSubspace),
|
||||
bank.NewAppModule(appCodec, app.bankKeeper, app.accountKeeper, bankSubspace),
|
||||
capability.NewAppModule(appCodec, *app.capabilityKeeper, false), // todo: confirm if this is okay to not be sealed
|
||||
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper, stakingSubspace),
|
||||
distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper, distrSubspace),
|
||||
gov.NewAppModule(appCodec, &app.govKeeper, app.accountKeeper, app.bankKeeper, govSubspace),
|
||||
auth.NewAppModule(appCodec, app.accountKeeper, nil),
|
||||
bank.NewAppModule(appCodec, app.bankKeeper, app.accountKeeper),
|
||||
capability.NewAppModule(appCodec, *app.capabilityKeeper),
|
||||
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
|
||||
distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
|
||||
gov.NewAppModule(appCodec, app.govKeeper, app.accountKeeper, app.bankKeeper),
|
||||
params.NewAppModule(app.paramsKeeper),
|
||||
crisis.NewAppModule(&app.crisisKeeper, options.SkipGenesisInvariants, crisisSubspace),
|
||||
slashing.NewAppModule(appCodec, app.slashingKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper, slashingSubspace),
|
||||
consensus.NewAppModule(appCodec, app.consensusParamsKeeper),
|
||||
crisis.NewAppModule(&app.crisisKeeper, options.SkipGenesisInvariants),
|
||||
slashing.NewAppModule(appCodec, app.slashingKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
|
||||
ibc.NewAppModule(app.ibcKeeper),
|
||||
packetforward.NewAppModule(app.packetForwardKeeper, packetforwardSubspace),
|
||||
evm.NewAppModule(app.evmKeeper, app.accountKeeper),
|
||||
feemarket.NewAppModule(app.feeMarketKeeper, feemarketSubspace),
|
||||
upgrade.NewAppModule(&app.upgradeKeeper),
|
||||
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),
|
||||
@ -668,8 +605,9 @@ func NewApp(
|
||||
committee.NewAppModule(app.committeeKeeper, app.accountKeeper),
|
||||
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),
|
||||
ibcwasm.NewAppModule(app.ibcWasmClientKeeper),
|
||||
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, chaincfg.NextInflationRate),
|
||||
council.NewAppModule(app.CouncilKeeper, app.stakingKeeper),
|
||||
dasigners.NewAppModule(app.dasignersKeeper, app.stakingKeeper),
|
||||
)
|
||||
|
||||
// Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
@ -697,7 +635,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,
|
||||
ibcexported.ModuleName,
|
||||
ibchost.ModuleName,
|
||||
// Add all remaining modules with an empty begin blocker below since cosmos 0.45.0 requires it
|
||||
vestingtypes.ModuleName,
|
||||
pricefeedtypes.ModuleName,
|
||||
@ -711,9 +649,9 @@ func NewApp(
|
||||
paramstypes.ModuleName,
|
||||
authz.ModuleName,
|
||||
evmutiltypes.ModuleName,
|
||||
consensusparamtypes.ModuleName,
|
||||
packetforwardtypes.ModuleName,
|
||||
ibcwasmtypes.ModuleName,
|
||||
|
||||
counciltypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
)
|
||||
|
||||
// Warning: Some end blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
@ -735,7 +673,7 @@ func NewApp(
|
||||
upgradetypes.ModuleName,
|
||||
evidencetypes.ModuleName,
|
||||
vestingtypes.ModuleName,
|
||||
ibcexported.ModuleName,
|
||||
ibchost.ModuleName,
|
||||
validatorvestingtypes.ModuleName,
|
||||
authtypes.ModuleName,
|
||||
banktypes.ModuleName,
|
||||
@ -745,9 +683,8 @@ func NewApp(
|
||||
authz.ModuleName,
|
||||
evmutiltypes.ModuleName,
|
||||
minttypes.ModuleName,
|
||||
consensusparamtypes.ModuleName,
|
||||
packetforwardtypes.ModuleName,
|
||||
ibcwasmtypes.ModuleName,
|
||||
counciltypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
)
|
||||
|
||||
// Warning: Some init genesis methods must run before others. Ensure the dependencies are understood before modifying this list
|
||||
@ -760,7 +697,7 @@ func NewApp(
|
||||
slashingtypes.ModuleName, // iterates over validators, run after staking
|
||||
govtypes.ModuleName,
|
||||
minttypes.ModuleName,
|
||||
ibcexported.ModuleName,
|
||||
ibchost.ModuleName,
|
||||
evidencetypes.ModuleName,
|
||||
authz.ModuleName,
|
||||
ibctransfertypes.ModuleName,
|
||||
@ -772,18 +709,18 @@ func NewApp(
|
||||
committeetypes.ModuleName,
|
||||
evmutiltypes.ModuleName,
|
||||
genutiltypes.ModuleName, // runs arbitrary txs included in genisis state, so run after modules have been initialized
|
||||
crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules
|
||||
// Add all remaining modules with an empty InitGenesis below since cosmos 0.45.0 requires it
|
||||
vestingtypes.ModuleName,
|
||||
paramstypes.ModuleName,
|
||||
upgradetypes.ModuleName,
|
||||
validatorvestingtypes.ModuleName,
|
||||
consensusparamtypes.ModuleName,
|
||||
packetforwardtypes.ModuleName,
|
||||
crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules
|
||||
ibcwasmtypes.ModuleName,
|
||||
counciltypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
)
|
||||
|
||||
app.mm.RegisterInvariants(&app.crisisKeeper)
|
||||
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
|
||||
|
||||
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
|
||||
app.RegisterServices(app.configurator)
|
||||
@ -855,15 +792,6 @@ func NewApp(
|
||||
}
|
||||
}
|
||||
|
||||
if manager := app.SnapshotManager(); manager != nil {
|
||||
err := manager.RegisterExtensions(
|
||||
ibcwasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.ibcWasmClientKeeper),
|
||||
)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
|
||||
}
|
||||
}
|
||||
|
||||
app.ScopedIBCKeeper = scopedIBCKeeper
|
||||
app.ScopedTransferKeeper = scopedTransferKeeper
|
||||
|
||||
|
@ -3,26 +3,22 @@ package app
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
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"
|
||||
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"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
db "github.com/tendermint/tm-db"
|
||||
"os"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
db "github.com/cometbft/cometbft-db"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cometbft/cometbft/libs/log"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
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"
|
||||
)
|
||||
|
||||
func TestNewApp(t *testing.T) {
|
||||
@ -40,7 +36,7 @@ func TestNewApp(t *testing.T) {
|
||||
func TestExport(t *testing.T) {
|
||||
chaincfg.SetSDKConfig()
|
||||
db := db.NewMemDB()
|
||||
app := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, chaincfg.DefaultNodeHome, nil, MakeEncodingConfig(), DefaultOptions, baseapp.SetChainID(TestChainId))
|
||||
app := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, chaincfg.DefaultNodeHome, nil, MakeEncodingConfig(), DefaultOptions)
|
||||
|
||||
genesisState := GenesisStateWithSingleValidator(&TestApp{App: *app}, NewDefaultGenesisState())
|
||||
|
||||
@ -49,23 +45,21 @@ func TestExport(t *testing.T) {
|
||||
|
||||
initRequest := abci.RequestInitChain{
|
||||
Time: time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
ChainId: TestChainId,
|
||||
ChainId: "kavatest_1-1",
|
||||
InitialHeight: 1,
|
||||
ConsensusParams: sims.DefaultConsensusParams,
|
||||
ConsensusParams: tmtypes.TM2PB.ConsensusParams(tmtypes.DefaultConsensusParams()),
|
||||
Validators: nil,
|
||||
AppStateBytes: stateBytes,
|
||||
}
|
||||
app.InitChain(initRequest)
|
||||
app.Commit()
|
||||
|
||||
exportedApp, err := app.ExportAppStateAndValidators(false, []string{}, []string{})
|
||||
exportedApp, err := app.ExportAppStateAndValidators(false, []string{})
|
||||
require.NoError(t, err)
|
||||
|
||||
// Assume each module is exported correctly, so only check modules in genesis are present in export
|
||||
initialModules, err := unmarshalJSONKeys(initRequest.AppStateBytes)
|
||||
require.NoError(t, err)
|
||||
// note ibctm is only registered in the BasicManager and not module manager so can be ignored
|
||||
initialModules = removeIbcTmModule(initialModules)
|
||||
exportedModules, err := unmarshalJSONKeys(exportedApp.AppState)
|
||||
require.NoError(t, err)
|
||||
assert.ElementsMatch(t, initialModules, exportedModules)
|
||||
@ -149,13 +143,3 @@ func unmarshalJSONKeys(jsonBytes []byte) ([]string, error) {
|
||||
|
||||
return keys, nil
|
||||
}
|
||||
|
||||
func removeIbcTmModule(modules []string) []string {
|
||||
var result []string
|
||||
for _, str := range modules {
|
||||
if str != ibctm.ModuleName && str != solomachine.ModuleName {
|
||||
result = append(result, str)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
|
||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
// ExportAppStateAndValidators export the state of the app for a genesis file
|
||||
func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []string, modulesToExport []string,
|
||||
func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []string,
|
||||
) (servertypes.ExportedApp, error) {
|
||||
// as if they could withdraw from the start of the next block
|
||||
// block time is not available and defaults to Jan 1st, 0001
|
||||
@ -26,7 +26,7 @@ func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []
|
||||
app.prepForZeroHeightGenesis(ctx, jailWhiteList)
|
||||
}
|
||||
|
||||
genState := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
|
||||
genState := app.mm.ExportGenesis(ctx, app.appCodec)
|
||||
newAppState, err := json.MarshalIndent(genState, "", " ")
|
||||
if err != nil {
|
||||
return servertypes.ExportedApp{}, err
|
||||
|
@ -143,7 +143,7 @@ func (th TallyHandler) Tally(
|
||||
totalVotingPower = totalVotingPower.Add(votingPower)
|
||||
}
|
||||
|
||||
tallyParams := th.gk.GetParams(ctx)
|
||||
tallyParams := th.gk.GetTallyParams(ctx)
|
||||
tallyResults = govv1.NewTallyResultFromMap(results)
|
||||
|
||||
// TODO: Upgrade the spec to cover all of these cases & remove pseudocode.
|
||||
@ -155,7 +155,7 @@ func (th TallyHandler) Tally(
|
||||
// If there is not enough quorum of votes, the proposal fails
|
||||
percentVoting := totalVotingPower.Quo(sdk.NewDecFromInt(th.stk.TotalBondedTokens(ctx)))
|
||||
if percentVoting.LT(sdk.MustNewDecFromStr(tallyParams.Quorum)) {
|
||||
return false, tallyParams.BurnVoteQuorum, tallyResults
|
||||
return false, true, tallyResults
|
||||
}
|
||||
|
||||
// If no one votes (everyone abstains), proposal fails
|
||||
@ -165,7 +165,7 @@ func (th TallyHandler) Tally(
|
||||
|
||||
// If more than 1/3 of voters veto, proposal fails
|
||||
if results[govv1.OptionNoWithVeto].Quo(totalVotingPower).GT(sdk.MustNewDecFromStr(tallyParams.VetoThreshold)) {
|
||||
return false, tallyParams.BurnVoteVeto, tallyResults
|
||||
return false, true, tallyResults
|
||||
}
|
||||
|
||||
// If more than 1/2 of non-abstaining voters vote Yes, proposal passes
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"time"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@ -16,6 +15,7 @@ import (
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
)
|
||||
|
||||
// d is an alias for sdk.MustNewDecFromStr
|
||||
@ -41,16 +41,12 @@ func (suite *tallyHandlerSuite) SetupTest() {
|
||||
genesisTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
suite.ctx = suite.app.NewContext(false, tmproto.Header{Height: 1, Time: genesisTime})
|
||||
|
||||
stakingKeeper := *suite.app.GetStakingKeeper()
|
||||
suite.staking = stakingHelper{stakingKeeper}
|
||||
suite.staking = stakingHelper{suite.app.GetStakingKeeper()}
|
||||
suite.staking.setBondDenom(suite.ctx, "ukava")
|
||||
|
||||
suite.tallier = NewTallyHandler(
|
||||
suite.app.GetGovKeeper(),
|
||||
stakingKeeper,
|
||||
suite.app.GetSavingsKeeper(),
|
||||
suite.app.GetEarnKeeper(),
|
||||
suite.app.GetLiquidKeeper(),
|
||||
suite.app.GetStakingKeeper(),
|
||||
suite.app.GetBankKeeper(),
|
||||
)
|
||||
}
|
||||
@ -213,12 +209,11 @@ func (suite *tallyHandlerSuite) TestTallyOutcomes() {
|
||||
}
|
||||
|
||||
func (suite *tallyHandlerSuite) setTallyParams(quorum, threshold, veto sdk.Dec) {
|
||||
params := suite.app.GetGovKeeper().GetParams(suite.ctx)
|
||||
params.Quorum = quorum.String()
|
||||
params.Threshold = threshold.String()
|
||||
params.VetoThreshold = veto.String()
|
||||
params.BurnVoteQuorum = true
|
||||
suite.app.GetGovKeeper().SetParams(suite.ctx, params)
|
||||
suite.app.GetGovKeeper().SetTallyParams(suite.ctx, govv1.TallyParams{
|
||||
Quorum: quorum.String(),
|
||||
Threshold: threshold.String(),
|
||||
VetoThreshold: veto.String(),
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *tallyHandlerSuite) voteOnProposal(
|
||||
@ -239,7 +234,7 @@ func (suite *tallyHandlerSuite) voteOnProposal(
|
||||
|
||||
func (suite *tallyHandlerSuite) createProposal() govv1.Proposal {
|
||||
gk := suite.app.GetGovKeeper()
|
||||
deposit := gk.GetParams(suite.ctx).MinDeposit
|
||||
deposit := gk.GetDepositParams(suite.ctx).MinDeposit
|
||||
proposer := suite.createAccount(deposit...)
|
||||
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(
|
||||
@ -249,7 +244,7 @@ func (suite *tallyHandlerSuite) createProposal() govv1.Proposal {
|
||||
)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
msgServerv1 := govkeeper.NewMsgServerImpl(&gk)
|
||||
msgServerv1 := govkeeper.NewMsgServerImpl(gk)
|
||||
|
||||
govAcct := gk.GetGovernanceAccount(suite.ctx).GetAddress()
|
||||
msgServer := govkeeper.NewLegacyMsgServerImpl(govAcct.String(), msgServerv1)
|
||||
@ -369,7 +364,7 @@ func (h stakingHelper) createUnbondedValidator(ctx sdk.Context, address sdk.ValA
|
||||
return nil, err
|
||||
}
|
||||
|
||||
msgServer := stakingkeeper.NewMsgServerImpl(&h.keeper)
|
||||
msgServer := stakingkeeper.NewMsgServerImpl(h.keeper)
|
||||
_, err = msgServer.CreateValidator(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -389,7 +384,7 @@ func (h stakingHelper) delegate(ctx sdk.Context, delegator sdk.AccAddress, valid
|
||||
h.newBondCoin(ctx, amount),
|
||||
)
|
||||
|
||||
msgServer := stakingkeeper.NewMsgServerImpl(&h.keeper)
|
||||
msgServer := stakingkeeper.NewMsgServerImpl(h.keeper)
|
||||
_, err := msgServer.Delegate(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return sdk.Dec{}, err
|
||||
|
@ -9,11 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
tmdb "github.com/cometbft/cometbft-db"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cometbft/cometbft/libs/log"
|
||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
tmtypes "github.com/cometbft/cometbft/types"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@ -40,6 +35,11 @@ import (
|
||||
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
|
||||
feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper"
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
tmdb "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
bep3keeper "github.com/0glabs/0g-chain/x/bep3/keeper"
|
||||
@ -51,11 +51,10 @@ import (
|
||||
|
||||
var (
|
||||
emptyTime time.Time
|
||||
testChainID = "kavatest_1-1"
|
||||
defaultInitialHeight int64 = 1
|
||||
)
|
||||
|
||||
const TestChainId = "kavatest_2221-1"
|
||||
|
||||
// TestApp is a simple wrapper around an App. It exposes internal keepers for use in integration tests.
|
||||
// This file also contains test helpers. Ideally they would be in separate package.
|
||||
// Basic Usage:
|
||||
@ -90,10 +89,7 @@ func NewTestAppFromSealed() TestApp {
|
||||
|
||||
encCfg := MakeEncodingConfig()
|
||||
|
||||
app := NewApp(
|
||||
log.NewNopLogger(), db, chaincfg.DefaultNodeHome, nil,
|
||||
encCfg, DefaultOptions, baseapp.SetChainID(TestChainId),
|
||||
)
|
||||
app := NewApp(log.NewNopLogger(), db, chaincfg.DefaultNodeHome, nil, encCfg, DefaultOptions)
|
||||
return TestApp{App: *app}
|
||||
}
|
||||
|
||||
@ -101,7 +97,7 @@ func NewTestAppFromSealed() TestApp {
|
||||
func (tApp TestApp) GetAccountKeeper() authkeeper.AccountKeeper { return tApp.accountKeeper }
|
||||
func (tApp TestApp) GetBankKeeper() bankkeeper.Keeper { return tApp.bankKeeper }
|
||||
func (tApp TestApp) GetMintKeeper() mintkeeper.Keeper { return tApp.mintKeeper }
|
||||
func (tApp TestApp) GetStakingKeeper() *stakingkeeper.Keeper { return tApp.stakingKeeper }
|
||||
func (tApp TestApp) GetStakingKeeper() stakingkeeper.Keeper { return tApp.stakingKeeper }
|
||||
func (tApp TestApp) GetSlashingKeeper() slashingkeeper.Keeper { return tApp.slashingKeeper }
|
||||
func (tApp TestApp) GetDistrKeeper() distkeeper.Keeper { return tApp.distrKeeper }
|
||||
func (tApp TestApp) GetGovKeeper() govkeeper.Keeper { return tApp.govKeeper }
|
||||
@ -250,7 +246,6 @@ func genesisStateWithValSet(
|
||||
balances,
|
||||
totalSupply,
|
||||
currentBankGenesis.DenomMetadata,
|
||||
currentBankGenesis.SendEnabled,
|
||||
)
|
||||
|
||||
// set genesis state
|
||||
@ -264,13 +259,13 @@ func genesisStateWithValSet(
|
||||
// InitializeFromGenesisStates calls InitChain on the app using the provided genesis states.
|
||||
// If any module genesis states are missing, defaults are used.
|
||||
func (tApp TestApp) InitializeFromGenesisStates(genesisStates ...GenesisState) TestApp {
|
||||
return tApp.InitializeFromGenesisStatesWithTimeAndChainIDAndHeight(emptyTime, TestChainId, defaultInitialHeight, true, genesisStates...)
|
||||
return tApp.InitializeFromGenesisStatesWithTimeAndChainIDAndHeight(emptyTime, testChainID, defaultInitialHeight, true, genesisStates...)
|
||||
}
|
||||
|
||||
// InitializeFromGenesisStatesWithTime calls InitChain on the app using the provided genesis states and time.
|
||||
// If any module genesis states are missing, defaults are used.
|
||||
func (tApp TestApp) InitializeFromGenesisStatesWithTime(genTime time.Time, genesisStates ...GenesisState) TestApp {
|
||||
return tApp.InitializeFromGenesisStatesWithTimeAndChainIDAndHeight(genTime, TestChainId, defaultInitialHeight, true, genesisStates...)
|
||||
return tApp.InitializeFromGenesisStatesWithTimeAndChainIDAndHeight(genTime, testChainID, defaultInitialHeight, true, genesisStates...)
|
||||
}
|
||||
|
||||
// InitializeFromGenesisStatesWithTimeAndChainID calls InitChain on the app using the provided genesis states, time, and chain id.
|
||||
@ -327,8 +322,8 @@ func (tApp TestApp) InitializeFromGenesisStatesWithTimeAndChainIDAndHeight(
|
||||
AppStateBytes: stateBytes,
|
||||
ChainId: chainID,
|
||||
// Set consensus params, which is needed by x/feemarket
|
||||
ConsensusParams: &tmproto.ConsensusParams{
|
||||
Block: &tmproto.BlockParams{
|
||||
ConsensusParams: &abci.ConsensusParams{
|
||||
Block: &abci.BlockParams{
|
||||
MaxBytes: 200000,
|
||||
MaxGas: 20000000,
|
||||
},
|
||||
|
277
app/upgrades.go
277
app/upgrades.go
@ -3,55 +3,87 @@ 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"
|
||||
ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/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_Testnet = "v0.3.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_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 {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
doUpgrade := upgradeInfo.Name == UpgradeName_Testnet
|
||||
doUpgrade := upgradeInfo.Name == UpgradeName_Mainnet ||
|
||||
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,
|
||||
ibcwasmtypes.ModuleName,
|
||||
// x/community added store
|
||||
// communitytypes.ModuleName,
|
||||
},
|
||||
}
|
||||
|
||||
@ -64,6 +96,7 @@ func (app App) RegisterUpgradeHandlers() {
|
||||
func upgradeHandler(
|
||||
app App,
|
||||
name string,
|
||||
// communityParams communitytypes.Params,
|
||||
) upgradetypes.UpgradeHandler {
|
||||
return func(
|
||||
ctx sdk.Context,
|
||||
@ -72,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
|
||||
}
|
@ -28,9 +28,9 @@ DIRS := $(BUILD_CACHE_DIR) $(BIN_DIR)
|
||||
### Tool Versions ###
|
||||
################################################################################
|
||||
GO_BIN ?= go
|
||||
PROTOC_VERSION ?= v25.1
|
||||
BUF_VERSION ?= v1.28.1
|
||||
PROTOC_GEN_GOCOSMOS_VERSION ?= $(shell $(GO_BIN) list -m -f '{{.Version}}' github.com/cosmos/gogoproto)
|
||||
PROTOC_VERSION ?= v21.9
|
||||
BUF_VERSION ?= v1.9.0
|
||||
PROTOC_GEN_GOCOSMOS_VERSION ?= v0.3.1
|
||||
PROTOC_GEN_GRPC_GATEWAY_VERSION ?= $(shell $(GO_BIN) list -m github.com/grpc-ecosystem/grpc-gateway| sed 's:.* ::')
|
||||
PROTOC_GEN_DOC_VERSION ?= v1.5.1
|
||||
SWAGGER_COMBINE_VERSION ?= v1.4.0
|
||||
@ -68,7 +68,7 @@ $(PROTOC_VERSION_FILE):
|
||||
mkdir -p protoc && cd protoc; \
|
||||
curl -sOL $(PROTOC_DOWNLOAD_URL); \
|
||||
unzip -q $(PROTOC_ARCHIVE_NAME) bin/protoc
|
||||
@cp -f $(BUILD_CACHE_DIR)/protoc/bin/protoc $(BIN_DIR)/protoc
|
||||
@cp $(BUILD_CACHE_DIR)/protoc/bin/protoc $(BIN_DIR)/protoc
|
||||
@rm -rf $(BUILD_CACHE_DIR)/protoc
|
||||
|
||||
PROTOC := $(BIN_DIR)/protoc
|
||||
@ -93,7 +93,7 @@ $(BUF_VERSION_FILE):
|
||||
mkdir -p buf && cd buf; \
|
||||
curl -sOL $(BUF_DOWNLOAD_URL); \
|
||||
tar -xzf $(BUF_ARCHIVE_NAME) buf/bin/buf
|
||||
@cp -f $(BUILD_CACHE_DIR)/buf/buf/bin/buf $(BIN_DIR)/buf
|
||||
@cp $(BUILD_CACHE_DIR)/buf/buf/bin/buf $(BIN_DIR)/buf
|
||||
@rm -rf $(BUILD_CACHE_DIR)/buf
|
||||
|
||||
BUF := $(BIN_DIR)/buf
|
||||
@ -113,8 +113,8 @@ $(PROTOC_GEN_GOCOSMOS_VERSION_FILE):
|
||||
@touch $(PROTOC_GEN_GOCOSMOS_VERSION_FILE)
|
||||
@cd $(BUILD_CACHE_DIR); \
|
||||
mkdir -p protoc-gen-gocosmos && cd protoc-gen-gocosmos; \
|
||||
git clone -q https://github.com/cosmos/gogoproto.git; \
|
||||
cd gogoproto; \
|
||||
git clone -q https://github.com/regen-network/cosmos-proto.git; \
|
||||
cd cosmos-proto; \
|
||||
git checkout -q $(PROTOC_GEN_GOCOSMOS_VERSION); \
|
||||
GOBIN=$(ROOT_DIR)/$(BIN_DIR) $(GO_BIN) install ./protoc-gen-gocosmos
|
||||
@rm -rf $(BUILD_CACHE_DIR)/protoc-gen-gocosmos
|
||||
@ -185,7 +185,7 @@ $(PROTOC_GEN_DOC_VERSION_FILE):
|
||||
mkdir -p protoc-gen-doc && cd protoc-gen-doc; \
|
||||
curl -sOL $(PROTOC_GEN_DOC_DOWNLOAD_URL); \
|
||||
tar -xzf $(PROTOC_GEN_DOC_ARCHIVE_NAME) protoc-gen-doc
|
||||
@cp -f $(BUILD_CACHE_DIR)/protoc-gen-doc/protoc-gen-doc $(BIN_DIR)/protoc-gen-doc
|
||||
@cp $(BUILD_CACHE_DIR)/protoc-gen-doc/protoc-gen-doc $(BIN_DIR)/protoc-gen-doc
|
||||
@rm -rf $(BUILD_CACHE_DIR)/protoc-gen-doc
|
||||
|
||||
PROTOC_GEN_DOC := $(BIN_DIR)/protoc-gen-doc
|
||||
|
@ -14,23 +14,13 @@ PROTOBUF_ANY_DOWNLOAD_URL = https://raw.githubusercontent.com/protocolbuffers/pr
|
||||
#
|
||||
# Proto dependencies under go.mod
|
||||
#
|
||||
GOGO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/gogoproto)
|
||||
TENDERMINT_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cometbft/cometbft)
|
||||
GOGO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/gogo/protobuf)
|
||||
TENDERMINT_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/tendermint/tendermint)
|
||||
COSMOS_PROTO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/cosmos-proto)
|
||||
COSMOS_SDK_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/cosmos-sdk)
|
||||
IBC_GO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/ibc-go/v7)
|
||||
IBC_GO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/ibc-go/v6)
|
||||
ETHERMINT_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/evmos/ethermint)
|
||||
|
||||
#
|
||||
# ICS23 Proof Proto
|
||||
#
|
||||
ICS23_VERSION := $(shell $(GO_BIN) list -m -f '{{.Version}}' github.com/cosmos/ics23/go)
|
||||
|
||||
ICS23_PROOFS_PROTO_PATH := cosmos/ics23/v1/proofs.proto
|
||||
ICS23_PROOFS_PROTO_LOCAL_PATH := third_party/proto/$(ICS23_PROOFS_PROTO_PATH)
|
||||
|
||||
ICS23_PROOFS_PROTO_DOWNLOAD_URL := https://raw.githubusercontent.com/cosmos/ics23/go/$(ICS23_VERSION)/proto/$(ICS23_PROOFS_PROTO_PATH)
|
||||
|
||||
#
|
||||
# Common target directories
|
||||
#
|
||||
@ -54,20 +44,18 @@ proto-update-deps: check-rsync ## Update all third party proto files
|
||||
@curl -sSL $(PROTOBUF_ANY_DOWNLOAD_URL)/any.proto > $(PROTOBUF_GOOGLE_TYPES)/any.proto
|
||||
|
||||
@mkdir -p client/docs
|
||||
@cp -f $(COSMOS_SDK_PATH)/client/docs/swagger-ui/swagger.yaml client/docs/cosmos-swagger.yml
|
||||
@cp -f $(IBC_GO_PATH)/docs/client/swagger-ui/swagger.yaml client/docs/ibc-go-swagger.yml
|
||||
@cp $(COSMOS_SDK_PATH)/client/docs/swagger-ui/swagger.yaml client/docs/cosmos-swagger.yml
|
||||
@cp $(IBC_GO_PATH)/docs/client/swagger-ui/swagger.yaml client/docs/ibc-go-swagger.yml
|
||||
|
||||
@mkdir -p $(COSMOS_PROTO_TYPES)
|
||||
@cp -f $(COSMOS_PROTO_PATH)/proto/cosmos_proto/cosmos.proto $(COSMOS_PROTO_TYPES)/cosmos.proto
|
||||
|
||||
@mkdir -p $(dir $(ICS23_PROOFS_PROTO_LOCAL_PATH))
|
||||
@curl -sSL $(ICS23_PROOFS_PROTO_DOWNLOAD_URL) > $(ICS23_PROOFS_PROTO_LOCAL_PATH)
|
||||
@cp $(COSMOS_PROTO_PATH)/proto/cosmos_proto/cosmos.proto $(COSMOS_PROTO_TYPES)/cosmos.proto
|
||||
|
||||
@$(RSYNC_BIN) -r --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --include "*.proto" --include='*/' --exclude='*' $(GOGO_PATH)/gogoproto third_party/proto
|
||||
@$(RSYNC_BIN) -r --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --include "*.proto" --include='*/' --exclude='*' $(TENDERMINT_PATH)/proto third_party
|
||||
@$(RSYNC_BIN) -r --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --include "*.proto" --include='*/' --exclude='*' $(COSMOS_SDK_PATH)/proto third_party
|
||||
@$(RSYNC_BIN) -r --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --include "*.proto" --include='*/' --exclude='*' $(IBC_GO_PATH)/proto third_party
|
||||
@$(RSYNC_BIN) -r --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --include "*.proto" --include='*/' --exclude='*' $(ETHERMINT_PATH)/proto third_party
|
||||
@cp -f $(IBC_GO_PATH)/third_party/proto/proofs.proto third_party/proto/proofs.proto
|
||||
|
||||
.PHONY: check-proto-deps
|
||||
check-proto-deps: proto-update-deps ## Return error code 1 if proto dependencies are not changed
|
||||
|
@ -1,7 +1,7 @@
|
||||
.PHONY: proto-lint check-proto-lint
|
||||
proto-lint check-proto-lint: install-build-deps
|
||||
@echo "Linting proto file"
|
||||
@$(BUF) lint proto
|
||||
@$(BUF) lint
|
||||
|
||||
.PHONY: proto-gen
|
||||
proto-gen: install-build-deps
|
||||
|
@ -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"
|
||||
|
24
ci/env/kava-protonet/genesis.json
vendored
24
ci/env/kava-protonet/genesis.json
vendored
@ -837,7 +837,6 @@
|
||||
"gov_denom": "ukava",
|
||||
"params": {
|
||||
"circuit_breaker": false,
|
||||
"liquidation_block_interval": 500,
|
||||
"collateral_params": [
|
||||
{
|
||||
"auction_size": "50000000000",
|
||||
@ -2178,23 +2177,6 @@
|
||||
"quorum": "0.334000000000000000",
|
||||
"threshold": "0.500000000000000000",
|
||||
"veto_threshold": "0.334000000000000000"
|
||||
},
|
||||
"params": {
|
||||
"min_deposit": [
|
||||
{
|
||||
"denom": "ukava",
|
||||
"amount": "10000000"
|
||||
}
|
||||
],
|
||||
"max_deposit_period": "172800s",
|
||||
"voting_period": "600s",
|
||||
"quorum": "0.334000000000000000",
|
||||
"threshold": "0.500000000000000000",
|
||||
"veto_threshold": "0.334000000000000000",
|
||||
"min_initial_deposit_ratio": "0.000000000000000000",
|
||||
"burn_vote_quorum": false,
|
||||
"burn_proposal_deposit_prevote": false,
|
||||
"burn_vote_veto": true
|
||||
}
|
||||
},
|
||||
"hard": {
|
||||
@ -3000,12 +2982,6 @@
|
||||
}
|
||||
},
|
||||
"params": null,
|
||||
"packetfowardmiddleware": {
|
||||
"params": {
|
||||
"fee_percentage": "0.000000000000000000"
|
||||
},
|
||||
"in_flight_packets": {}
|
||||
},
|
||||
"pricefeed": {
|
||||
"params": {
|
||||
"markets": [
|
||||
|
@ -14,9 +14,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cometbft/cometbft/crypto/ed25519"
|
||||
tmtypes "github.com/cometbft/cometbft/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/tests"
|
||||
@ -813,7 +813,7 @@ func TestKvCLISubmitCommunityPoolSpendProposal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKvCLIQueryTxPagination(t *testing.T) {
|
||||
// Skip until https://github.com/cometbft/cometbft/issues/4432 has been
|
||||
// Skip until https://github.com/tendermint/tendermint/issues/4432 has been
|
||||
// resolved and included in a release.
|
||||
t.SkipNow()
|
||||
|
||||
|
@ -13,13 +13,13 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
tmtypes "github.com/cometbft/cometbft/types"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/tests"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,74 +0,0 @@
|
||||
# Kava gRPC Client
|
||||
|
||||
The Kava gRPC client is a tool for making gRPC queries on a Kava chain.
|
||||
|
||||
## Features
|
||||
|
||||
- Easy-to-use gRPC client for the Kava chain.
|
||||
- Access all query clients for Cosmos and Kava modules using `client.Query` (e.g., `client.Query.Bank.Balance`).
|
||||
- Utilize utility functions for common queries (e.g., `client.BaseAccount(str)`).
|
||||
|
||||
## Usage
|
||||
|
||||
### Creating a new client
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
kavaGrpc "github.com/0glabs/0g-chain/client/grpc"
|
||||
)
|
||||
grpcUrl := "https://grpc.kava.io:443"
|
||||
client, err := kavaGrpc.NewClient(grpcUrl)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
### Making grpc queries
|
||||
|
||||
Query clients for both Cosmos and Kava modules are available via `client.Query`.
|
||||
|
||||
Example: Query Cosmos module `x/bank` for address balance
|
||||
|
||||
```go
|
||||
import (
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
rsp, err := client.Query.Bank.Balance(context.Background(), &banktypes.QueryBalanceRequest{
|
||||
Address: "kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
Denom: "ukava",
|
||||
})
|
||||
```
|
||||
|
||||
Example: Query Kava module `x/evmutil` for params
|
||||
|
||||
```go
|
||||
import (
|
||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
)
|
||||
|
||||
rsp, err := client.Query.Evmutil.Params(
|
||||
context.Background(), &evmutiltypes.QueryParamsRequest{},
|
||||
)
|
||||
```
|
||||
|
||||
#### Query Utilities
|
||||
|
||||
Utility functions for common queries are available directly on the client.
|
||||
|
||||
Example: Util query to get a base account
|
||||
|
||||
```go
|
||||
kavaAcc := "kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92"
|
||||
rsp, err := client.BaseAccount(kavaAcc)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("account sequence for %s: %d\n", kavaAcc, rsp.Sequence)
|
||||
```
|
||||
|
||||
## Query Tests
|
||||
|
||||
To test queries, a Kava node is required. Therefore, the e2e tests for the gRPC client queries can be found in the `tests/e2e` directory. Tests for new utility queries should be added as e2e tests under the `test/e2e` directory.
|
@ -1,50 +0,0 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/0glabs/0g-chain/client/grpc/query"
|
||||
"github.com/0glabs/0g-chain/client/grpc/util"
|
||||
)
|
||||
|
||||
// KavaGrpcClient enables the usage of kava grpc query clients and query utils
|
||||
type KavaGrpcClient struct {
|
||||
config KavaGrpcClientConfig
|
||||
|
||||
// Query clients for cosmos and kava modules
|
||||
Query *query.QueryClient
|
||||
|
||||
// Utils for common queries (ie fetch an unpacked BaseAccount)
|
||||
*util.Util
|
||||
}
|
||||
|
||||
// KavaGrpcClientConfig is a configuration struct for a KavaGrpcClient
|
||||
type KavaGrpcClientConfig struct {
|
||||
// note: add future config options here
|
||||
}
|
||||
|
||||
// NewClient creates a new KavaGrpcClient via a grpc url
|
||||
func NewClient(grpcUrl string) (*KavaGrpcClient, error) {
|
||||
return NewClientWithConfig(grpcUrl, NewDefaultConfig())
|
||||
}
|
||||
|
||||
// NewClientWithConfig creates a new KavaGrpcClient via a grpc url and config
|
||||
func NewClientWithConfig(grpcUrl string, config KavaGrpcClientConfig) (*KavaGrpcClient, error) {
|
||||
if grpcUrl == "" {
|
||||
return nil, errors.New("grpc url cannot be empty")
|
||||
}
|
||||
query, error := query.NewQueryClient(grpcUrl)
|
||||
if error != nil {
|
||||
return nil, error
|
||||
}
|
||||
client := &KavaGrpcClient{
|
||||
Query: query,
|
||||
Util: util.NewUtil(query),
|
||||
config: config,
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func NewDefaultConfig() KavaGrpcClientConfig {
|
||||
return KavaGrpcClientConfig{}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package grpc_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/0glabs/0g-chain/client/grpc"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewClient_InvalidEndpoint(t *testing.T) {
|
||||
_, err := grpc.NewClient("invalid-url")
|
||||
require.ErrorContains(t, err, "unknown grpc url scheme")
|
||||
_, err = grpc.NewClient("")
|
||||
require.ErrorContains(t, err, "grpc url cannot be empty")
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
/*
|
||||
The query package includes Cosmos and Kava gRPC query clients.
|
||||
|
||||
To ensure that the `QueryClient` stays updated, add new module query clients
|
||||
to the `QueryClient` whenever new modules with grpc queries are added to the Kava app.
|
||||
*/
|
||||
package query
|
@ -1,125 +0,0 @@
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
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"
|
||||
govv1beta1types "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
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"
|
||||
|
||||
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
|
||||
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
|
||||
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"
|
||||
)
|
||||
|
||||
// QueryClient is a wrapper with all Cosmos and Kava grpc query clients
|
||||
type QueryClient struct {
|
||||
// cosmos-sdk query clients
|
||||
|
||||
Tm tmservice.ServiceClient
|
||||
Tx txtypes.ServiceClient
|
||||
Auth authtypes.QueryClient
|
||||
Authz authz.QueryClient
|
||||
Bank banktypes.QueryClient
|
||||
Distribution disttypes.QueryClient
|
||||
Evidence evidencetypes.QueryClient
|
||||
Gov govv1types.QueryClient
|
||||
GovBeta govv1beta1types.QueryClient
|
||||
Mint minttypes.QueryClient
|
||||
Params paramstypes.QueryClient
|
||||
Slashing slashingtypes.QueryClient
|
||||
Staking stakingtypes.QueryClient
|
||||
Upgrade upgradetypes.QueryClient
|
||||
Consensus consensustypes.QueryClient
|
||||
|
||||
// 3rd party query clients
|
||||
|
||||
Evm evmtypes.QueryClient
|
||||
Feemarket feemarkettypes.QueryClient
|
||||
IbcClient ibcclienttypes.QueryClient
|
||||
IbcTransfer ibctransfertypes.QueryClient
|
||||
|
||||
// kava module query clients
|
||||
|
||||
Auction auctiontypes.QueryClient
|
||||
Bep3 bep3types.QueryClient
|
||||
Cdp cdptypes.QueryClient
|
||||
Committee committeetypes.QueryClient
|
||||
Community communitytypes.QueryClient
|
||||
Earn earntypes.QueryClient
|
||||
Evmutil evmutiltypes.QueryClient
|
||||
Hard hardtypes.QueryClient
|
||||
Incentive incentivetypes.QueryClient
|
||||
Issuance issuancetypes.QueryClient
|
||||
Kavadist kavadisttypes.QueryClient
|
||||
Liquid liquidtypes.QueryClient
|
||||
Pricefeed pricefeedtypes.QueryClient
|
||||
Savings savingstypes.QueryClient
|
||||
Swap swaptypes.QueryClient
|
||||
}
|
||||
|
||||
// NewQueryClient creates a new QueryClient and initializes all the module query clients
|
||||
func NewQueryClient(grpcEndpoint string) (*QueryClient, error) {
|
||||
conn, err := newGrpcConnection(context.Background(), grpcEndpoint)
|
||||
if err != nil {
|
||||
return &QueryClient{}, err
|
||||
}
|
||||
client := &QueryClient{
|
||||
Tm: tmservice.NewServiceClient(conn),
|
||||
Tx: txtypes.NewServiceClient(conn),
|
||||
Auth: authtypes.NewQueryClient(conn),
|
||||
Authz: authz.NewQueryClient(conn),
|
||||
Bank: banktypes.NewQueryClient(conn),
|
||||
Distribution: disttypes.NewQueryClient(conn),
|
||||
Evidence: evidencetypes.NewQueryClient(conn),
|
||||
Gov: govv1types.NewQueryClient(conn),
|
||||
GovBeta: govv1beta1types.NewQueryClient(conn),
|
||||
Mint: minttypes.NewQueryClient(conn),
|
||||
Params: paramstypes.NewQueryClient(conn),
|
||||
Slashing: slashingtypes.NewQueryClient(conn),
|
||||
Staking: stakingtypes.NewQueryClient(conn),
|
||||
Upgrade: upgradetypes.NewQueryClient(conn),
|
||||
Consensus: consensustypes.NewQueryClient(conn),
|
||||
|
||||
Evm: evmtypes.NewQueryClient(conn),
|
||||
Feemarket: feemarkettypes.NewQueryClient(conn),
|
||||
IbcClient: ibcclienttypes.NewQueryClient(conn),
|
||||
IbcTransfer: ibctransfertypes.NewQueryClient(conn),
|
||||
|
||||
Auction: auctiontypes.NewQueryClient(conn),
|
||||
Bep3: bep3types.NewQueryClient(conn),
|
||||
Cdp: cdptypes.NewQueryClient(conn),
|
||||
Committee: committeetypes.NewQueryClient(conn),
|
||||
Community: communitytypes.NewQueryClient(conn),
|
||||
Earn: earntypes.NewQueryClient(conn),
|
||||
Evmutil: evmutiltypes.NewQueryClient(conn),
|
||||
Hard: hardtypes.NewQueryClient(conn),
|
||||
Incentive: incentivetypes.NewQueryClient(conn),
|
||||
Issuance: issuancetypes.NewQueryClient(conn),
|
||||
Kavadist: kavadisttypes.NewQueryClient(conn),
|
||||
Liquid: liquidtypes.NewQueryClient(conn),
|
||||
Pricefeed: pricefeedtypes.NewQueryClient(conn),
|
||||
Savings: savingstypes.NewQueryClient(conn),
|
||||
Swap: swaptypes.NewQueryClient(conn),
|
||||
}
|
||||
return client, nil
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package query_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/0glabs/0g-chain/client/grpc/query"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewQueryClient_InvalidGprc(t *testing.T) {
|
||||
t.Run("valid connection", func(t *testing.T) {
|
||||
conn, err := query.NewQueryClient("http://localhost:1234")
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, conn)
|
||||
})
|
||||
|
||||
t.Run("non-empty url", func(t *testing.T) {
|
||||
_, err := query.NewQueryClient("")
|
||||
require.ErrorContains(t, err, "unknown grpc url scheme")
|
||||
})
|
||||
|
||||
t.Run("invalid url scheme", func(t *testing.T) {
|
||||
_, err := query.NewQueryClient("ftp://localhost:1234")
|
||||
require.ErrorContains(t, err, "unknown grpc url scheme")
|
||||
})
|
||||
}
|
||||
|
||||
func TestNewQueryClient_ValidClient(t *testing.T) {
|
||||
t.Run("all clients are created", func(t *testing.T) {
|
||||
client, err := query.NewQueryClient("http://localhost:1234")
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, client)
|
||||
|
||||
// validate cosmos clients
|
||||
require.NotNil(t, client.Tm)
|
||||
require.NotNil(t, client.Tx)
|
||||
require.NotNil(t, client.Auth)
|
||||
require.NotNil(t, client.Authz)
|
||||
require.NotNil(t, client.Bank)
|
||||
require.NotNil(t, client.Distribution)
|
||||
require.NotNil(t, client.Evidence)
|
||||
require.NotNil(t, client.Gov)
|
||||
require.NotNil(t, client.GovBeta)
|
||||
require.NotNil(t, client.Mint)
|
||||
require.NotNil(t, client.Params)
|
||||
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)
|
||||
require.NotNil(t, client.Feemarket)
|
||||
require.NotNil(t, client.IbcClient)
|
||||
require.NotNil(t, client.IbcTransfer)
|
||||
|
||||
// validate kava clients
|
||||
require.NotNil(t, client.Auction)
|
||||
require.NotNil(t, client.Bep3)
|
||||
require.NotNil(t, client.Cdp)
|
||||
require.NotNil(t, client.Committee)
|
||||
require.NotNil(t, client.Community)
|
||||
require.NotNil(t, client.Earn)
|
||||
require.NotNil(t, client.Evmutil)
|
||||
require.NotNil(t, client.Hard)
|
||||
require.NotNil(t, client.Incentive)
|
||||
require.NotNil(t, client.Issuance)
|
||||
require.NotNil(t, client.Kavadist)
|
||||
require.NotNil(t, client.Liquid)
|
||||
require.NotNil(t, client.Pricefeed)
|
||||
require.NotNil(t, client.Savings)
|
||||
require.NotNil(t, client.Swap)
|
||||
})
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
|
||||
// Account fetches an account via an address and returns the unpacked account
|
||||
func (u *Util) Account(addr string) (authtypes.AccountI, error) {
|
||||
res, err := u.query.Auth.Account(context.Background(), &authtypes.QueryAccountRequest{
|
||||
Address: addr,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to fetch account: %w", err)
|
||||
}
|
||||
|
||||
var acc authtypes.AccountI
|
||||
err = u.encodingConfig.Marshaler.UnpackAny(res.Account, &acc)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unpack account: %w", err)
|
||||
}
|
||||
return acc, nil
|
||||
}
|
||||
|
||||
// BaseAccount fetches a base account via an address or returns an error if
|
||||
// the account is not a base account
|
||||
func (u *Util) BaseAccount(addr string) (authtypes.BaseAccount, error) {
|
||||
acc, err := u.Account(addr)
|
||||
if err != nil {
|
||||
return authtypes.BaseAccount{}, err
|
||||
}
|
||||
|
||||
bAcc, ok := acc.(*authtypes.BaseAccount)
|
||||
if !ok {
|
||||
return authtypes.BaseAccount{}, fmt.Errorf("%s is not a base account", addr)
|
||||
}
|
||||
|
||||
return *bAcc, nil
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
/*
|
||||
The util package contains utility functions for the Kava gRPC client.
|
||||
|
||||
For example, `account.go` includes account-related query helpers.
|
||||
In this file, utilities such as `client.Util.BaseAccount(addr)` is exposed to
|
||||
query an account and return an unpacked `BaseAccount` instance.
|
||||
*/
|
||||
package util
|
@ -1,32 +0,0 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// Util contains utility functions for the Kava gRPC client
|
||||
type Util struct {
|
||||
query *query.QueryClient
|
||||
encodingConfig params.EncodingConfig
|
||||
}
|
||||
|
||||
// NewUtil creates a new Util instance
|
||||
func NewUtil(query *query.QueryClient) *Util {
|
||||
return &Util{
|
||||
query: query,
|
||||
encodingConfig: app.MakeEncodingConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
func (u *Util) CtxAtHeight(height int64) context.Context {
|
||||
heightStr := strconv.FormatInt(height, 10)
|
||||
return metadata.AppendToOutgoingContext(context.Background(), grpctypes.GRPCBlockHeightHeader, heightStr)
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
package main
|
||||
package client
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
|
||||
"github.com/cometbft/cometbft/libs/cli"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
ethclient "github.com/evmos/ethermint/client"
|
||||
@ -18,9 +18,9 @@ import (
|
||||
|
||||
var ethFlag = "eth"
|
||||
|
||||
// keyCommands registers a sub-tree of commands to interact with
|
||||
// KeyCommands registers a sub-tree of commands to interact with
|
||||
// local private key storage.
|
||||
func keyCommands(defaultNodeHome string) *cobra.Command {
|
||||
func KeyCommands(defaultNodeHome string) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "keys",
|
||||
Short: "Manage your application's keys",
|
||||
@ -52,7 +52,7 @@ 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.FlagKeyType)
|
||||
algoFlag := addCmd.Flag(flags.FlagKeyAlgorithm)
|
||||
algoFlag.DefValue = string(hd.EthSecp256k1Type)
|
||||
err := algoFlag.Value.Set(string(hd.EthSecp256k1Type))
|
||||
if err != nil {
|
||||
@ -107,7 +107,7 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
|
||||
eth, _ := cmd.Flags().GetBool(ethFlag)
|
||||
if eth {
|
||||
cmd.Print("eth flag specified: using coin-type 60 and signing algorithm eth_secp256k1\n")
|
||||
cmd.Flags().Set(flags.FlagKeyType, string(hd.EthSecp256k1Type))
|
||||
cmd.Flags().Set(flags.FlagKeyAlgorithm, string(hd.EthSecp256k1Type))
|
||||
cmd.Flags().Set("coin-type", "60")
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/cometbft/cometbft/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@ -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)
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
|
@ -7,9 +7,6 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
cometbftdb "github.com/cometbft/cometbft-db"
|
||||
"github.com/cometbft/cometbft/libs/log"
|
||||
tmtypes "github.com/cometbft/cometbft/types"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
@ -22,6 +19,8 @@ import (
|
||||
ethermintflags "github.com/evmos/ethermint/server/flags"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
db "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/params"
|
||||
@ -30,7 +29,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.
|
||||
@ -42,7 +40,7 @@ type appCreator struct {
|
||||
// newApp loads config from AppOptions and returns a new app.
|
||||
func (ac appCreator) newApp(
|
||||
logger log.Logger,
|
||||
db cometbftdb.DB,
|
||||
db db.DB,
|
||||
traceStore io.Writer,
|
||||
appOpts servertypes.AppOptions,
|
||||
) servertypes.Application {
|
||||
@ -63,7 +61,7 @@ func (ac appCreator) newApp(
|
||||
|
||||
homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
|
||||
snapshotDir := filepath.Join(homeDir, "data", "snapshots") // TODO can these directory names be imported from somewhere?
|
||||
snapshotDB, err := cometbftdb.NewDB("metadata", server.GetAppDBBackend(appOpts), snapshotDir)
|
||||
snapshotDB, err := sdk.NewLevelDB("metadata", snapshotDir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -90,26 +88,10 @@ func (ac appCreator) newApp(
|
||||
cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)),
|
||||
)
|
||||
|
||||
// Setup chainId
|
||||
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
|
||||
if len(chainID) == 0 {
|
||||
// fallback to genesis chain-id
|
||||
appGenesis, err := tmtypes.GenesisDocFromFile(filepath.Join(homeDir, "config", "genesis.json"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
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)),
|
||||
@ -130,20 +112,18 @@ func (ac appCreator) newApp(
|
||||
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))),
|
||||
baseapp.SetIAVLDisableFastNode(cast.ToBool(iavlDisableFastNode)),
|
||||
baseapp.SetIAVLLazyLoading(cast.ToBool(appOpts.Get(server.FlagIAVLLazyLoading))),
|
||||
baseapp.SetChainID(chainID),
|
||||
)
|
||||
}
|
||||
|
||||
// appExport writes out an app's state to json.
|
||||
func (ac appCreator) appExport(
|
||||
logger log.Logger,
|
||||
db cometbftdb.DB,
|
||||
db db.DB,
|
||||
traceStore io.Writer,
|
||||
height int64,
|
||||
forZeroHeight bool,
|
||||
jailAllowedAddrs []string,
|
||||
appOpts servertypes.AppOptions,
|
||||
modulesToExport []string,
|
||||
) (servertypes.ExportedApp, error) {
|
||||
homePath, ok := appOpts.Get(flags.FlagHome).(string)
|
||||
if !ok || homePath == "" {
|
||||
@ -164,7 +144,7 @@ func (ac appCreator) appExport(
|
||||
} else {
|
||||
tempApp = app.NewApp(logger, db, homePath, traceStore, ac.encodingConfig, options)
|
||||
}
|
||||
return tempApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport)
|
||||
return tempApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
|
||||
}
|
||||
|
||||
// addStartCmdFlags adds flags to the server start command.
|
||||
|
@ -4,10 +4,10 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
tmtypes "github.com/cometbft/cometbft/types"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
"github.com/spf13/cobra"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/params"
|
||||
|
@ -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))
|
||||
}
|
@ -11,7 +11,9 @@ 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:
|
||||
|
@ -1,216 +0,0 @@
|
||||
//go:build rocksdb
|
||||
// +build rocksdb
|
||||
|
||||
package rocksdb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/0glabs/0g-chain/cmd/opendb"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/linxGnu/grocksdb"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"github.com/cometbft/cometbft/libs/log"
|
||||
)
|
||||
|
||||
const (
|
||||
flagPrintStatsInterval = "print-stats-interval"
|
||||
)
|
||||
|
||||
var allowedDBs = []string{"application", "blockstore", "state"}
|
||||
|
||||
func CompactRocksDBCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: fmt.Sprintf(
|
||||
"compact <%s>",
|
||||
strings.Join(allowedDBs, "|"),
|
||||
),
|
||||
Short: "force compacts RocksDB",
|
||||
Long: `This is a utility command that performs a force compaction on the state or
|
||||
blockstore. This should only be run once the node has stopped.`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
|
||||
|
||||
statsIntervalStr, err := cmd.Flags().GetString(flagPrintStatsInterval)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
statsInterval, err := time.ParseDuration(statsIntervalStr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse duration for --%s: %w", flagPrintStatsInterval, err)
|
||||
}
|
||||
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
ctx := server.GetServerContextFromCmd(cmd)
|
||||
|
||||
if server.GetAppDBBackend(ctx.Viper) != "rocksdb" {
|
||||
return errors.New("compaction is currently only supported with rocksdb")
|
||||
}
|
||||
|
||||
if !slices.Contains(allowedDBs, args[0]) {
|
||||
return fmt.Errorf(
|
||||
"invalid db name, must be one of the following: %s",
|
||||
strings.Join(allowedDBs, ", "),
|
||||
)
|
||||
}
|
||||
|
||||
return compactRocksDBs(clientCtx.HomeDir, logger, args[0], statsInterval)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().String(flagPrintStatsInterval, "1m", "duration string for how often to print compaction stats")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// compactRocksDBs performs a manual compaction on the given db.
|
||||
func compactRocksDBs(
|
||||
rootDir string,
|
||||
logger log.Logger,
|
||||
dbName string,
|
||||
statsInterval time.Duration,
|
||||
) error {
|
||||
dbPath := filepath.Join(rootDir, "data", dbName+".db")
|
||||
|
||||
dbOpts, cfOpts, err := opendb.LoadLatestOptions(dbPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Info("opening db", "path", dbPath)
|
||||
db, _, err := grocksdb.OpenDbColumnFamilies(
|
||||
dbOpts,
|
||||
dbPath,
|
||||
[]string{opendb.DefaultColumnFamilyName},
|
||||
[]*grocksdb.Options{cfOpts},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logger.Error("failed to initialize cometbft db", "path", dbPath, "err", err)
|
||||
return fmt.Errorf("failed to open db %s %w", dbPath, err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
logColumnFamilyMetadata(db, logger)
|
||||
|
||||
logger.Info("starting compaction...", "db", dbPath)
|
||||
|
||||
done := make(chan bool)
|
||||
registerSignalHandler(db, logger, done)
|
||||
startCompactionStatsOutput(db, logger, done, statsInterval)
|
||||
|
||||
// Actually run the compaction
|
||||
db.CompactRange(grocksdb.Range{Start: nil, Limit: nil})
|
||||
logger.Info("done compaction", "db", dbPath)
|
||||
|
||||
done <- true
|
||||
return nil
|
||||
}
|
||||
|
||||
// bytesToMB converts bytes to megabytes.
|
||||
func bytesToMB(bytes uint64) float64 {
|
||||
return float64(bytes) / 1024 / 1024
|
||||
}
|
||||
|
||||
// logColumnFamilyMetadata outputs the column family and level metadata.
|
||||
func logColumnFamilyMetadata(
|
||||
db *grocksdb.DB,
|
||||
logger log.Logger,
|
||||
) {
|
||||
metadata := db.GetColumnFamilyMetadata()
|
||||
|
||||
logger.Info(
|
||||
"column family metadata",
|
||||
"name", metadata.Name(),
|
||||
"sizeMB", bytesToMB(metadata.Size()),
|
||||
"fileCount", metadata.FileCount(),
|
||||
"levels", len(metadata.LevelMetas()),
|
||||
)
|
||||
|
||||
for _, level := range metadata.LevelMetas() {
|
||||
logger.Info(
|
||||
fmt.Sprintf("level %d metadata", level.Level()),
|
||||
"sstMetas", strconv.Itoa(len(level.SstMetas())),
|
||||
"sizeMB", strconv.FormatFloat(bytesToMB(level.Size()), 'f', 2, 64),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// startCompactionStatsOutput starts a goroutine that outputs compaction stats
|
||||
// every minute.
|
||||
func startCompactionStatsOutput(
|
||||
db *grocksdb.DB,
|
||||
logger log.Logger,
|
||||
done chan bool,
|
||||
statsInterval time.Duration,
|
||||
) {
|
||||
go func() {
|
||||
ticker := time.NewTicker(statsInterval)
|
||||
isClosed := false
|
||||
|
||||
for {
|
||||
select {
|
||||
// Make sure we don't try reading from the closed db.
|
||||
// We continue the loop so that we can make sure the done channel
|
||||
// does not stall indefinitely from repeated writes and no reader.
|
||||
case <-done:
|
||||
logger.Debug("stopping compaction stats output")
|
||||
isClosed = true
|
||||
case <-ticker.C:
|
||||
if !isClosed {
|
||||
compactionStats := db.GetProperty("rocksdb.stats")
|
||||
fmt.Printf("%s\n", compactionStats)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// registerSignalHandler registers a signal handler that will cancel any running
|
||||
// compaction when the user presses Ctrl+C.
|
||||
func registerSignalHandler(
|
||||
db *grocksdb.DB,
|
||||
logger log.Logger,
|
||||
done chan bool,
|
||||
) {
|
||||
// https://github.com/facebook/rocksdb/wiki/RocksDB-FAQ
|
||||
// Q: Can I close the DB when a manual compaction is in progress?
|
||||
//
|
||||
// A: No, it's not safe to do that. However, you call
|
||||
// CancelAllBackgroundWork(db, true) in another thread to abort the
|
||||
// running compactions, so that you can close the DB sooner. Since
|
||||
// 6.5, you can also speed it up using
|
||||
// DB::DisableManualCompaction().
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
for sig := range c {
|
||||
logger.Info(fmt.Sprintf(
|
||||
"received %s signal, aborting running compaction... Do NOT kill me before compaction is cancelled. I will exit when compaction is cancelled.",
|
||||
sig,
|
||||
))
|
||||
db.DisableManualCompaction()
|
||||
logger.Info("manual compaction disabled")
|
||||
|
||||
// Stop the logging
|
||||
done <- true
|
||||
}
|
||||
}()
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
//go:build rocksdb
|
||||
// +build rocksdb
|
||||
|
||||
package rocksdb
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// RocksDBCmd defines the root command containing subcommands that assist in
|
||||
// rocksdb related tasks such as manual compaction.
|
||||
var RocksDBCmd = &cobra.Command{
|
||||
Use: "rocksdb",
|
||||
Short: "RocksDB util commands",
|
||||
}
|
||||
|
||||
func init() {
|
||||
RocksDBCmd.AddCommand(CompactRocksDBCmd())
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
//go:build !rocksdb
|
||||
// +build !rocksdb
|
||||
|
||||
package rocksdb
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// RocksDBCmd defines the root command when the rocksdb build tag is not set.
|
||||
var RocksDBCmd = &cobra.Command{
|
||||
Use: "rocksdb",
|
||||
Short: "RocksDB util commands, disabled because rocksdb build tag not set",
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -11,24 +10,21 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
|
||||
tmcfg "github.com/cometbft/cometbft/config"
|
||||
tmcli "github.com/cometbft/cometbft/libs/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
ethermintclient "github.com/evmos/ethermint/client"
|
||||
"github.com/evmos/ethermint/crypto/hd"
|
||||
ethermintserver "github.com/evmos/ethermint/server"
|
||||
servercfg "github.com/evmos/ethermint/server/config"
|
||||
"github.com/spf13/cobra"
|
||||
tmcfg "github.com/tendermint/tendermint/config"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"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"
|
||||
kavaclient "github.com/0glabs/0g-chain/client"
|
||||
"github.com/0glabs/0g-chain/cmd/opendb"
|
||||
"github.com/0glabs/0g-chain/crypto/vrf"
|
||||
)
|
||||
@ -50,10 +46,11 @@ func NewRootCmd() *cobra.Command {
|
||||
WithLegacyAmino(encodingConfig.Amino).
|
||||
WithInput(os.Stdin).
|
||||
WithAccountRetriever(types.AccountRetriever{}).
|
||||
WithBroadcastMode(flags.FlagBroadcastMode).
|
||||
WithBroadcastMode(flags.BroadcastBlock).
|
||||
WithHomeDir(chaincfg.DefaultNodeHome).
|
||||
WithKeyringOptions(customKeyringOptions()).
|
||||
WithViper(chaincfg.EnvPrefix)
|
||||
|
||||
rootCmd := &cobra.Command{
|
||||
Use: chaincfg.AppName,
|
||||
Short: "Daemon and CLI for the 0g-chain blockchain.",
|
||||
@ -87,22 +84,18 @@ func NewRootCmd() *cobra.Command {
|
||||
}
|
||||
|
||||
addSubCmds(rootCmd, encodingConfig, chaincfg.DefaultNodeHome)
|
||||
|
||||
return rootCmd
|
||||
}
|
||||
|
||||
// addSubCmds registers all the sub commands used by 0g-chain.
|
||||
func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, defaultNodeHome string) {
|
||||
gentxModule, ok := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic)
|
||||
if !ok {
|
||||
panic(fmt.Errorf("expected %s module to be an instance of type %T", genutiltypes.ModuleName, genutil.AppModuleBasic{}))
|
||||
}
|
||||
|
||||
rootCmd.AddCommand(
|
||||
StatusCommand(),
|
||||
ethermintclient.ValidateChainID(
|
||||
genutilcli.InitCmd(app.ModuleBasics, defaultNodeHome),
|
||||
),
|
||||
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, defaultNodeHome, gentxModule.GenTxValidator),
|
||||
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, defaultNodeHome),
|
||||
AssertInvariantsCmd(encodingConfig),
|
||||
genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, defaultNodeHome),
|
||||
genutilcli.ValidateGenesisCmd(app.ModuleBasics),
|
||||
@ -130,13 +123,10 @@ 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),
|
||||
rocksdb.RocksDBCmd,
|
||||
newShardCmd(opts),
|
||||
iavlviewer.NewCmd(opts),
|
||||
kavaclient.KeyCommands(chaincfg.DefaultNodeHome),
|
||||
)
|
||||
}
|
||||
|
@ -1,319 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
dbm "github.com/cometbft/cometbft-db"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"
|
||||
"github.com/cosmos/cosmos-sdk/store/rootmulti"
|
||||
|
||||
tmconfig "github.com/cometbft/cometbft/config"
|
||||
"github.com/cometbft/cometbft/node"
|
||||
tmstate "github.com/cometbft/cometbft/state"
|
||||
"github.com/cometbft/cometbft/store"
|
||||
|
||||
ethermintserver "github.com/evmos/ethermint/server"
|
||||
)
|
||||
|
||||
const (
|
||||
flagShardStartBlock = "start"
|
||||
flagShardEndBlock = "end"
|
||||
flagShardOnlyAppState = "only-app-state"
|
||||
flagShardForceAppVersion = "force-app-version"
|
||||
flagShardOnlyCometbftState = "only-cometbft-state"
|
||||
// TODO: --preserve flag for creating & operating on a copy?
|
||||
|
||||
// allow using -1 to mean "latest" (perform no rollbacks)
|
||||
shardEndBlockLatest = -1
|
||||
)
|
||||
|
||||
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>]",
|
||||
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.
|
||||
|
||||
It works by first rolling back the latest state to the block before the end block, and then by pruning all state before the start block.
|
||||
|
||||
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
|
||||
|
||||
Prune all blocks up to 5,000,000:
|
||||
$ 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
|
||||
//////////////////////////
|
||||
startBlock, err := cmd.Flags().GetInt64(flagShardStartBlock)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
endBlock, err := cmd.Flags().GetInt64(flagShardEndBlock)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (endBlock == 0 || endBlock < startBlock) && endBlock != shardEndBlockLatest {
|
||||
return fmt.Errorf("end block (%d) must be greater than start block (%d)", endBlock, startBlock)
|
||||
}
|
||||
onlyAppState, err := cmd.Flags().GetBool(flagShardOnlyAppState)
|
||||
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
|
||||
////////////////////////
|
||||
// connect to database
|
||||
db, err := opts.DBOpener(ctx.Viper, clientCtx.HomeDir, server.GetAppDBBackend(ctx.Viper))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// close db connection when done
|
||||
defer func() {
|
||||
if err := db.Close(); err != nil {
|
||||
ctx.Logger.Error("error closing db", "error", err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
///////////////////
|
||||
// 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
|
||||
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)
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// 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
|
||||
}
|
||||
} 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())
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().String(flags.FlagHome, opts.DefaultNodeHome, "The application home directory")
|
||||
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
|
||||
|
||||
var blockStoreDB dbm.DB
|
||||
blockStoreDB, err = dbProvider(&node.DBContext{ID: "blockstore", Config: config})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
blockStore = store.NewBlockStore(blockStoreDB)
|
||||
|
||||
stateDB, err := dbProvider(&node.DBContext{ID: "state", Config: config})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
stateStore = tmstate.NewStore(stateDB, tmstate.StoreOptions{
|
||||
DiscardABCIResponses: config.Storage.DiscardABCIResponses,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cometbft/cometbft/libs/bytes"
|
||||
"github.com/cometbft/cometbft/p2p"
|
||||
coretypes "github.com/cometbft/cometbft/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/libs/bytes"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
coretypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
|
@ -6,8 +6,8 @@ package opendb
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
dbm "github.com/cometbft/cometbft-db"
|
||||
"github.com/cosmos/cosmos-sdk/server/types"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
)
|
||||
|
||||
// OpenDB is a copy of default DBOpener function used by ethermint, see for details:
|
||||
|
@ -29,10 +29,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
dbm "github.com/cometbft/cometbft-db"
|
||||
"github.com/cosmos/cosmos-sdk/server/types"
|
||||
"github.com/linxGnu/grocksdb"
|
||||
"github.com/spf13/cast"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
)
|
||||
|
||||
var ErrUnexpectedConfiguration = errors.New("unexpected rocksdb configuration, rocksdb should have only one column family named default")
|
||||
@ -41,7 +41,7 @@ const (
|
||||
// default tm-db block cache size for RocksDB
|
||||
defaultBlockCacheSize = 1 << 30
|
||||
|
||||
DefaultColumnFamilyName = "default"
|
||||
defaultColumnFamilyName = "default"
|
||||
|
||||
enableMetricsOptName = "rocksdb.enable-metrics"
|
||||
reportMetricsIntervalSecsOptName = "rocksdb.report-metrics-interval-secs"
|
||||
@ -91,7 +91,7 @@ func OpenDB(appOpts types.AppOptions, home string, backendType dbm.BackendType)
|
||||
// option will be overridden only in case if it explicitly specified in appOpts
|
||||
func openRocksdb(dir string, appOpts types.AppOptions) (dbm.DB, error) {
|
||||
optionsPath := filepath.Join(dir, "application.db")
|
||||
dbOpts, cfOpts, err := LoadLatestOptions(optionsPath)
|
||||
dbOpts, cfOpts, err := loadLatestOptions(optionsPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -112,10 +112,10 @@ func openRocksdb(dir string, appOpts types.AppOptions) (dbm.DB, error) {
|
||||
return newRocksDBWithOptions("application", dir, dbOpts, cfOpts, readOpts, enableMetrics, reportMetricsIntervalSecs)
|
||||
}
|
||||
|
||||
// LoadLatestOptions loads and returns database and column family options
|
||||
// loadLatestOptions loads and returns database and column family options
|
||||
// if options file not found, it means database isn't created yet, in such case default tm-db options will be returned
|
||||
// if database exists it should have only one column family named default
|
||||
func LoadLatestOptions(dir string) (*grocksdb.Options, *grocksdb.Options, error) {
|
||||
func loadLatestOptions(dir string) (*grocksdb.Options, *grocksdb.Options, error) {
|
||||
latestOpts, err := grocksdb.LoadLatestOptions(dir, grocksdb.NewDefaultEnv(), true, grocksdb.NewLRUCache(defaultBlockCacheSize))
|
||||
if err != nil && strings.HasPrefix(err.Error(), "NotFound: ") {
|
||||
return newDefaultOptions(), newDefaultOptions(), nil
|
||||
@ -127,7 +127,7 @@ func LoadLatestOptions(dir string) (*grocksdb.Options, *grocksdb.Options, error)
|
||||
cfNames := latestOpts.ColumnFamilyNames()
|
||||
cfOpts := latestOpts.ColumnFamilyOpts()
|
||||
// db should have only one column family named default
|
||||
ok := len(cfNames) == 1 && cfNames[0] == DefaultColumnFamilyName
|
||||
ok := len(cfNames) == 1 && cfNames[0] == defaultColumnFamilyName
|
||||
if !ok {
|
||||
return nil, nil, ErrUnexpectedConfiguration
|
||||
}
|
||||
@ -312,7 +312,7 @@ func newRocksDBWithOptions(
|
||||
dbOpts.EnableStatistics()
|
||||
}
|
||||
|
||||
db, _, err := grocksdb.OpenDbColumnFamilies(dbOpts, dbPath, []string{DefaultColumnFamilyName}, []*grocksdb.Options{cfOpts})
|
||||
db, _, err := grocksdb.OpenDbColumnFamilies(dbOpts, dbPath, []string{defaultColumnFamilyName}, []*grocksdb.Options{cfOpts})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func TestOpenRocksdb(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, db.Close())
|
||||
|
||||
dbOpts, cfOpts, err := LoadLatestOptions(filepath.Join(dir, "application.db"))
|
||||
dbOpts, cfOpts, err := loadLatestOptions(filepath.Join(dir, "application.db"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.maxOpenFiles, dbOpts.GetMaxOpenFiles())
|
||||
require.Equal(t, tc.maxFileOpeningThreads, dbOpts.GetMaxFileOpeningThreads())
|
||||
@ -108,7 +108,7 @@ func TestOpenRocksdb(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, db.Close())
|
||||
|
||||
dbOpts, cfOpts, err := LoadLatestOptions(filepath.Join(dir, "application.db"))
|
||||
dbOpts, cfOpts, err := loadLatestOptions(filepath.Join(dir, "application.db"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, defaultOpts.GetMaxOpenFiles(), dbOpts.GetMaxOpenFiles())
|
||||
require.Equal(t, defaultOpts.GetMaxFileOpeningThreads(), dbOpts.GetMaxFileOpeningThreads())
|
||||
@ -190,7 +190,7 @@ func TestLoadLatestOptions(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, db.Close())
|
||||
|
||||
dbOpts, cfOpts, err := LoadLatestOptions(filepath.Join(dir, "application.db"))
|
||||
dbOpts, cfOpts, err := loadLatestOptions(filepath.Join(dir, "application.db"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.maxOpenFiles, dbOpts.GetMaxOpenFiles())
|
||||
require.Equal(t, tc.maxFileOpeningThreads, dbOpts.GetMaxFileOpeningThreads())
|
||||
@ -210,7 +210,7 @@ func TestLoadLatestOptions(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
dbOpts, cfOpts, err := LoadLatestOptions(filepath.Join(dir, "application.db"))
|
||||
dbOpts, cfOpts, err := loadLatestOptions(filepath.Join(dir, "application.db"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, defaultOpts.GetMaxOpenFiles(), dbOpts.GetMaxOpenFiles())
|
||||
require.Equal(t, defaultOpts.GetMaxFileOpeningThreads(), dbOpts.GetMaxFileOpeningThreads())
|
||||
@ -368,7 +368,7 @@ func TestNewRocksDBWithOptions(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, db.Close())
|
||||
|
||||
dbOpts, cfOpts, err = LoadLatestOptions(filepath.Join(dir, "application.db"))
|
||||
dbOpts, cfOpts, err = loadLatestOptions(filepath.Join(dir, "application.db"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 999, dbOpts.GetMaxOpenFiles())
|
||||
require.Equal(t, defaultOpts.GetMaxFileOpeningThreads(), dbOpts.GetMaxFileOpeningThreads())
|
||||
|
@ -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 (
|
||||
|
@ -1,86 +0,0 @@
|
||||
# Telemetry
|
||||
|
||||
[example metrics emitted by Kava application](./example-prometheus-metrics.txt)
|
||||
|
||||
## Enabling Kava Metric Telemetry
|
||||
|
||||
To enable the kava app to emit telemetry during operation, update the relevant config values to enable metrics:
|
||||
|
||||
`config.toml`
|
||||
|
||||
```toml
|
||||
[instrumentation]
|
||||
|
||||
# When true, Prometheus metrics are served under /metrics on
|
||||
# PrometheusListenAddr.
|
||||
# Check out the documentation for the list of available metrics.
|
||||
prometheus = true
|
||||
|
||||
# Address to listen for Prometheus collector(s) connections
|
||||
prometheus_listen_addr = ":8888"
|
||||
```
|
||||
|
||||
`app.toml`
|
||||
|
||||
```toml
|
||||
[telemetry]
|
||||
|
||||
# Prefixed with keys to separate services.
|
||||
service-name = ""
|
||||
|
||||
# Enabled enables the application telemetry functionality. When enabled,
|
||||
# an in-memory sink is also enabled by default. Operators may also enabled
|
||||
# other sinks such as Prometheus.
|
||||
enabled = true
|
||||
```
|
||||
|
||||
Then restart the service with the updated settings
|
||||
|
||||
## Running local prometheus collector and grafana services
|
||||
|
||||
To collect app metrics and visualize them locally, you can run the prometheus collector and grafana services with docker compose from the repo root directory (after updating `config.toml` and `app.toml` as detailed above)
|
||||
|
||||
```bash
|
||||
docker compose -f prometheus.docker-compose.yml up
|
||||
```
|
||||
|
||||
Navigate to localhost:3000 to view the grafana unix
|
||||
|
||||
Login with `admin` as the username and `admin` as the password
|
||||
|
||||
Hook up grafana to the local prometheus collector by navigating to `http://localhost:3000/connections/datasources/new`, selecting prometheus, entering `http://prometheus:9090` for the url, and clicking `Save & test` at the bottom of the screen
|
||||
|
||||
See [grafana docs](https://grafana.com/docs/grafana/latest/dashboards/) for information on how to construct queries and build dashboards
|
||||
|
||||
### Collecting from local host
|
||||
|
||||
Update [prometheus config](../prometheus.yml) to collect metrics from your local source, where the port matches the value set for `config.toml/instrumentation.prometheus_listen_addr`
|
||||
|
||||
```yaml
|
||||
metrics_path: /
|
||||
static_configs:
|
||||
- targets:
|
||||
- docker-host:8888
|
||||
```
|
||||
|
||||
### Collecting from remote host
|
||||
|
||||
Update the kava config on the host and restart using the instructions from `Enabling Kava Metric Emission`
|
||||
|
||||
Install [ngrok](https://ngrok.com/download) on the remote host
|
||||
|
||||
Run ngrok on the remote host to forward the prometheus metric port
|
||||
|
||||
```bash
|
||||
ngrok http 8888
|
||||
```
|
||||
|
||||
```yaml
|
||||
scrape_configs:
|
||||
- job_name: proxy
|
||||
scheme: https
|
||||
metrics_path: /
|
||||
static_configs:
|
||||
- targets:
|
||||
- 4efb-18-207-102-158.ngrok-free.app
|
||||
```
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
198
go.mod
198
go.mod
@ -1,71 +1,62 @@
|
||||
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-beta.7
|
||||
cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4
|
||||
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.46.11
|
||||
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/modules/light-clients/08-wasm v0.1.1-ibc-go-v7.3-wasmvm-v1.5
|
||||
github.com/cosmos/ibc-go/v7 v7.4.0
|
||||
github.com/cosmos/ibc-go/v6 v6.1.1
|
||||
github.com/ethereum/go-ethereum v1.10.26
|
||||
github.com/evmos/ethermint v0.21.0
|
||||
github.com/go-kit/kit v0.12.0
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
github.com/gogo/protobuf v1.3.3
|
||||
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/linxGnu/grocksdb v1.8.6
|
||||
github.com/pelletier/go-toml/v2 v2.1.0
|
||||
github.com/linxGnu/grocksdb v1.8.0
|
||||
github.com/pelletier/go-toml/v2 v2.0.6
|
||||
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
|
||||
github.com/subosito/gotenv v1.6.0
|
||||
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/spf13/cast v1.5.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/spf13/viper v1.15.0
|
||||
github.com/stretchr/testify v1.8.3
|
||||
github.com/subosito/gotenv v1.4.2
|
||||
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
|
||||
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
|
||||
cosmossdk.io/simapp v0.0.0-20231127212628-044ff4d8c015 // indirect
|
||||
cosmossdk.io/tools/rosetta v0.2.1 // indirect
|
||||
filippo.io/edwards25519 v1.0.0 // indirect
|
||||
filippo.io/edwards25519 v1.0.0-rc.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
|
||||
github.com/CosmWasm/wasmvm v1.5.2 // indirect
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
|
||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
|
||||
github.com/Workiva/go-datastructures v1.0.53 // 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/aws/aws-sdk-go v1.44.122 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
|
||||
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
|
||||
github.com/bgentry/speakeasy v0.1.0 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.7.0 // indirect
|
||||
github.com/btcsuite/btcd v0.23.4 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
||||
@ -73,56 +64,53 @@ 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
|
||||
github.com/cockroachdb/redact v1.1.5 // indirect
|
||||
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
|
||||
github.com/cometbft/cometbft-db v0.7.0 // indirect
|
||||
github.com/confio/ics23/go v0.9.0 // indirect
|
||||
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/ics23/go v0.10.0 // indirect
|
||||
github.com/cosmos/gogoproto v1.4.6 // indirect
|
||||
github.com/cosmos/iavl v0.19.5 // 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/creachadair/taskgroup v0.3.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/felixge/httpsnoop v1.0.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
|
||||
github.com/getsentry/sentry-go v0.23.0 // indirect
|
||||
github.com/gin-gonic/gin v1.8.1 // 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-playground/validator/v10 v10.11.1 // 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/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/s2a-go v0.1.4 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.2.4 // 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
|
||||
@ -137,20 +125,17 @@ require (
|
||||
github.com/hashicorp/go-version v1.6.0 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
|
||||
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||
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/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
|
||||
@ -165,79 +150,84 @@ 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/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // 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
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/regen-network/cosmos-proto v0.3.1 // indirect
|
||||
github.com/rjeczalik/notify v0.9.1 // indirect
|
||||
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
||||
github.com/rs/cors v1.8.3 // 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/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
|
||||
github.com/tendermint/go-amino v0.16.0 // indirect
|
||||
github.com/tidwall/btree v1.6.0 // indirect
|
||||
github.com/tidwall/btree v1.5.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.10 // indirect
|
||||
github.com/tklauser/numcpus v0.4.0 // indirect
|
||||
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
|
||||
github.com/ulikunitz/xz v0.5.11 // indirect
|
||||
github.com/zondax/hid v0.9.2 // indirect
|
||||
github.com/zondax/ledger-go v0.14.3 // indirect
|
||||
go.etcd.io/bbolt v1.3.8 // indirect
|
||||
github.com/ugorji/go/codec v1.2.7 // 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
|
||||
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
|
||||
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/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
|
||||
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
|
||||
google.golang.org/api v0.128.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // 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
|
||||
rsc.io/tmplfunc v0.0.3 // indirect
|
||||
)
|
||||
|
||||
replace (
|
||||
// Use the cosmos keyring code
|
||||
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
|
||||
// Use cometbft fork of tendermint
|
||||
github.com/cometbft/cometbft => github.com/kava-labs/cometbft v0.37.4-kava.1
|
||||
github.com/cometbft/cometbft-db => github.com/kava-labs/cometbft-db v0.9.1-kava.1
|
||||
// Use rocksdb 7.9.2
|
||||
github.com/cometbft/cometbft-db => github.com/kava-labs/cometbft-db v0.7.0-rocksdb-v7.9.2-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 => github.com/0glabs/cosmos-sdk v0.47.10-0glabs.3
|
||||
github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.46.11-0glabs.8
|
||||
// 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/0glabs/ethermint v0.21.0-0g.v3.0.2
|
||||
github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v2.0.4
|
||||
// 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
|
||||
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0
|
||||
// Use the cosmos modified protobufs
|
||||
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
|
||||
// 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,58 +1,61 @@
|
||||
# Kava 16 Upgrade Instructions
|
||||
# Kava 15 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.
|
||||
- The version of `kava` for Kava 15 is v0.25.0
|
||||
- The Kava 14 chain will be shutdown with a `SoftwareUpgradeProposal` that
|
||||
activates at approximately 15:00 UTC on December 7th, 2023.
|
||||
|
||||
## 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.
|
||||
If you use RocksDB as your database backend, you will need to update RocksDB
|
||||
from v7 to v8. The tested and recommended RocksDB version is `v8.1.1`.
|
||||
Please reference the [RocksDB repository](https://github.com/facebook/rocksdb/tree/v8.1.1)
|
||||
to update your installation before building the RocksDB kava binary.
|
||||
|
||||
## API Changes
|
||||
|
||||
If you require calculating the yearly staking reward percentages, standard
|
||||
calculation will no longer be accurate. [Additional Details can be found here.](./staking_rewards.md)
|
||||
|
||||
### 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!
|
||||
The kava chain is expected to halt at block height **7637070**. **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!
|
||||
**Ensure you are using golang 1.20.x and not a different version.** Golang 1.19 and below may cause app hash mismatches!
|
||||
|
||||
To update to v0.26.0
|
||||
To update to v0.25.0
|
||||
|
||||
```sh
|
||||
# check go version - look for 1.21!
|
||||
# check go version - look for 1.20!
|
||||
go version
|
||||
# go version go1.21.6 linux/amd64
|
||||
# go version go1.20.5 linux/amd64
|
||||
|
||||
# in the `kava` folder
|
||||
git fetch
|
||||
git checkout v0.26.0
|
||||
git checkout v0.25.0
|
||||
|
||||
# Note: Golang 1.21 must be installed before this step
|
||||
# Note: Golang 1.20 must be installed before this step
|
||||
make install
|
||||
|
||||
# verify versions
|
||||
kava version --long
|
||||
# name: kava
|
||||
# server_name: kava
|
||||
# version: 0.26.0
|
||||
# version: 0.25.0
|
||||
# commit: <commit placeholder>
|
||||
# build_tags: netgo ledger,
|
||||
# go: go version go1.21.6 linux/amd64
|
||||
# go: go version go1.20.5 linux/amd64
|
||||
# build_deps:
|
||||
# ...
|
||||
# cosmos_sdk_version: v0.47.10
|
||||
# cosmos_sdk_version: v0.46.11
|
||||
|
||||
# Restart node -
|
||||
kava start
|
||||
@ -66,12 +69,12 @@ The riskiest thing a validator can do is discover that they made a mistake and r
|
||||
|
||||
### 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.
|
||||
Prior to applying the Kava 15 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.
|
||||
In the event that the upgrade does not succeed, validators and operators must downgrade back to v0.24.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).
|
||||
If the Kava 15 chain does not launch by December 8th, 2023 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).
|
80
migrate/v0_25/staking_rewards.md
Normal file
80
migrate/v0_25/staking_rewards.md
Normal file
@ -0,0 +1,80 @@
|
||||
# Migrate Staking Reward Calculation to Endpoint
|
||||
|
||||
Kava 15 (v0.25.x) changes the mechanism for staking rewards, which will no longer be inflationary but will be paid out of the community module. In order to continue displaying expected yields or APYs to users, wallets and explorers will need to update.
|
||||
|
||||
The endpoint calculates staking rewards for the current kava version and is forward compatible with future changes.
|
||||
|
||||
All consumers who display yearly staking reward percentages are encouraged to migrate from the standard calculation to using the endpoint, as the standard calculation will no longer be accurate.
|
||||
|
||||
Endpoint: `/kava/community/v1beta1/annualized_rewards`
|
||||
Example Response:
|
||||
```json
|
||||
{
|
||||
"staking_rewards": "0.203023625910000000"
|
||||
}
|
||||
```
|
||||
|
||||
## Before Kava 15
|
||||
|
||||
The staking APR is calculated the same way as other cosmos-sdk chains. Various parameters are fetched and then combined in this calculation:
|
||||
```
|
||||
staking_apr ≈ mint_inflation *
|
||||
(1 - distribution_params.community_tax) *
|
||||
(total_supply_ukava/pool.bonded_tokens)
|
||||
```
|
||||
|
||||
_Note this doesn’t include transaction fees paid to stakers._
|
||||
|
||||
Endpoints used:
|
||||
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/params
|
||||
* https://api.data.kava.io/cosmos/distribution/v1beta1/params
|
||||
* https://api.data.kava.io/cosmos/bank/v1beta1/supply/by_denom?denom=ukava
|
||||
* https://api.data.kava.io/cosmos/staking/v1beta1/pool
|
||||
|
||||
Informational Endpoints
|
||||
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/inflation
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/annual_provisions
|
||||
|
||||
## After Kava 15
|
||||
|
||||
Kava 15 implements new staking rewards as ratified in this proposal: https://www.mintscan.io/kava/proposals/141. They will come into effect at the “switchover time” on 2024-01-01 00:00 UTC.
|
||||
|
||||
* All delegating and claiming transactions remain unchanged. There is no change in how rewards are claimed or how claimable balances are queried.
|
||||
* After the switchover time, inflation will be set to zero (and rewards will be paid from the community module account).
|
||||
* After the switchover time, rewards are paid out according to:
|
||||
```
|
||||
staking apy ≈ community_params.staking_rewards_per_second *
|
||||
seconds_per_year / pool.bonded_tokens
|
||||
```
|
||||
|
||||
_Note this doesn’t include transaction fees paid to stakers._
|
||||
|
||||
* There is a new endpoint `kava/community/v1beta1/annualized_rewards`
|
||||
* before the switchover time, it will return the current staking APY (calculated in the previous section)
|
||||
* after the switchover time, it will return the new staking APY above
|
||||
|
||||
* Existing endpoints above will remain active, but the params will change such that the old apr calculation will return 0.
|
||||
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/params
|
||||
* no format changes
|
||||
* `inflation_max` and `inflation_min` will be 0.0
|
||||
|
||||
* https://api.data.kava.io/cosmos/distribution/v1beta1/params
|
||||
* no format changes
|
||||
* `community_tax` will be 0.0
|
||||
|
||||
* https://api.data.kava.io/cosmos/bank/v1beta1/supply/by_denom?denom=ukava
|
||||
* no changes
|
||||
|
||||
* https://api.data.kava.io/cosmos/staking/v1beta1/pool
|
||||
* no changes
|
||||
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/inflation
|
||||
* no format changes
|
||||
* `inflation` will be 0.0
|
||||
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/annual_provisions
|
||||
* no format changes
|
||||
* `annual_provisions` will be 0.0
|
@ -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,43 +0,0 @@
|
||||
version: '3.8'
|
||||
|
||||
networks:
|
||||
monitoring:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
prometheus_data: {}
|
||||
|
||||
services:
|
||||
grafana:
|
||||
image: grafana/grafana-enterprise
|
||||
container_name: grafana
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
networks:
|
||||
- monitoring
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus:latest
|
||||
container_name: prometheus
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./prometheus.yml:/etc/prometheus/prometheus.yml
|
||||
- prometheus_data:/prometheus
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--storage.tsdb.path=/prometheus'
|
||||
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
||||
- '--web.console.templates=/etc/prometheus/consoles'
|
||||
- '--web.enable-lifecycle'
|
||||
expose:
|
||||
- 9090
|
||||
networks:
|
||||
- monitoring
|
||||
docker-host:
|
||||
image: qoomon/docker-host
|
||||
cap_add: [ 'NET_ADMIN', 'NET_RAW' ]
|
||||
mem_limit: 8M
|
||||
restart: on-failure
|
||||
networks:
|
||||
- monitoring
|
@ -1,9 +0,0 @@
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
scrape_configs:
|
||||
- job_name: proxy
|
||||
metrics_path: /
|
||||
static_configs:
|
||||
- targets:
|
||||
- docker-host:8888
|
@ -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
|
||||
];
|
||||
}
|
@ -113,7 +113,7 @@ message AtomicSwap {
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// random_number_hash represents the hash of the random number
|
||||
bytes random_number_hash = 2 [(gogoproto.casttype) = "github.com/cometbft/cometbft/libs/bytes.HexBytes"];
|
||||
bytes random_number_hash = 2 [(gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes"];
|
||||
// expire_height represents the height when the swap expires
|
||||
uint64 expire_height = 3;
|
||||
// timestamp represents the timestamp of the swap
|
||||
|
@ -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 [
|
||||
|
32
simulations/Dockerfile
Normal file
32
simulations/Dockerfile
Normal file
@ -0,0 +1,32 @@
|
||||
FROM golang:1.13-alpine AS build-env
|
||||
|
||||
# Set up dependencies
|
||||
# bash for debugging
|
||||
# git, make for installation
|
||||
# libc-dev, gcc, linux-headers, eudev-dev are used for cgo and ledger installation (possibly)
|
||||
RUN apk add bash git make libc-dev gcc linux-headers eudev-dev jq
|
||||
|
||||
# Install aws cli
|
||||
RUN apk add python py-pip
|
||||
RUN pip install awscli
|
||||
|
||||
# Set working directory for the build
|
||||
WORKDIR /root/kava
|
||||
# default home directory is /root
|
||||
|
||||
# Download dependencies before adding source files to speed up build times
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
RUN go mod download
|
||||
|
||||
# Add source files
|
||||
COPY app app
|
||||
COPY cli_test cli_test
|
||||
COPY cmd cmd
|
||||
COPY app app
|
||||
COPY x x
|
||||
COPY Makefile .
|
||||
|
||||
COPY simulations simulations
|
||||
|
||||
# kvd and kcli binaries are not necessary for running the simulations
|
43
simulations/README.md
Normal file
43
simulations/README.md
Normal file
@ -0,0 +1,43 @@
|
||||
# How To Run Sims In The Cloud
|
||||
|
||||
Sims run with AWS batch, with results uploaded to S3
|
||||
|
||||
## AWS Batch
|
||||
|
||||
In AWS batch you define:
|
||||
|
||||
- a "compute environment"--just how many machines you want (and of what kind)
|
||||
- a "job queue"--just a place to put jobs (pairs them with a compute environment)
|
||||
- a "job definition"--a template for jobs
|
||||
|
||||
Then to run stuff you create "jobs" and submit them to a job queue.
|
||||
|
||||
The number of machines running auto-scales to match the number of jobs. When there are no jobs there are no machines, so you don't pay for anything.
|
||||
|
||||
Jobs are defined as a docker image (assumed hosted on dockerhub) and a command string.
|
||||
>e.g. `kava/kava-sim:version1`, `go test ./app`
|
||||
|
||||
This can run sims but doesn't collect the results. This is handled by a custom script.
|
||||
|
||||
## Running sims and uploading to S3
|
||||
|
||||
The dockerfile in this repo defines the docker image to run sims. It includes the kava source code, aws cli, and the custom simulation script.
|
||||
|
||||
The custom script reads some input args, runs a sim and uploads the stdout and stderr to a S3 bucket.
|
||||
|
||||
AWS Batch allows for "array jobs" which are a way of specifying many duplicates of a job, each with a different index passed in as an env var.
|
||||
|
||||
### Steps
|
||||
|
||||
- create and submit a new array job (based of the job definition) with
|
||||
- image `kava/kava-sim:<some-version>`
|
||||
- command `run-then-upload.sh TestFullAppSimulation <starting-seed> <num-blocks> <block-size>`
|
||||
- array size of how many sims you want to run
|
||||
- any changes needed to the code or script necessitates a rebuild:
|
||||
- `docker build -f simulations/Dockerfile -t kava/kava-sim:<some-version> .`
|
||||
- `docker push kava/kava-sim:<some-version>`
|
||||
|
||||
### Tips
|
||||
|
||||
- click on the compute environment name, to get details, then click the link ECS Cluster Name to get details on the actual machines running
|
||||
- for array jobs, click the job name to get details of the individual jobs
|
47
simulations/run-then-upload.sh
Executable file
47
simulations/run-then-upload.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This requires AWS access keys envs to be set (ie AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
|
||||
# These need to be generated from the AWS console.
|
||||
|
||||
# For commands passed to the docker container, the working directory is /root/kava (which is the blockchain git repo).
|
||||
|
||||
|
||||
# Parse Input Args
|
||||
# get simulation type, eg TestFullAppSimulation
|
||||
simType=$1
|
||||
# get seed
|
||||
startingSeed=$2
|
||||
# compute the seed from the starting and the job index
|
||||
# add two nums together, hence the $(()), and use 0 as the default value for array index, hence the ${:-} syntax
|
||||
seed=$(($startingSeed+${AWS_BATCH_JOB_ARRAY_INDEX:-0}))
|
||||
# get sim parameters
|
||||
numBlocks=$3
|
||||
blockSize=$4
|
||||
|
||||
|
||||
# Run The Sim
|
||||
# record cli arguments in the log file (in json in case we need to parse this) and stdout (https://stackoverflow.com/questions/418896/how-to-redirect-output-to-a-file-and-stdout)
|
||||
printf "{\"simType\": \"%s\", \"startingSeed\": %s, \"seed\": %s, \"numBlocks\": %s, \"blockSize\": %s}\n" $simType $startingSeed $seed $numBlocks $blockSize | tee out.log
|
||||
# run sim and redirect stdout and stderr to a file)
|
||||
go test ./app -run $simType -Enabled=true -NumBlocks=$numBlocks -BlockSize=$blockSize -Commit=true -Period=5 -Seed=$seed -v -timeout 24h >> out.log 2>&1
|
||||
# get the exit code to determine how to upload results
|
||||
simExitStatus=$?
|
||||
if [ $simExitStatus -eq 0 ];then
|
||||
echo "simulation passed"
|
||||
simResult="pass"
|
||||
else
|
||||
echo "simulation failed"
|
||||
simResult="fail"
|
||||
fi
|
||||
|
||||
|
||||
# Upload Sim Results To S3
|
||||
# read in the job id, using a default value if not set
|
||||
jobID=${AWS_BATCH_JOB_ID:-"testJobID:"}
|
||||
# job id format is "job-id:array-job-index", this removes trailing colon (and array index if present) https://stackoverflow.com/questions/3045493/parse-string-with-bash-and-extract-number
|
||||
jobID=$(echo $jobID | sed 's/\(.*\):\d*/\1/')
|
||||
|
||||
# create the filename from the array job index (which won't be set if this is a normal job)
|
||||
fileName=$(printf "out%05d.log" $AWS_BATCH_JOB_ARRAY_INDEX)
|
||||
|
||||
aws s3 cp out.log s3://simulations-1/$SIM_NAME$jobID/$simResult/$fileName
|
@ -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="master"
|
||||
|
||||
# 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
|
||||
|
@ -1,39 +0,0 @@
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGrpcClientQueryCosmosModule_Balance() {
|
||||
// ARRANGE
|
||||
// setup kava account
|
||||
funds := ukava(1e5) // .1 KAVA
|
||||
kavaAcc := suite.Kava.NewFundedAccount("balance-test", sdk.NewCoins(funds))
|
||||
|
||||
// ACT
|
||||
rsp, err := suite.Kava.Grpc.Query.Bank.Balance(context.Background(), &banktypes.QueryBalanceRequest{
|
||||
Address: kavaAcc.SdkAddress.String(),
|
||||
Denom: funds.Denom,
|
||||
})
|
||||
|
||||
// ASSERT
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().Equal(funds.Amount, rsp.Balance.Amount)
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGrpcClientQueryKavaModule_EvmParams() {
|
||||
// ACT
|
||||
rsp, err := suite.Kava.Grpc.Query.Evmutil.Params(
|
||||
context.Background(), &evmutiltypes.QueryParamsRequest{},
|
||||
)
|
||||
|
||||
// ASSERT
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().GreaterOrEqual(len(rsp.Params.AllowedCosmosDenoms), 1)
|
||||
suite.Require().GreaterOrEqual(len(rsp.Params.EnabledConversionPairs), 1)
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func (suite *IntegrationTestSuite) TestGrpcClientUtil_Account() {
|
||||
// ARRANGE
|
||||
// setup kava account
|
||||
kavaAcc := suite.Kava.NewFundedAccount("account-test", sdk.NewCoins(ukava(1e5)))
|
||||
|
||||
// ACT
|
||||
rsp, err := suite.Kava.Grpc.BaseAccount(kavaAcc.SdkAddress.String())
|
||||
|
||||
// ASSERT
|
||||
suite.Require().NoError(err)
|
||||
suite.Equal(kavaAcc.SdkAddress.String(), rsp.Address)
|
||||
suite.Greater(rsp.AccountNumber, uint64(1))
|
||||
suite.Equal(uint64(0), rsp.Sequence)
|
||||
}
|
@ -13,8 +13,8 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
ibctypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
|
||||
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
|
||||
ibctypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
|
||||
ibcclienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
emtypes "github.com/evmos/ethermint/types"
|
||||
|
||||
|
241
tests/e2e/e2e_upgrade_community_test.go
Normal file
241
tests/e2e/e2e_upgrade_community_test.go
Normal file
@ -0,0 +1,241 @@
|
||||
package e2e_test
|
||||
|
||||
// func (suite *IntegrationTestSuite) TestUpgradeCommunityParams() {
|
||||
// suite.SkipIfUpgradeDisabled()
|
||||
|
||||
// beforeUpgradeCtx := util.CtxAtHeight(suite.UpgradeHeight - 1)
|
||||
// afterUpgradeCtx := util.CtxAtHeight(suite.UpgradeHeight)
|
||||
|
||||
// // Before params
|
||||
// kavaDistParamsBefore, err := suite.ZgChain.Kavadist.Params(beforeUpgradeCtx, &kavadisttypes.QueryParamsRequest{})
|
||||
// suite.NoError(err)
|
||||
// mintParamsBefore, err := suite.ZgChain.Mint.Params(beforeUpgradeCtx, &minttypes.QueryParamsRequest{})
|
||||
// suite.NoError(err)
|
||||
|
||||
// // Before parameters
|
||||
// suite.Run("x/community and x/kavadist parameters before upgrade", func() {
|
||||
// _, err = suite.ZgChain.Community.Params(beforeUpgradeCtx, &communitytypes.QueryParamsRequest{})
|
||||
// suite.Error(err, "x/community should not have params before upgrade")
|
||||
|
||||
// suite.Require().True(
|
||||
// kavaDistParamsBefore.Params.Active,
|
||||
// "x/kavadist should be active before upgrade",
|
||||
// )
|
||||
|
||||
// suite.Require().True(
|
||||
// mintParamsBefore.Params.InflationMax.IsPositive(),
|
||||
// "x/mint inflation max should be positive before upgrade",
|
||||
// )
|
||||
// suite.Require().True(
|
||||
// mintParamsBefore.Params.InflationMin.IsPositive(),
|
||||
// "x/mint inflation min should be positive before upgrade",
|
||||
// )
|
||||
// })
|
||||
|
||||
// // After upgrade, Before switchover - parameters
|
||||
// suite.Run("x/kavadist, x/mint, x/community parameters after upgrade, before switchover", func() {
|
||||
// kavaDistParamsAfter, err := suite.ZgChain.Kavadist.Params(afterUpgradeCtx, &kavadisttypes.QueryParamsRequest{})
|
||||
// suite.NoError(err)
|
||||
// mintParamsAfter, err := suite.ZgChain.Mint.Params(afterUpgradeCtx, &minttypes.QueryParamsRequest{})
|
||||
// suite.NoError(err)
|
||||
// communityParamsAfter, err := suite.ZgChain.Community.Params(afterUpgradeCtx, &communitytypes.QueryParamsRequest{})
|
||||
// suite.NoError(err)
|
||||
|
||||
// suite.Equal(
|
||||
// kavaDistParamsBefore.Params,
|
||||
// kavaDistParamsAfter.Params,
|
||||
// "x/kavadist should be unaffected after upgrade",
|
||||
// )
|
||||
|
||||
// suite.Equal(
|
||||
// mintParamsBefore.Params,
|
||||
// mintParamsAfter.Params,
|
||||
// "x/mint params should be unaffected after upgrade",
|
||||
// )
|
||||
|
||||
// expectedParams := app.CommunityParams_E2E
|
||||
// // Make UpgradeTimeDisableInflation match so that we ignore it, because
|
||||
// // referencing app.CommunityParams_E2E in this test files is different
|
||||
// // from the one set in the upgrade handler. At least check that it is
|
||||
// // set to a non-zero value in the assertion below
|
||||
// expectedParams.UpgradeTimeDisableInflation = communityParamsAfter.Params.UpgradeTimeDisableInflation
|
||||
|
||||
// suite.False(
|
||||
// communityParamsAfter.Params.UpgradeTimeDisableInflation.IsZero(),
|
||||
// "x/community switchover time should be set after upgrade",
|
||||
// )
|
||||
// suite.Equal(
|
||||
// expectedParams,
|
||||
// communityParamsAfter.Params,
|
||||
// "x/community params should be set to E2E params after upgrade",
|
||||
// )
|
||||
// })
|
||||
|
||||
// suite.Require().Eventually(
|
||||
// func() bool {
|
||||
// // Get x/community for switchover time
|
||||
// params, err := suite.ZgChain.Community.Params(
|
||||
// context.Background(),
|
||||
// &communitytypes.QueryParamsRequest{},
|
||||
// )
|
||||
// suite.Require().NoError(err)
|
||||
|
||||
// // Check that switchover time is set to zero, e.g. switchover happened
|
||||
// return params.Params.UpgradeTimeDisableInflation.Equal(time.Time{})
|
||||
// },
|
||||
// 20*time.Second, 1*time.Second,
|
||||
// "switchover should happen and x/community params should be updated",
|
||||
// )
|
||||
|
||||
// // Fetch exact block when inflation stop event emitted
|
||||
// _, switchoverHeight, err := suite.ZgChain.GetBeginBlockEventsFromQuery(
|
||||
// context.Background(),
|
||||
// fmt.Sprintf(
|
||||
// "%s.%s EXISTS",
|
||||
// communitytypes.EventTypeInflationStop,
|
||||
// communitytypes.AttributeKeyInflationDisableTime,
|
||||
// ),
|
||||
// )
|
||||
// suite.Require().NoError(err)
|
||||
// suite.Require().NotZero(switchoverHeight)
|
||||
|
||||
// beforeSwitchoverCtx := util.CtxAtHeight(switchoverHeight - 1)
|
||||
// afterSwitchoverCtx := util.CtxAtHeight(switchoverHeight)
|
||||
|
||||
// suite.Run("x/kavadist, x/mint, x/community parameters after upgrade, after switchover", func() {
|
||||
// kavaDistParamsAfter, err := suite.ZgChain.Kavadist.Params(
|
||||
// afterSwitchoverCtx,
|
||||
// &kavadisttypes.QueryParamsRequest{},
|
||||
// )
|
||||
// suite.NoError(err)
|
||||
// mintParamsAfter, err := suite.ZgChain.Mint.Params(
|
||||
// afterSwitchoverCtx,
|
||||
// &minttypes.QueryParamsRequest{},
|
||||
// )
|
||||
// suite.NoError(err)
|
||||
// communityParamsAfter, err := suite.ZgChain.Community.Params(
|
||||
// afterSwitchoverCtx,
|
||||
// &communitytypes.QueryParamsRequest{},
|
||||
// )
|
||||
// suite.NoError(err)
|
||||
|
||||
// suite.False(
|
||||
// kavaDistParamsAfter.Params.Active,
|
||||
// "x/kavadist should be disabled after upgrade",
|
||||
// )
|
||||
|
||||
// suite.True(
|
||||
// mintParamsAfter.Params.InflationMax.IsZero(),
|
||||
// "x/mint inflation max should be zero after switchover",
|
||||
// )
|
||||
// suite.True(
|
||||
// mintParamsAfter.Params.InflationMin.IsZero(),
|
||||
// "x/mint inflation min should be zero after switchover",
|
||||
// )
|
||||
|
||||
// suite.Equal(
|
||||
// time.Time{},
|
||||
// communityParamsAfter.Params.UpgradeTimeDisableInflation,
|
||||
// "x/community switchover time should be reset",
|
||||
// )
|
||||
|
||||
// suite.Equal(
|
||||
// communityParamsAfter.Params.UpgradeTimeSetStakingRewardsPerSecond,
|
||||
// communityParamsAfter.Params.StakingRewardsPerSecond,
|
||||
// "x/community staking rewards per second should match upgrade time staking rewards per second",
|
||||
// )
|
||||
// })
|
||||
|
||||
// suite.Run("x/kavadist, x/distribution, x/community balances after switchover", func() {
|
||||
// // Before balances - community pool fund consolidation
|
||||
// kavaDistBalBefore, err := suite.ZgChain.Kavadist.Balance(
|
||||
// beforeSwitchoverCtx,
|
||||
// &kavadisttypes.QueryBalanceRequest{},
|
||||
// )
|
||||
// suite.NoError(err)
|
||||
// distrBalBefore, err := suite.ZgChain.Distribution.CommunityPool(
|
||||
// beforeSwitchoverCtx,
|
||||
// &distrtypes.QueryCommunityPoolRequest{},
|
||||
// )
|
||||
// suite.NoError(err)
|
||||
// distrBalCoinsBefore, distrDustBefore := distrBalBefore.Pool.TruncateDecimal()
|
||||
// beforeCommPoolBalance, err := suite.ZgChain.Community.Balance(
|
||||
// beforeSwitchoverCtx,
|
||||
// &communitytypes.QueryBalanceRequest{},
|
||||
// )
|
||||
// suite.NoError(err)
|
||||
|
||||
// // After balances
|
||||
// kavaDistBalAfter, err := suite.ZgChain.Kavadist.Balance(
|
||||
// afterSwitchoverCtx,
|
||||
// &kavadisttypes.QueryBalanceRequest{},
|
||||
// )
|
||||
// suite.NoError(err)
|
||||
// distrBalAfter, err := suite.ZgChain.Distribution.CommunityPool(
|
||||
// afterSwitchoverCtx,
|
||||
// &distrtypes.QueryCommunityPoolRequest{},
|
||||
// )
|
||||
// suite.NoError(err)
|
||||
// afterCommPoolBalance, err := suite.ZgChain.Community.Balance(
|
||||
// afterSwitchoverCtx,
|
||||
// &communitytypes.QueryBalanceRequest{},
|
||||
// )
|
||||
// suite.NoError(err)
|
||||
|
||||
// expectedKavadistBal := sdk.NewCoins(sdk.NewCoin(
|
||||
// "ukava",
|
||||
// kavaDistBalBefore.Coins.AmountOf("ukava"),
|
||||
// ))
|
||||
// suite.Equal(
|
||||
// expectedKavadistBal,
|
||||
// kavaDistBalAfter.Coins,
|
||||
// "x/kavadist balance should persist the ukava amount and move all other funds",
|
||||
// )
|
||||
// expectedKavadistTransferred := kavaDistBalBefore.Coins.Sub(expectedKavadistBal...)
|
||||
|
||||
// // very low ukava balance after (ignoring dust in x/distribution)
|
||||
// // a small amount of tx fees can still end up here.
|
||||
// // dust should stay in x/distribution, but may not be the same so it's unchecked
|
||||
// distrCoinsAfter, distrDustAfter := distrBalAfter.Pool.TruncateDecimal()
|
||||
// suite.Empty(distrCoinsAfter, "expected no coins in x/distribution community pool")
|
||||
|
||||
// // Fetch block results for paid staking rewards in the block
|
||||
// blockRes, err := suite.ZgChain.TmSignClient.BlockResults(
|
||||
// context.Background(),
|
||||
// &switchoverHeight,
|
||||
// )
|
||||
// suite.Require().NoError(err)
|
||||
|
||||
// stakingRewardPaidEvents := util.FilterEventsByType(
|
||||
// blockRes.BeginBlockEvents,
|
||||
// communitytypes.EventTypeStakingRewardsPaid,
|
||||
// )
|
||||
// suite.Require().Len(stakingRewardPaidEvents, 1, "there should be only 1 staking reward paid event")
|
||||
// stakingRewardAmount := sdk.NewCoins()
|
||||
// for _, attr := range stakingRewardPaidEvents[0].Attributes {
|
||||
// if string(attr.Key) == communitytypes.AttributeKeyStakingRewardAmount {
|
||||
// stakingRewardAmount, err = sdk.ParseCoinsNormalized(string(attr.Value))
|
||||
// suite.Require().NoError(err)
|
||||
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
|
||||
// expectedCommunityBal := beforeCommPoolBalance.Coins.
|
||||
// Add(distrBalCoinsBefore...).
|
||||
// Add(expectedKavadistTransferred...).
|
||||
// Sub(stakingRewardAmount...) // Remove staking rewards paid in the block
|
||||
|
||||
// // x/kavadist and x/distribution community pools should be moved to x/community
|
||||
// suite.Equal(
|
||||
// expectedCommunityBal,
|
||||
// afterCommPoolBalance.Coins,
|
||||
// )
|
||||
|
||||
// suite.Equal(
|
||||
// distrDustBefore,
|
||||
// distrDustAfter,
|
||||
// "x/distribution community pool dust should be unchanged",
|
||||
// )
|
||||
// })
|
||||
// }
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user