Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add module mint, feeburn #157

Merged
merged 60 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
fa6db55
feat: add NewMinGasPriceDecorator
Dec 20, 2022
65407dc
feat: add module feeburn
Dec 21, 2022
d6a96e7
refactor fee burn
Dec 22, 2022
08d4519
update proto and add some test
Dec 22, 2022
1606b27
add integration test
Dec 23, 2022
90af238
add test send batch transaction
Dec 23, 2022
9240375
update integration test
Dec 26, 2022
605cc5b
refactor add ante test
Dec 27, 2022
52f99f2
add integration test feeburn
Dec 28, 2022
564bf70
dev/mint (#155)
LampardNguyen234 Dec 28, 2022
0a2cc60
chore: remove proto unused
Dec 28, 2022
e95415e
test: fix unittest invalid denom
Dec 28, 2022
50c50f3
chore: remove code unused
Dec 28, 2022
e9dea88
Merge remote-tracking branch 'origin/module/feeburn' into astra
Dec 28, 2022
c45452c
refactor: update astra app
Dec 28, 2022
229a8fa
docs: add module feeburn
Dec 28, 2022
e7d17ef
fix: miss feeburn in ante handler
Dec 28, 2022
9edf7db
refactor: reorder module
Dec 29, 2022
8cfc678
chore(mint): add queryCirculatingSupply and queryBondedRatio methods
LampardNguyen234 Dec 30, 2022
22e273b
test(mint): update unit tests
LampardNguyen234 Dec 30, 2022
020ca98
feat: add feeburn rest api
Dec 31, 2022
9dc768a
chore: update swagger
Dec 31, 2022
9a5606f
chore: update script gen
Dec 31, 2022
6d12dc1
refactor: update proto
Dec 31, 2022
fd8da6d
test: add feeburn integration test
Dec 31, 2022
7f537ea
chore: upadte init.sh
Dec 31, 2022
ba08f65
feat: add get total_fee_burn in module fee
Dec 31, 2022
42930b3
chore: update init.sh
Jan 3, 2023
9ac6a01
test: update integration test feeburn
Jan 3, 2023
84d3056
test: add integration test evm tx
Jan 3, 2023
571425b
test: update integration test
Jan 3, 2023
b25af35
test: upadte integration tests for mint
LampardNguyen234 Jan 3, 2023
2a2cf73
Merge branch 'astra' of github.com:AstraProtocol/astra into astra
LampardNguyen234 Jan 3, 2023
6c68b8b
test: update integration test cases
LampardNguyen234 Jan 3, 2023
6ea7f3a
fix: totalBurnAmount incorrect
Jan 4, 2023
2ddc466
test: update integration tests for mint
LampardNguyen234 Jan 4, 2023
f10215e
test: update test_fee_payer
Jan 4, 2023
aeb3aab
test: update test_fee_payer (#159)
hoanguyenkh Jan 4, 2023
85246ba
test: update integration tests
LampardNguyen234 Jan 4, 2023
ef8ca4b
Merge remote-tracking branch 'origin/astra' into astra
Jan 4, 2023
2609375
Merge branch 'astra' of github.com:AstraProtocol/astra into astra
LampardNguyen234 Jan 4, 2023
d8cf3d0
Merge branch 'astra' of github.com:AstraProtocol/astra into astra
LampardNguyen234 Jan 4, 2023
e3a923a
test: update unittest for mint module
LampardNguyen234 Jan 5, 2023
6db8239
refactor: add handler errror (#160)
hoanguyenkh Jan 5, 2023
6f0b4b5
test(mint): disable integration tests
LampardNguyen234 Jan 5, 2023
fd347dd
Merge branch 'astra' of github.com:AstraProtocol/astra into astra
LampardNguyen234 Jan 5, 2023
03cece2
fix: integer overflow (#161)
hoanguyenkh Jan 5, 2023
4921651
refactor: add default DefaultMinGasPrice, DefaultMinGasMultiplier
Jan 5, 2023
092b845
refactor: remove upgrade handler
Jan 11, 2023
1b81258
refactor: remove default MinGasPrice
Jan 11, 2023
e338c18
add fork code update voting period (#163)
hoanguyenkh Jan 12, 2023
3879927
update UpgradeHeight
Jan 12, 2023
3adf727
update UpgradeHeight
Jan 12, 2023
56d9fa3
change update name
Jan 12, 2023
7f78292
test: check fee burn when test fail
Jan 16, 2023
a5647ef
chore: update changelog
Jan 31, 2023
3ac5161
chore: update Genesis Distribution
Jan 31, 2023
aab862a
deps: bump ginkgo to v2.7.1, gomega to v1.26.0
Jan 31, 2023
b3b3bee
chore: update CHANGELOG.md and refactor go.mod
Jan 31, 2023
40ae284
refactor: update logic check burn amount
Jan 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ante

import (
feeBurnKeeper "github.com/AstraProtocol/astra/v2/x/feeburn/keeper"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand All @@ -14,6 +15,8 @@ import (
ethante "github.com/evmos/ethermint/app/ante"
evmtypes "github.com/evmos/ethermint/x/evm/types"

feeburnante "github.com/AstraProtocol/astra/v2/x/feeburn/ante"
feeburntypes "github.com/AstraProtocol/astra/v2/x/feeburn/types"
vestingtypes "github.com/evmos/evmos/v6/x/vesting/types"
)

Expand All @@ -22,11 +25,13 @@ import (
type HandlerOptions struct {
AccountKeeper evmtypes.AccountKeeper
BankKeeper evmtypes.BankKeeper
BankKeeperFork feeburntypes.BankKeeper
IBCKeeper *ibckeeper.Keeper
FeeMarketKeeper evmtypes.FeeMarketKeeper
StakingKeeper vestingtypes.StakingKeeper
EvmKeeper ethante.EVMKeeper
FeegrantKeeper ante.FeegrantKeeper
FeeBurnKeeper feeBurnKeeper.Keeper
SignModeHandler authsigning.SignModeHandler
SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
Cdc codec.BinaryCodec
Expand Down Expand Up @@ -59,8 +64,9 @@ func (options HandlerOptions) Validate() error {
// newCosmosAnteHandler creates the default ante handler for Ethereum transactions
func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ethante.NewEthSetUpContextDecorator(options.EvmKeeper), // outermost AnteDecorator. SetUpContext must be called first
ethante.NewEthMempoolFeeDecorator(options.EvmKeeper), // Check eth effective gas price against minimal-gas-prices
ethante.NewEthSetUpContextDecorator(options.EvmKeeper), // outermost AnteDecorator. SetUpContext must be called first
ethante.NewEthMempoolFeeDecorator(options.EvmKeeper), // Check eth effective gas price against minimal-gas-prices
ethante.NewEthMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper), // Check eth effective gas price against the global MinGasPrice
ethante.NewEthValidateBasicDecorator(options.EvmKeeper),
ethante.NewEthSigVerificationDecorator(options.EvmKeeper),
ethante.NewEthAccountVerificationDecorator(options.AccountKeeper, options.EvmKeeper),
Expand All @@ -80,11 +86,13 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
ante.NewSetUpContextDecorator(),
ante.NewRejectExtensionOptionsDecorator(),
ante.NewMempoolFeeDecorator(),
ethante.NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
feeburnante.NewFeeBurnDecorator(options.BankKeeperFork, options.FeeBurnKeeper),
NewVestingDelegationDecorator(options.AccountKeeper, options.StakingKeeper, options.Cdc),
NewValidatorCommissionDecorator(options.Cdc),
// SetPubKeyDecorator must be called before all signature verification decorators
Expand All @@ -105,10 +113,12 @@ func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
ante.NewSetUpContextDecorator(),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ethante.NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
feeburnante.NewFeeBurnDecorator(options.BankKeeperFork, options.FeeBurnKeeper),
NewVestingDelegationDecorator(options.AccountKeeper, options.StakingKeeper, options.Cdc),
NewValidatorCommissionDecorator(options.Cdc),
// SetPubKeyDecorator must be called before all signature verification decorators
Expand Down
81 changes: 38 additions & 43 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ package app
import (
"context"
"encoding/json"
"github.com/AstraProtocol/astra/v2/x/inflation"
"github.com/evmos/evmos/v6/x/epochs"
"github.com/AstraProtocol/astra/v2/x/feeburn"
feeBurnKeeper "github.com/AstraProtocol/astra/v2/x/feeburn/keeper"
feeBurnTypes "github.com/AstraProtocol/astra/v2/x/feeburn/types"
"github.com/AstraProtocol/astra/v2/x/mint"
mintkeeper "github.com/AstraProtocol/astra/v2/x/mint/keeper"
minttypes "github.com/AstraProtocol/astra/v2/x/mint/types"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -108,8 +112,6 @@ import (
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"

"github.com/AstraProtocol/astra/v2/app/ante"
epochskeeper "github.com/evmos/evmos/v6/x/epochs/keeper"
epochstypes "github.com/evmos/evmos/v6/x/epochs/types"
"github.com/evmos/evmos/v6/x/erc20"
erc20client "github.com/evmos/evmos/v6/x/erc20/client"
erc20keeper "github.com/evmos/evmos/v6/x/erc20/keeper"
Expand All @@ -118,9 +120,6 @@ import (
vestingkeeper "github.com/evmos/evmos/v6/x/vesting/keeper"
vestingtypes "github.com/evmos/evmos/v6/x/vesting/types"

inflationkeeper "github.com/AstraProtocol/astra/v2/x/inflation/keeper"
inflationtypes "github.com/AstraProtocol/astra/v2/x/inflation/types"

v1_1 "github.com/AstraProtocol/astra/v2/app/upgrades/v1_1"
v2 "github.com/AstraProtocol/astra/v2/app/upgrades/v2"
)
Expand Down Expand Up @@ -180,9 +179,9 @@ var (
vesting.AppModuleBasic{},
evm.AppModuleBasic{},
feemarket.AppModuleBasic{},
inflation.AppModuleBasic{},
mint.AppModuleBasic{},
erc20.AppModuleBasic{},
epochs.AppModuleBasic{},
feeburn.AppModuleBasic{},
)

// module account permissions
Expand All @@ -195,7 +194,7 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
inflationtypes.ModuleName: {authtypes.Minter},
minttypes.ModuleName: {authtypes.Minter, authtypes.Burner},
erc20types.ModuleName: {authtypes.Minter, authtypes.Burner},
}

Expand Down Expand Up @@ -252,14 +251,14 @@ type Astra struct {
ScopedTransferKeeper capabilitykeeper.ScopedKeeper

// Ethermint keepers
Erc20Keeper erc20keeper.Keeper
EvmKeeper *evmkeeper.Keeper
FeeMarketKeeper feemarketkeeper.Keeper

// Astra keepers
InflationKeeper inflationkeeper.Keeper
Erc20Keeper erc20keeper.Keeper
EpochsKeeper epochskeeper.Keeper
VestingKeeper vestingkeeper.Keeper
MintKeeper mintkeeper.Keeper
VestingKeeper vestingkeeper.Keeper
FeeBurnKeeper feeBurnKeeper.Keeper

// the module manager
mm *module.Manager
Expand Down Expand Up @@ -315,10 +314,10 @@ func NewAstraApp(
// ethermint keys
evmtypes.StoreKey, feemarkettypes.StoreKey,
// astra keys
inflationtypes.StoreKey,
minttypes.StoreKey,
erc20types.StoreKey,
epochstypes.StoreKey,
vestingtypes.StoreKey,
feeBurnTypes.StoreKey,
)

// Add the EVM transient store key
Expand Down Expand Up @@ -361,14 +360,21 @@ func NewAstraApp(
stakingKeeper := stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName),
)
//app.MintKeeper = mintkeeper.NewKeeper(
// appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper,
// app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName,
//)
app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
)
app.MintKeeper = mintkeeper.NewKeeper(
appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper,
app.AccountKeeper, app.BankKeeper, app.DistrKeeper, authtypes.FeeCollectorName,
)
app.FeeBurnKeeper = feeBurnKeeper.NewKeeper(
appCodec,
keys[feeBurnTypes.StoreKey],
app.GetSubspace(feeBurnTypes.ModuleName),
app.BankKeeper,
authtypes.FeeCollectorName,
)
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
)
Expand Down Expand Up @@ -413,12 +419,6 @@ func NewAstraApp(
app.AccountKeeper, app.BankKeeper, &stakingKeeper, govRouter,
)

app.InflationKeeper = inflationkeeper.NewKeeper(
keys[inflationtypes.StoreKey], appCodec, app.GetSubspace(inflationtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, &stakingKeeper,
authtypes.FeeCollectorName,
)

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
// NOTE: Distr, Slashing and Claim must be created before calling the Hooks method to avoid returning a Keeper without its table generated
Expand All @@ -439,13 +439,6 @@ func NewAstraApp(
app.AccountKeeper, app.BankKeeper, app.EvmKeeper,
)

epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey])
app.EpochsKeeper = *epochsKeeper.SetHooks(
epochskeeper.NewMultiEpochHooks(
app.InflationKeeper.Hooks(),
),
)

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(),
)
Expand Down Expand Up @@ -530,10 +523,11 @@ func NewAstraApp(
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper),
feemarket.NewAppModule(app.FeeMarketKeeper),
// Astra app modules
inflation.NewAppModule(app.InflationKeeper, app.AccountKeeper, app.StakingKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
//inflation.NewAppModule(app.InflationKeeper, app.AccountKeeper, app.StakingKeeper),
erc20.NewAppModule(app.Erc20Keeper, app.AccountKeeper),
epochs.NewAppModule(appCodec, app.EpochsKeeper),
vesting.NewAppModule(app.VestingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
feeburn.NewAppModule(appCodec, app.FeeBurnKeeper, app.AccountKeeper, app.BankKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand All @@ -545,7 +539,6 @@ func NewAstraApp(
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
epochstypes.ModuleName,
feemarkettypes.ModuleName,
evmtypes.ModuleName,
//minttypes.ModuleName,
Expand All @@ -565,8 +558,9 @@ func NewAstraApp(
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
inflationtypes.ModuleName,
minttypes.ModuleName,
erc20types.ModuleName,
feeBurnTypes.ModuleName,
)

// NOTE: fee market module must go last in order to retrieve the block gas used.
Expand All @@ -576,7 +570,6 @@ func NewAstraApp(
stakingtypes.ModuleName,
evmtypes.ModuleName,
feemarkettypes.ModuleName,
epochstypes.ModuleName,
ibchost.ModuleName,
ibctransfertypes.ModuleName,
capabilitytypes.ModuleName,
Expand All @@ -593,8 +586,9 @@ func NewAstraApp(
upgradetypes.ModuleName,
// Astra modules
vestingtypes.ModuleName,
inflationtypes.ModuleName,
minttypes.ModuleName,
erc20types.ModuleName,
feeBurnTypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -627,8 +621,8 @@ func NewAstraApp(
// Astra modules
vestingtypes.ModuleName,
erc20types.ModuleName,
epochstypes.ModuleName,
inflationtypes.ModuleName,
minttypes.ModuleName,
feeBurnTypes.ModuleName,
// NOTE: crisis module must go at the end to check for invariants on each module
crisistypes.ModuleName,
)
Expand Down Expand Up @@ -661,7 +655,6 @@ func NewAstraApp(
ibc.NewAppModule(app.IBCKeeper),
transferModule,
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper),
epochs.NewAppModule(appCodec, app.EpochsKeeper),
feemarket.NewAppModule(app.FeeMarketKeeper),
)

Expand All @@ -679,6 +672,7 @@ func NewAstraApp(
options := ante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
BankKeeperFork: app.BankKeeper,
EvmKeeper: app.EvmKeeper,
StakingKeeper: app.StakingKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
Expand Down Expand Up @@ -938,8 +932,9 @@ func initParamsKeeper(
paramsKeeper.Subspace(evmtypes.ModuleName)
paramsKeeper.Subspace(feemarkettypes.ModuleName)
// astra subspaces
paramsKeeper.Subspace(inflationtypes.ModuleName)
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(erc20types.ModuleName)
paramsKeeper.Subspace(feeBurnTypes.ModuleName)
return paramsKeeper
}

Expand Down
8 changes: 8 additions & 0 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package app

import (
"encoding/json"
minttypes "github.com/AstraProtocol/astra/v2/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -64,6 +66,12 @@ func Setup(
// init chain must be called to stop deliverState from being nil
genesisState := NewDefaultGenesisState()

stakingGenesisState := stakingtypes.DefaultGenesisState()
stakingGenesisState.Params.BondDenom = minttypes.DefaultInflationDenom
encCfg := encoding.MakeConfig(ModuleBasics)
stakingGenesis := encCfg.Marshaler.MustMarshalJSON(stakingGenesisState)
genesisState[stakingtypes.ModuleName] = stakingGenesis

// Verify feeMarket genesis
if feemarketGenesis != nil {
if err := feemarketGenesis.Validate(); err != nil {
Expand Down
8 changes: 5 additions & 3 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
}
},
{
"url": "./tmp-swagger-gen/astra/inflation/v1/query.swagger.json",
"url": "./tmp-swagger-gen/astra/feeburn/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "InflationParams",
"TotalSupply": "InflationTotalSupply"
"Params": "FeeBurnParams"
}
}
},
Expand Down Expand Up @@ -82,6 +81,9 @@
{
"url": "./tmp-swagger-gen/cosmos/authz/v1beta1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/cosmos/mint/v1beta1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/cosmos/bank/v1beta1/query.swagger.json",
"operationIds": {
Expand Down
3 changes: 1 addition & 2 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading