Skip to content

Commit

Permalink
fix: simulation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
poorphd committed Jul 26, 2023
1 parent 1ad3ad8 commit f107ff3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
16 changes: 9 additions & 7 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import (
"os"
"testing"

"github.com/evmos/ethermint/encoding"
abci "github.com/tendermint/tendermint/abci/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/store"
Expand All @@ -25,6 +22,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
"github.com/evmos/ethermint/encoding"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
Expand Down Expand Up @@ -185,7 +183,7 @@ func TestAppImportExport(t *testing.T) {
require.NoError(t, err)

ctxA := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
ctxB := newApp.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
ctxB := newApp.NewContext(true, tmproto.Header{ChainID: config.ChainID, Height: app.LastBlockHeight()})
newApp.mm.InitGenesis(ctxB, app.AppCodec(), genesisState)
newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)

Expand Down Expand Up @@ -394,9 +392,13 @@ func TestAppSimulationAfterImport(t *testing.T) {
)
require.Equal(t, cantoconfig.AppName, newApp.Name())

newApp.InitChain(abci.RequestInitChain{
AppStateBytes: exported.AppState,
})
var genesisState GenesisState
err = json.Unmarshal(exported.AppState, &genesisState)
require.NoError(t, err)

ctx := newApp.NewContext(true, tmproto.Header{ChainID: config.ChainID, Height: app.LastBlockHeight()})
newApp.mm.InitGenesis(ctx, app.AppCodec(), genesisState)
newApp.StoreConsensusParams(ctx, exported.ConsensusParams)

_, _, err = simulation.SimulateFromSeed(
t,
Expand Down
2 changes: 2 additions & 0 deletions app/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand Down Expand Up @@ -235,6 +236,7 @@ func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile str
PrivKey: privKey,
PubKey: privKey.PubKey(),
Address: a.GetAddress(),
ConsKey: ed25519.GenPrivKeyFromSecret(privkeySeed),
}
newAccs[i] = simAcc
}
Expand Down
30 changes: 19 additions & 11 deletions init_testnet.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
KEY="mykey"
KEY2="mykey2"
KEY1="key1"
KEY2="key2"
KEY3="key3"
CHAINID="canto_7701-1"
MONIKER="plex-validator"
KEYRING="test"
Expand All @@ -14,15 +15,18 @@ command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https

# Reinstall daemon
rm -rf ~/.cantod*
make install
make install-testing

# Set client config
cantod config keyring-backend $KEYRING
cantod config chain-id $CHAINID

# if $KEY exists it should be deleted
cantod keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO
cantod keys add $KEY1 --keyring-backend $KEYRING --algo $KEYALGO
cantod keys add $KEY2 --keyring-backend $KEYRING --algo $KEYALGO
cantod keys add $KEY3 --keyring-backend $KEYRING --algo $KEYALGO



# Set moniker and chain-id for Canto (Moniker can be anything, chain-id must be an integer)
cantod init $MONIKER --chain-id $CHAINID
Expand Down Expand Up @@ -70,20 +74,24 @@ if [[ $1 == "pending" ]]; then
fi

# Allocate genesis accounts (cosmos formatted addresses)
cantod add-genesis-account $KEY 964723926400000000000000000acanto --keyring-backend $KEYRING
cantod add-genesis-account $KEY2 35276073600000000000000000acanto --keyring-backend $KEYRING

cantod add-genesis-account $KEY1 1050000000000000000000000000acanto --keyring-backend $KEYRING
cantod add-genesis-account $KEY2 1000000000000000000000000000acanto --keyring-backend $KEYRING
cantod add-genesis-account $KEY3 1000000000000000000000000000acanto --keyring-backend $KEYRING



# Update total supply with claim values
#validators_supply=$(cat $HOME/.cantod/config/genesis.json | jq -r '.app_state["bank"]["supply"][0]["amount"]')
# Bc is required to add this big numbers
# total_supply=$(bc <<< "$amount_to_claim+$validators_supply")
total_supply=1000000000000000000000000000
total_supply=3050000000000000000000000000
cat $HOME/.cantod/config/genesis.json | jq -r --arg total_supply "$total_supply" '.app_state["bank"]["supply"][0]["amount"]=$total_supply' > $HOME/.cantod/config/tmp_genesis.json && mv $HOME/.cantod/config/tmp_genesis.json $HOME/.cantod/config/genesis.json

echo $KEYRING
echo $KEY
echo $KEY1
# Sign genesis transaction
cantod gentx $KEY2 100000000000000000000000acanto --keyring-backend $KEYRING --chain-id $CHAINID
mkdir $HOME/.cantod/config/gentx
cantod gentx $KEY1 900000000000000000000000acanto --keyring-backend $KEYRING --chain-id $CHAINID --output-document $HOME/.cantod/config/gentx/gentx-1.json
#cantod gentx $KEY2 1000000000000000000000acanto --keyring-backend $KEYRING --chain-id $CHAINID

# Collect genesis tx
Expand All @@ -97,5 +105,5 @@ if [[ $1 == "pending" ]]; then
fi

# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
cantod start --pruning=nothing --trace --log_level trace --minimum-gas-prices=1.000acanto --json-rpc.api eth,txpool,personal,net,debug,web3 --rpc.laddr "tcp://0.0.0.0:26657" --api.enable true --api.enabled-unsafe-cors true
#cantod start --pruning=nothing --trace --log_level trace --minimum-gas-prices=1.000acanto --json-rpc.api eth,txpool,personal,net,debug,web3 --rpc.laddr "tcp://0.0.0.0:26657" --api.enable true --api.enabled-unsafe-cors true

0 comments on commit f107ff3

Please sign in to comment.