From 9b4a1e6b321a8f24271867122e19a1c1f63a522b Mon Sep 17 00:00:00 2001 From: 0xsatoshi Date: Sat, 4 May 2024 14:26:54 +0800 Subject: [PATCH] fix --- app/_simulate_tx_test.go | 5 +- app/ante/authz_test.go | 7 +- app/ante/eip712_test.go | 19 ++- app/ante/min_gas_filter_test.go | 33 +++-- app/ante/vesting_test.go | 7 +- app/app.go | 4 - app/test_common.go | 8 +- chaincfg/denoms.go | 27 ---- cmd/0gchaind/main.go | 1 - cmd/0gchaind/root.go | 2 +- migrate/utils/periodic_vesting_reset_test.go | 47 ++++--- x/evmutil/keeper/bank_keeper.go | 133 ++++++++++--------- x/evmutil/keeper/invariants.go | 3 +- x/evmutil/keeper/invariants_test.go | 2 +- x/evmutil/testutil/suite.go | 24 ++-- x/issuance/legacy/v0_16/migrate_test.go | 12 +- x/validator-vesting/querier.go | 4 +- 17 files changed, 153 insertions(+), 185 deletions(-) delete mode 100644 chaincfg/denoms.go diff --git a/app/_simulate_tx_test.go b/app/_simulate_tx_test.go index e9cb1552..834ee988 100644 --- a/app/_simulate_tx_test.go +++ b/app/_simulate_tx_test.go @@ -10,7 +10,6 @@ import ( sdkmath "cosmossdk.io/math" "github.com/0glabs/0g-chain/app" - "github.com/0glabs/0g-chain/chaincfg" "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" @@ -63,11 +62,11 @@ func (suite *SimulateRequestTestSuite) TestSimulateRequest() { bank.MsgSend{ FromAddress: fromAddr, ToAddress: toAddr, - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1e6))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, }, Fee: auth.StdFee{ - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(5e4))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(5e4))), Gas: 1e6, }, Memo: "test memo", diff --git a/app/ante/authz_test.go b/app/ante/authz_test.go index 35395092..16478c47 100644 --- a/app/ante/authz_test.go +++ b/app/ante/authz_test.go @@ -16,7 +16,6 @@ import ( "github.com/0glabs/0g-chain/app" "github.com/0glabs/0g-chain/app/ante" - "github.com/0glabs/0g-chain/chaincfg" ) func newMsgGrant(granter sdk.AccAddress, grantee sdk.AccAddress, a authz.Authorization, expiration time.Time) *authz.MsgGrant { @@ -59,7 +58,7 @@ func TestAuthzLimiterDecorator(t *testing.T) { banktypes.NewMsgSend( testAddresses[0], testAddresses[1], - sdk.NewCoins(sdk.NewInt64Coin(chaincfg.DisplayDenom, 100)), + sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100e6)), ), }, checkTx: false, @@ -129,7 +128,7 @@ func TestAuthzLimiterDecorator(t *testing.T) { []sdk.Msg{banktypes.NewMsgSend( testAddresses[0], testAddresses[3], - sdk.NewCoins(sdk.NewInt64Coin(chaincfg.DisplayDenom, 100)), + sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100e6)), )}), }, checkTx: false, @@ -162,7 +161,7 @@ func TestAuthzLimiterDecorator(t *testing.T) { banktypes.NewMsgSend( testAddresses[0], testAddresses[3], - sdk.NewCoins(sdk.NewInt64Coin(chaincfg.DisplayDenom, 100)), + sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100e6)), ), &evmtypes.MsgEthereumTx{}, }, diff --git a/app/ante/eip712_test.go b/app/ante/eip712_test.go index 35632b5b..b117026e 100644 --- a/app/ante/eip712_test.go +++ b/app/ante/eip712_test.go @@ -34,7 +34,6 @@ import ( "github.com/tendermint/tendermint/version" "github.com/0glabs/0g-chain/app" - "github.com/0glabs/0g-chain/chaincfg" evmutilkeeper "github.com/0glabs/0g-chain/x/evmutil/keeper" evmutiltestutil "github.com/0glabs/0g-chain/x/evmutil/testutil" evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" @@ -156,7 +155,7 @@ func (suite *EIP712TestSuite) SetupTest() { // Genesis states evmGs := evmtypes.NewGenesisState( evmtypes.NewParams( - chaincfg.BaseDenom, // evmDenom + "neuron", // evmDenom false, // allowedUnprotectedTxs true, // enableCreate true, // enableCall @@ -222,10 +221,10 @@ func (suite *EIP712TestSuite) SetupTest() { pricefeedtypes.ModuleName: cdc.MustMarshalJSON(&pricefeedGenState), } - // funds our test accounts with some a0gi + // funds our test accounts with some ua0gi coinsGenState := app.NewFundedGenStateWithSameCoins( tApp.AppCodec(), - sdk.NewCoins(sdk.NewInt64Coin(chaincfg.DisplayDenom, 1e3)), + sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 1e9)), []sdk.AccAddress{suite.testAddr, suite.testAddr2}, ) @@ -370,7 +369,7 @@ func (suite *EIP712TestSuite) deployUSDCERC20(app app.TestApp, ctx sdk.Context) suite.tApp.FundModuleAccount( suite.ctx, evmutiltypes.ModuleName, - sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(0))), + sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(0))), ) contractAddr, err := suite.evmutilKeeper.DeployTestMintableERC20Contract(suite.ctx, "USDC", "USDC", uint8(18)) @@ -470,7 +469,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() { errMsg: "insufficient funds", updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder { bk := suite.tApp.GetBankKeeper() - gasCoins := bk.GetBalance(suite.ctx, suite.testAddr, chaincfg.DisplayDenom) + gasCoins := bk.GetBalance(suite.ctx, suite.testAddr, "ua0gi") suite.tApp.GetBankKeeper().SendCoins(suite.ctx, suite.testAddr, suite.testAddr2, sdk.NewCoins(gasCoins)) return txBuilder }, @@ -482,7 +481,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() { failCheckTx: true, errMsg: "invalid chain-id", updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder { - gasAmt := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(20))) + gasAmt := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(20))) return suite.createTestEIP712CosmosTxBuilder( suite.testAddr, suite.testPrivKey, "kavatest_12-1", uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs, ) @@ -495,7 +494,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() { failCheckTx: true, errMsg: "invalid pubkey", updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder { - gasAmt := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(20))) + gasAmt := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(20))) return suite.createTestEIP712CosmosTxBuilder( suite.testAddr2, suite.testPrivKey2, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs, ) @@ -523,7 +522,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() { msgs = tc.updateMsgs(msgs) } - gasAmt := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(20))) + gasAmt := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(20))) txBuilder := suite.createTestEIP712CosmosTxBuilder( suite.testAddr, suite.testPrivKey, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs, ) @@ -597,7 +596,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() { } // deliver deposit msg - gasAmt := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(20))) + gasAmt := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(20))) txBuilder := suite.createTestEIP712CosmosTxBuilder( suite.testAddr, suite.testPrivKey, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, depositMsgs, ) diff --git a/app/ante/min_gas_filter_test.go b/app/ante/min_gas_filter_test.go index 66f703e3..6ad5f10e 100644 --- a/app/ante/min_gas_filter_test.go +++ b/app/ante/min_gas_filter_test.go @@ -13,7 +13,6 @@ import ( "github.com/0glabs/0g-chain/app" "github.com/0glabs/0g-chain/app/ante" - "github.com/0glabs/0g-chain/chaincfg" ) func mustParseDecCoins(value string) sdk.DecCoins { @@ -31,7 +30,7 @@ func TestEvmMinGasFilter(t *testing.T) { ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()}) tApp.GetEvmKeeper().SetParams(ctx, evmtypes.Params{ - EvmDenom: chaincfg.BaseDenom, + EvmDenom: "neuron", }) testCases := []struct { @@ -45,29 +44,29 @@ func TestEvmMinGasFilter(t *testing.T) { mustParseDecCoins(""), }, { - "zero a0gi gas price", - mustParseDecCoins("0a0gi"), - mustParseDecCoins("0a0gi"), + "zero ua0gi gas price", + mustParseDecCoins("0ua0gi"), + mustParseDecCoins("0ua0gi"), }, { - "non-zero a0gi gas price", - mustParseDecCoins("0.001a0gi"), - mustParseDecCoins("0.001a0gi"), + "non-zero ua0gi gas price", + mustParseDecCoins("0.001ua0gi"), + mustParseDecCoins("0.001ua0gi"), }, { - "zero a0gi gas price, min neuron price", - mustParseDecCoins("0a0gi;100000neuron"), - mustParseDecCoins("0a0gi"), // neuron is removed + "zero ua0gi gas price, min neuron price", + mustParseDecCoins("0ua0gi;100000neuron"), + mustParseDecCoins("0ua0gi"), // neuron is removed }, { - "zero a0gi gas price, min neuron price, other token", - mustParseDecCoins("0a0gi;100000neuron;0.001other"), - mustParseDecCoins("0a0gi;0.001other"), // neuron is removed + "zero ua0gi gas price, min neuron price, other token", + mustParseDecCoins("0ua0gi;100000neuron;0.001other"), + mustParseDecCoins("0ua0gi;0.001other"), // neuron is removed }, { - "non-zero a0gi gas price, min neuron price", - mustParseDecCoins("0.25a0gi;100000neuron;0.001other"), - mustParseDecCoins("0.25a0gi;0.001other"), // neuron is removed + "non-zero ua0gi gas price, min neuron price", + mustParseDecCoins("0.25ua0gi;100000neuron;0.001other"), + mustParseDecCoins("0.25ua0gi;0.001other"), // neuron is removed }, } diff --git a/app/ante/vesting_test.go b/app/ante/vesting_test.go index beea72a4..242b25dd 100644 --- a/app/ante/vesting_test.go +++ b/app/ante/vesting_test.go @@ -14,7 +14,6 @@ import ( "github.com/0glabs/0g-chain/app" "github.com/0glabs/0g-chain/app/ante" - "github.com/0glabs/0g-chain/chaincfg" ) func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing.T) { @@ -34,7 +33,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing "MsgCreateVestingAccount", vesting.NewMsgCreateVestingAccount( testAddresses[0], testAddresses[1], - sdk.NewCoins(sdk.NewInt64Coin(chaincfg.DisplayDenom, 100)), + sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100)), time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC).Unix(), false, ), @@ -45,7 +44,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing "MsgCreateVestingAccount", vesting.NewMsgCreatePermanentLockedAccount( testAddresses[0], testAddresses[1], - sdk.NewCoins(sdk.NewInt64Coin(chaincfg.DisplayDenom, 100)), + sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100)), ), true, "MsgTypeURL /cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount not supported", @@ -64,7 +63,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing "other messages not affected", banktypes.NewMsgSend( testAddresses[0], testAddresses[1], - sdk.NewCoins(sdk.NewInt64Coin(chaincfg.DisplayDenom, 100)), + sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100)), ), false, "", diff --git a/app/app.go b/app/app.go index 04af80ff..a6b8b9f0 100644 --- a/app/app.go +++ b/app/app.go @@ -5,7 +5,6 @@ import ( "io" "net/http" - sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" @@ -264,9 +263,6 @@ type App struct { } func init() { - // 1stake = 1 ukava = 1_000_000_000_000 akava = 1_000_000_000_000 neuron - conversionMultiplier := sdkmath.NewIntFromUint64(1_000_000_000_000) - sdk.DefaultPowerReduction = sdk.DefaultPowerReduction.Mul(conversionMultiplier) } // NewApp returns a reference to an initialized App. diff --git a/app/test_common.go b/app/test_common.go index 29ab3ead..ecef1271 100644 --- a/app/test_common.go +++ b/app/test_common.go @@ -149,7 +149,7 @@ func GenesisStateWithSingleValidator( balances := []banktypes.Balance{ { Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(100000000000000))), }, } @@ -212,7 +212,7 @@ func genesisStateWithValSet( } // set validators and delegations currentStakingGenesis := stakingtypes.GetGenesisStateFromAppState(app.appCodec, genesisState) - currentStakingGenesis.Params.BondDenom = chaincfg.DisplayDenom + currentStakingGenesis.Params.BondDenom = "ua0gi" stakingGenesis := stakingtypes.NewGenesisState( currentStakingGenesis.Params, @@ -232,13 +232,13 @@ func genesisStateWithValSet( for range delegations { // add delegated tokens to total supply - totalSupply = totalSupply.Add(sdk.NewCoin(chaincfg.DisplayDenom, bondAmt)) + totalSupply = totalSupply.Add(sdk.NewCoin("ua0gi", bondAmt)) } // add bonded amount to bonded pool module account balances = append(balances, banktypes.Balance{ Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), - Coins: sdk.Coins{sdk.NewCoin(chaincfg.DisplayDenom, bondAmt)}, + Coins: sdk.Coins{sdk.NewCoin("ua0gi", bondAmt)}, }) bankGenesis := banktypes.NewGenesisState( diff --git a/chaincfg/denoms.go b/chaincfg/denoms.go deleted file mode 100644 index cbd61280..00000000 --- a/chaincfg/denoms.go +++ /dev/null @@ -1,27 +0,0 @@ -package chaincfg - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -const ( - // DisplayDenom defines the denomination displayed to users in client applications. - DisplayDenom = "a0gi" - // BaseDenom defines to the default denomination used in 0g-chain - BaseDenom = "neuron" - - BaseDenomUnit = 18 - - ConversionMultiplier = 1e18 -) - -// RegisterDenoms registers the base and display denominations to the SDK. -func RegisterDenoms() { - if err := sdk.RegisterDenom(DisplayDenom, sdk.OneDec()); err != nil { - panic(err) - } - - if err := sdk.RegisterDenom(BaseDenom, sdk.NewDecWithPrec(1, BaseDenomUnit)); err != nil { - panic(err) - } -} diff --git a/cmd/0gchaind/main.go b/cmd/0gchaind/main.go index 5a1c4cfe..621362ca 100644 --- a/cmd/0gchaind/main.go +++ b/cmd/0gchaind/main.go @@ -11,7 +11,6 @@ import ( func main() { chaincfg.SetSDKConfig().Seal() - chaincfg.RegisterDenoms() rootCmd := NewRootCmd() diff --git a/cmd/0gchaind/root.go b/cmd/0gchaind/root.go index a652fe17..72cf38f4 100644 --- a/cmd/0gchaind/root.go +++ b/cmd/0gchaind/root.go @@ -72,7 +72,7 @@ func NewRootCmd() *cobra.Command { return err } - customAppTemplate, customAppConfig := servercfg.AppConfig(chaincfg.BaseDenom) + customAppTemplate, customAppConfig := servercfg.AppConfig("ua0gi") return server.InterceptConfigsPreRunHandler( cmd, diff --git a/migrate/utils/periodic_vesting_reset_test.go b/migrate/utils/periodic_vesting_reset_test.go index 06789f86..e0a8ed28 100644 --- a/migrate/utils/periodic_vesting_reset_test.go +++ b/migrate/utils/periodic_vesting_reset_test.go @@ -5,7 +5,6 @@ import ( "time" sdkmath "cosmossdk.io/math" - "github.com/0glabs/0g-chain/chaincfg" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -42,7 +41,7 @@ func TestResetPeriodVestingAccount_NoVestingPeriods(t *testing.T) { } func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(t *testing.T) { - balance := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))) + balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))) vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past periods := vestingtypes.Periods{ @@ -65,7 +64,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(t *testing.T) { } func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) { - balance := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))) + balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))) vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past periods := vestingtypes.Periods{ @@ -98,7 +97,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) { } func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing.T) { - balance := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))) + balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))) vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past periods := vestingtypes.Periods{ @@ -126,25 +125,25 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing } func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) { - balance := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(4))) + balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(4e6))) vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past periods := vestingtypes.Periods{ vestingtypes.Period{ Length: 15 * 24 * 60 * 60, // -15 days - vested - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, vestingtypes.Period{ Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, vestingtypes.Period{ Length: 15 * 24 * 60 * 60, // +15 days - vesting - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, vestingtypes.Period{ Length: 15 * 24 * 60 * 60, // +30 days - vesting - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, } @@ -160,36 +159,36 @@ func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) { expectedPeriods := []vestingtypes.Period{ { Length: 15 * 24 * 60 * 60, // 15 days - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, { Length: 15 * 24 * 60 * 60, // 15 days - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, } - assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(2))), vacc.OriginalVesting, "expected original vesting to be updated") + assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(2e6))), vacc.OriginalVesting, "expected original vesting to be updated") assert.Equal(t, newVestingStartTime.Unix(), vacc.StartTime, "expected vesting start time to be updated") assert.Equal(t, expectedEndtime, vacc.EndTime, "expected vesting end time end at last period") assert.Equal(t, expectedPeriods, vacc.VestingPeriods, "expected vesting periods to be updated") } func TestResetPeriodVestingAccount_DelegatedVesting_GreaterThanVesting(t *testing.T) { - balance := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(3))) + balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(3e6))) vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past periods := vestingtypes.Periods{ vestingtypes.Period{ Length: 15 * 24 * 60 * 60, // -15 days - vested - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, vestingtypes.Period{ Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, vestingtypes.Period{ Length: 15 * 24 * 60 * 60, // +15 days - vesting - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, } @@ -199,35 +198,35 @@ func TestResetPeriodVestingAccount_DelegatedVesting_GreaterThanVesting(t *testin newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour) ResetPeriodicVestingAccount(vacc, newVestingStartTime) - assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(2))), vacc.DelegatedFree, "expected delegated free to be updated") - assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), vacc.DelegatedVesting, "expected delegated vesting to be updated") + assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(2e6))), vacc.DelegatedFree, "expected delegated free to be updated") + assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be updated") } func TestResetPeriodVestingAccount_DelegatedVesting_LessThanVested(t *testing.T) { - balance := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(3))) + balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(3e6))) vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past periods := vestingtypes.Periods{ vestingtypes.Period{ Length: 15 * 24 * 60 * 60, // -15 days - vested - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, vestingtypes.Period{ Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, vestingtypes.Period{ Length: 15 * 24 * 60 * 60, // +15 days - vesting - Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), + Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), }, } vacc := createVestingAccount(balance, vestingStartTime, periods) - vacc.TrackDelegation(vestingStartTime, balance, sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1)))) + vacc.TrackDelegation(vestingStartTime, balance, sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6)))) newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour) ResetPeriodicVestingAccount(vacc, newVestingStartTime) assert.Equal(t, sdk.Coins(nil), vacc.DelegatedFree, "expected delegrated free to be unmodified") - assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(1))), vacc.DelegatedVesting, "expected delegated vesting to be unmodified") + assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be unmodified") } diff --git a/x/evmutil/keeper/bank_keeper.go b/x/evmutil/keeper/bank_keeper.go index d360f55b..3ef3b0c6 100644 --- a/x/evmutil/keeper/bank_keeper.go +++ b/x/evmutil/keeper/bank_keeper.go @@ -9,12 +9,19 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/evmutil/types" ) -// ConversionMultiplier is the conversion multiplier between neuron and a0gi -var ConversionMultiplier = sdkmath.NewInt(chaincfg.ConversionMultiplier) +const ( + // EvmDenom is the gas denom used by the evm + EvmDenom = "neuron" + + // CosmosDenom is the gas denom used by the 0g-chain app + CosmosDenom = "ua0gi" +) + +// ConversionMultiplier is the conversion multiplier between neuron and ua0gi +var ConversionMultiplier = sdkmath.NewInt(1_000_000_000_000) var _ evmtypes.BankKeeper = EvmBankKeeper{} @@ -25,30 +32,30 @@ var _ evmtypes.BankKeeper = EvmBankKeeper{} // This keeper uses both the a0gi coin and a separate neuron balance to manage the // extra percision needed by the evm. type EvmBankKeeper struct { - baseKeeper Keeper - bk types.BankKeeper - ak types.AccountKeeper + neuronKeeper Keeper + bk types.BankKeeper + ak types.AccountKeeper } -func NewEvmBankKeeper(baseKeeper Keeper, bk types.BankKeeper, ak types.AccountKeeper) EvmBankKeeper { +func NewEvmBankKeeper(neuronKeeper Keeper, bk types.BankKeeper, ak types.AccountKeeper) EvmBankKeeper { return EvmBankKeeper{ - baseKeeper: baseKeeper, - bk: bk, - ak: ak, + neuronKeeper: neuronKeeper, + bk: bk, + ak: ak, } } // GetBalance returns the total **spendable** balance of neuron for a given account by address. func (k EvmBankKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { - if denom != chaincfg.BaseDenom { - panic(fmt.Errorf("only evm denom %s is supported by EvmBankKeeper", chaincfg.BaseDenom)) + if denom != EvmDenom { + panic(fmt.Errorf("only evm denom %s is supported by EvmBankKeeper", EvmDenom)) } spendableCoins := k.bk.SpendableCoins(ctx, addr) - a0gi := spendableCoins.AmountOf(chaincfg.DisplayDenom) - neuron := k.baseKeeper.GetBalance(ctx, addr) - total := a0gi.Mul(ConversionMultiplier).Add(neuron) - return sdk.NewCoin(chaincfg.BaseDenom, total) + ua0gi := spendableCoins.AmountOf(CosmosDenom) + neuron := k.neuronKeeper.GetBalance(ctx, addr) + total := ua0gi.Mul(ConversionMultiplier).Add(neuron) + return sdk.NewCoin(EvmDenom, total) } // SendCoins transfers neuron coins from a AccAddress to an AccAddress. @@ -63,115 +70,115 @@ func (k EvmBankKeeper) SendCoins(ctx sdk.Context, senderAddr sdk.AccAddress, rec // It will panic if the module account does not exist. An error is returned if the recipient // address is black-listed or if sending the tokens fails. func (k EvmBankKeeper) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error { - a0gi, neuron, err := SplitNeuronCoins(amt) + ua0gi, neuron, err := SplitNeuronCoins(amt) if err != nil { return err } - if a0gi.Amount.IsPositive() { - if err := k.bk.SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, sdk.NewCoins(a0gi)); err != nil { + if ua0gi.Amount.IsPositive() { + if err := k.bk.SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, sdk.NewCoins(ua0gi)); err != nil { return err } } senderAddr := k.GetModuleAddress(senderModule) - if err := k.ConvertOneA0giToNeuronIfNeeded(ctx, senderAddr, neuron); err != nil { + if err := k.ConvertOneUa0giToNeuronIfNeeded(ctx, senderAddr, neuron); err != nil { return err } - if err := k.baseKeeper.SendBalance(ctx, senderAddr, recipientAddr, neuron); err != nil { + if err := k.neuronKeeper.SendBalance(ctx, senderAddr, recipientAddr, neuron); err != nil { return err } - return k.ConvertNeuronToA0gi(ctx, recipientAddr) + return k.ConvertNeuronToUa0gi(ctx, recipientAddr) } // SendCoinsFromAccountToModule transfers neuron coins from an AccAddress to a ModuleAccount. // It will panic if the module account does not exist. func (k EvmBankKeeper) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error { - a0gi, neuronNeeded, err := SplitNeuronCoins(amt) + ua0gi, neuronNeeded, err := SplitNeuronCoins(amt) if err != nil { return err } - if a0gi.IsPositive() { - if err := k.bk.SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, sdk.NewCoins(a0gi)); err != nil { + if ua0gi.IsPositive() { + if err := k.bk.SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, sdk.NewCoins(ua0gi)); err != nil { return err } } - if err := k.ConvertOneA0giToNeuronIfNeeded(ctx, senderAddr, neuronNeeded); err != nil { + if err := k.ConvertOneUa0giToNeuronIfNeeded(ctx, senderAddr, neuronNeeded); err != nil { return err } recipientAddr := k.GetModuleAddress(recipientModule) - if err := k.baseKeeper.SendBalance(ctx, senderAddr, recipientAddr, neuronNeeded); err != nil { + if err := k.neuronKeeper.SendBalance(ctx, senderAddr, recipientAddr, neuronNeeded); err != nil { return err } - return k.ConvertNeuronToA0gi(ctx, recipientAddr) + return k.ConvertNeuronToUa0gi(ctx, recipientAddr) } // MintCoins mints neuron coins by minting the equivalent a0gi coins and any remaining neuron coins. // It will panic if the module account does not exist or is unauthorized. func (k EvmBankKeeper) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error { - a0gi, neuron, err := SplitNeuronCoins(amt) + ua0gi, neuron, err := SplitNeuronCoins(amt) if err != nil { return err } - if a0gi.IsPositive() { - if err := k.bk.MintCoins(ctx, moduleName, sdk.NewCoins(a0gi)); err != nil { + if ua0gi.IsPositive() { + if err := k.bk.MintCoins(ctx, moduleName, sdk.NewCoins(ua0gi)); err != nil { return err } } recipientAddr := k.GetModuleAddress(moduleName) - if err := k.baseKeeper.AddBalance(ctx, recipientAddr, neuron); err != nil { + if err := k.neuronKeeper.AddBalance(ctx, recipientAddr, neuron); err != nil { return err } - return k.ConvertNeuronToA0gi(ctx, recipientAddr) + return k.ConvertNeuronToUa0gi(ctx, recipientAddr) } // BurnCoins burns neuron coins by burning the equivalent a0gi coins and any remaining neuron coins. // It will panic if the module account does not exist or is unauthorized. func (k EvmBankKeeper) BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error { - a0gi, neuron, err := SplitNeuronCoins(amt) + ua0gi, neuron, err := SplitNeuronCoins(amt) if err != nil { return err } - if a0gi.IsPositive() { - if err := k.bk.BurnCoins(ctx, moduleName, sdk.NewCoins(a0gi)); err != nil { + if ua0gi.IsPositive() { + if err := k.bk.BurnCoins(ctx, moduleName, sdk.NewCoins(ua0gi)); err != nil { return err } } moduleAddr := k.GetModuleAddress(moduleName) - if err := k.ConvertOneA0giToNeuronIfNeeded(ctx, moduleAddr, neuron); err != nil { + if err := k.ConvertOneUa0giToNeuronIfNeeded(ctx, moduleAddr, neuron); err != nil { return err } - return k.baseKeeper.RemoveBalance(ctx, moduleAddr, neuron) + return k.neuronKeeper.RemoveBalance(ctx, moduleAddr, neuron) } -// ConvertOneA0giToNeuronIfNeeded converts 1 a0gi to neuron for an address if +// ConvertOneUa0giToNeuronIfNeeded converts 1 a0gi to neuron for an address if // its neuron balance is smaller than the neuronNeeded amount. -func (k EvmBankKeeper) ConvertOneA0giToNeuronIfNeeded(ctx sdk.Context, addr sdk.AccAddress, neuronNeeded sdkmath.Int) error { - neuronBal := k.baseKeeper.GetBalance(ctx, addr) +func (k EvmBankKeeper) ConvertOneUa0giToNeuronIfNeeded(ctx sdk.Context, addr sdk.AccAddress, neuronNeeded sdkmath.Int) error { + neuronBal := k.neuronKeeper.GetBalance(ctx, addr) if neuronBal.GTE(neuronNeeded) { return nil } - a0giToStore := sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdk.OneInt())) - if err := k.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, a0giToStore); err != nil { + ua0giToStore := sdk.NewCoins(sdk.NewCoin(CosmosDenom, sdk.OneInt())) + if err := k.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, ua0giToStore); err != nil { return err } // add 1a0gi equivalent of neuron to addr neuronToReceive := ConversionMultiplier - if err := k.baseKeeper.AddBalance(ctx, addr, neuronToReceive); err != nil { + if err := k.neuronKeeper.AddBalance(ctx, addr, neuronToReceive); err != nil { return err } @@ -179,28 +186,28 @@ func (k EvmBankKeeper) ConvertOneA0giToNeuronIfNeeded(ctx sdk.Context, addr sdk. } // ConvertNeuronToA0gi converts all available neuron to a0gi for a given AccAddress. -func (k EvmBankKeeper) ConvertNeuronToA0gi(ctx sdk.Context, addr sdk.AccAddress) error { - totalNeuron := k.baseKeeper.GetBalance(ctx, addr) - a0gi, _, err := SplitNeuronCoins(sdk.NewCoins(sdk.NewCoin(chaincfg.BaseDenom, totalNeuron))) +func (k EvmBankKeeper) ConvertNeuronToUa0gi(ctx sdk.Context, addr sdk.AccAddress) error { + totalNeuron := k.neuronKeeper.GetBalance(ctx, addr) + ua0gi, _, err := SplitNeuronCoins(sdk.NewCoins(sdk.NewCoin(EvmDenom, totalNeuron))) if err != nil { return err } // do nothing if account does not have enough neuron for a single a0gi - a0giToReceive := a0gi.Amount - if !a0giToReceive.IsPositive() { + ua0giToReceive := ua0gi.Amount + if !ua0giToReceive.IsPositive() { return nil } - // remove neuron used for converting to a0gi - neuronToBurn := a0giToReceive.Mul(ConversionMultiplier) + // remove neuron used for converting to ua0gi + neuronToBurn := ua0giToReceive.Mul(ConversionMultiplier) finalBal := totalNeuron.Sub(neuronToBurn) - if err := k.baseKeeper.SetBalance(ctx, addr, finalBal); err != nil { + if err := k.neuronKeeper.SetBalance(ctx, addr, finalBal); err != nil { return err } fromAddr := k.GetModuleAddress(types.ModuleName) - if err := k.bk.SendCoins(ctx, fromAddr, addr, sdk.NewCoins(a0gi)); err != nil { + if err := k.bk.SendCoins(ctx, fromAddr, addr, sdk.NewCoins(ua0gi)); err != nil { return err } @@ -219,14 +226,14 @@ func (k EvmBankKeeper) GetModuleAddress(moduleName string) sdk.AccAddress { // An error will be returned if the coins are not valid or if the coins are not the neuron denom. func SplitNeuronCoins(coins sdk.Coins) (sdk.Coin, sdkmath.Int, error) { neuron := sdk.ZeroInt() - a0gi := sdk.NewCoin(chaincfg.DisplayDenom, sdk.ZeroInt()) + ua0gi := sdk.NewCoin(CosmosDenom, sdk.ZeroInt()) if len(coins) == 0 { - return a0gi, neuron, nil + return ua0gi, neuron, nil } if err := ValidateEvmCoins(coins); err != nil { - return a0gi, neuron, err + return ua0gi, neuron, err } // note: we should always have len(coins) == 1 here since coins cannot have dup denoms after we validate. @@ -235,15 +242,15 @@ func SplitNeuronCoins(coins sdk.Coins) (sdk.Coin, sdkmath.Int, error) { if remainingBalance.IsPositive() { neuron = remainingBalance } - a0giAmount := coin.Amount.Quo(ConversionMultiplier) - if a0giAmount.IsPositive() { - a0gi = sdk.NewCoin(chaincfg.DisplayDenom, a0giAmount) + ua0giAmount := coin.Amount.Quo(ConversionMultiplier) + if ua0giAmount.IsPositive() { + ua0gi = sdk.NewCoin(CosmosDenom, ua0giAmount) } - return a0gi, neuron, nil + return ua0gi, neuron, nil } -// ValidateEvmCoins validates the coins from evm is valid and is the chaincfg.BaseDenom (neuron). +// ValidateEvmCoins validates the coins from evm is valid and is the EvmDenom (neuron). func ValidateEvmCoins(coins sdk.Coins) error { if len(coins) == 0 { return nil @@ -255,8 +262,8 @@ func ValidateEvmCoins(coins sdk.Coins) error { } // validate that coin denom is neuron - if len(coins) != 1 || coins[0].Denom != chaincfg.BaseDenom { - errMsg := fmt.Sprintf("invalid evm coin denom, only %s is supported", chaincfg.BaseDenom) + if len(coins) != 1 || coins[0].Denom != EvmDenom { + errMsg := fmt.Sprintf("invalid evm coin denom, only %s is supported", EvmDenom) return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, errMsg) } diff --git a/x/evmutil/keeper/invariants.go b/x/evmutil/keeper/invariants.go index 6d9ac93b..6b3a1db0 100644 --- a/x/evmutil/keeper/invariants.go +++ b/x/evmutil/keeper/invariants.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/evmutil/types" ) @@ -51,7 +50,7 @@ func FullyBackedInvariant(bankK types.BankKeeper, k Keeper) sdk.Invariant { }) bankAddr := authtypes.NewModuleAddress(types.ModuleName) - bankBalance := bankK.GetBalance(ctx, bankAddr, chaincfg.DisplayDenom).Amount.Mul(ConversionMultiplier) + bankBalance := bankK.GetBalance(ctx, bankAddr, CosmosDenom).Amount.Mul(ConversionMultiplier) broken = totalMinorBalances.GT(bankBalance) diff --git a/x/evmutil/keeper/invariants_test.go b/x/evmutil/keeper/invariants_test.go index fa73f3d7..3e6b941a 100644 --- a/x/evmutil/keeper/invariants_test.go +++ b/x/evmutil/keeper/invariants_test.go @@ -50,7 +50,7 @@ func (suite *invariantTestSuite) SetupValidState() { suite.FundModuleAccountWithZgChain( types.ModuleName, sdk.NewCoins( - sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(2)), // ( sum of all minor balances ) / conversion multiplier + sdk.NewCoin("ua0gi", sdkmath.NewInt(2)), // ( sum of all minor balances ) / conversion multiplier ), ) diff --git a/x/evmutil/testutil/suite.go b/x/evmutil/testutil/suite.go index 4447587c..5f7e0194 100644 --- a/x/evmutil/testutil/suite.go +++ b/x/evmutil/testutil/suite.go @@ -82,14 +82,14 @@ func (suite *Suite) SetupTest() { suite.Addrs = addrs evmGenesis := evmtypes.DefaultGenesisState() - evmGenesis.Params.EvmDenom = chaincfg.BaseDenom + evmGenesis.Params.EvmDenom = chaincfg.EvmDenom feemarketGenesis := feemarkettypes.DefaultGenesisState() feemarketGenesis.Params.EnableHeight = 1 feemarketGenesis.Params.NoBaseFee = false cdc := suite.App.AppCodec() - coins := sdk.NewCoins(sdk.NewInt64Coin(chaincfg.DisplayDenom, 1000_000_000_000)) + coins := sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 1000_000_000_000)) authGS := app.NewFundedGenStateWithSameCoins(cdc, coins, []sdk.AccAddress{ sdk.AccAddress(suite.Key1.PubKey().Address()), sdk.AccAddress(suite.Key2.PubKey().Address()), @@ -186,12 +186,12 @@ func (suite *Suite) ModuleBalance(denom string) sdk.Int { } func (suite *Suite) FundAccountWithZgChain(addr sdk.AccAddress, coins sdk.Coins) { - a0gi := coins.AmountOf(chaincfg.DisplayDenom) - if a0gi.IsPositive() { - err := suite.App.FundAccount(suite.Ctx, addr, sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, a0gi))) + ua0gi := coins.AmountOf("ua0gi") + if ua0gi.IsPositive() { + err := suite.App.FundAccount(suite.Ctx, addr, sdk.NewCoins(sdk.NewCoin("ua0gi", ua0gi))) suite.Require().NoError(err) } - neuron := coins.AmountOf(chaincfg.BaseDenom) + neuron := coins.AmountOf("neuron") if neuron.IsPositive() { err := suite.Keeper.SetBalance(suite.Ctx, addr, neuron) suite.Require().NoError(err) @@ -199,12 +199,12 @@ func (suite *Suite) FundAccountWithZgChain(addr sdk.AccAddress, coins sdk.Coins) } func (suite *Suite) FundModuleAccountWithZgChain(moduleName string, coins sdk.Coins) { - a0gi := coins.AmountOf(chaincfg.DisplayDenom) - if a0gi.IsPositive() { - err := suite.App.FundModuleAccount(suite.Ctx, moduleName, sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, a0gi))) + ua0gi := coins.AmountOf("ua0gi") + if ua0gi.IsPositive() { + err := suite.App.FundModuleAccount(suite.Ctx, moduleName, sdk.NewCoins(sdk.NewCoin("ua0gi", ua0gi))) suite.Require().NoError(err) } - neuron := coins.AmountOf(chaincfg.BaseDenom) + neuron := coins.AmountOf("neuron") if neuron.IsPositive() { addr := suite.AccountKeeper.GetModuleAddress(moduleName) err := suite.Keeper.SetBalance(suite.Ctx, addr, neuron) @@ -218,7 +218,7 @@ func (suite *Suite) DeployERC20() types.InternalEVMAddress { suite.App.FundModuleAccount( suite.Ctx, types.ModuleName, - sdk.NewCoins(sdk.NewCoin(chaincfg.DisplayDenom, sdkmath.NewInt(0))), + sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(0))), ) contractAddr, err := suite.Keeper.DeployTestMintableERC20Contract(suite.Ctx, "USDC", "USDC", uint8(18)) @@ -319,7 +319,7 @@ func (suite *Suite) SendTx( // Mint the max gas to the FeeCollector to ensure balance in case of refund suite.MintFeeCollector(sdk.NewCoins( sdk.NewCoin( - chaincfg.DisplayDenom, + "ua0gi", sdkmath.NewInt(baseFee.Int64()*int64(gasRes.Gas*2)), ))) diff --git a/x/issuance/legacy/v0_16/migrate_test.go b/x/issuance/legacy/v0_16/migrate_test.go index db5fe484..158920a2 100644 --- a/x/issuance/legacy/v0_16/migrate_test.go +++ b/x/issuance/legacy/v0_16/migrate_test.go @@ -63,7 +63,7 @@ func (s *migrateTestSuite) TestMigrate_JSON() { }, "supplies": [ { - "current_supply": { "denom": "neuron", "amount": "100000000000000" }, + "current_supply": { "denom": "ua0gi", "amount": "100" }, "time_elapsed": "3600000000000" }, { @@ -96,7 +96,7 @@ func (s *migrateTestSuite) TestMigrate_JSON() { }, "supplies": [ { - "current_supply": { "denom": "neuron", "amount": "100000000000000" }, + "current_supply": { "denom": "ua0gi", "amount": "100" }, "time_elapsed": "3600s" }, { @@ -115,7 +115,7 @@ func (s *migrateTestSuite) TestMigrate_Params() { Assets: v015issuance.Assets{ { Owner: s.addresses[0], - Denom: "neuron", + Denom: "ua0gi", BlockedAddresses: s.addresses[1:2], Paused: true, Blockable: true, @@ -131,7 +131,7 @@ func (s *migrateTestSuite) TestMigrate_Params() { Assets: []v016issuance.Asset{ { Owner: s.addresses[0].String(), - Denom: "neuron", + Denom: "ua0gi", BlockedAddresses: []string{s.addresses[1].String()}, Paused: true, Blockable: true, @@ -150,7 +150,7 @@ func (s *migrateTestSuite) TestMigrate_Params() { func (s *migrateTestSuite) TestMigrate_Supplies() { s.v15genstate.Supplies = v015issuance.AssetSupplies{ { - CurrentSupply: sdk.NewCoin("neuron", sdkmath.NewInt(100000000000000)), + CurrentSupply: sdk.NewCoin("ua0gi", sdkmath.NewInt(100)), TimeElapsed: time.Duration(1 * time.Hour), }, { @@ -160,7 +160,7 @@ func (s *migrateTestSuite) TestMigrate_Supplies() { } expected := []v016issuance.AssetSupply{ { - CurrentSupply: sdk.NewCoin("neuron", sdkmath.NewInt(100000000000000)), + CurrentSupply: sdk.NewCoin("ua0gi", sdkmath.NewInt(100)), TimeElapsed: time.Duration(1 * time.Hour), }, { diff --git a/x/validator-vesting/querier.go b/x/validator-vesting/querier.go index a83eefb9..92c44027 100644 --- a/x/validator-vesting/querier.go +++ b/x/validator-vesting/querier.go @@ -41,7 +41,7 @@ func NewQuerier(bk types.BankKeeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Qu } func queryGetTotalSupply(ctx sdk.Context, req abci.RequestQuery, bk types.BankKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - totalSupply := bk.GetSupply(ctx, "a0gi").Amount + totalSupply := bk.GetSupply(ctx, "ua0gi").Amount supplyInt := sdk.NewDecFromInt(totalSupply).Mul(sdk.MustNewDecFromStr("0.000001")).TruncateInt64() bz, err := legacyQuerierCdc.MarshalJSON(supplyInt) if err != nil { @@ -51,7 +51,7 @@ func queryGetTotalSupply(ctx sdk.Context, req abci.RequestQuery, bk types.BankKe } func queryGetCirculatingSupply(ctx sdk.Context, req abci.RequestQuery, bk types.BankKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - totalSupply := bk.GetSupply(ctx, "a0gi").Amount + totalSupply := bk.GetSupply(ctx, "ua0gi").Amount supplyInt := getCirculatingSupply(ctx.BlockTime(), totalSupply) bz, err := legacyQuerierCdc.MarshalJSON(supplyInt) if err != nil {