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

refactor(devgas): For #1866 #2199

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ needed to include double quotes around the hexadecimal string.
- [#2192](https://github.com/NibiruChain/nibiru/pull/2192) - fix(oracle): correctly handle misscount
- [#2197](https://github.com/NibiruChain/nibiru/pull/2197) - chore(evm): Create ethers v6 adapters for Nibiru. Publish as a library on npm (`@nibiruchain/evm-core`)
- [#2200](https://github.com/NibiruChain/nibiru/pull/2200) - fix(test): evm e2e oracle test fixed pair name
- [#2199](https://github.com/NibiruChain/nibiru/pull/2199) - refactor(devgas): For #1866

#### Nibiru EVM | Before Audit 2 - 2024-12-06

Expand Down
2 changes: 1 addition & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/NibiruChain/nibiru/v2/app/ante"
"github.com/NibiruChain/nibiru/v2/app/evmante"
devgasante "github.com/NibiruChain/nibiru/v2/x/devgas/v1/ante"
devgasante "github.com/NibiruChain/nibiru/v2/x/devgas/ante"
)

// NewAnteHandler returns and AnteHandler that checks and increments sequence
Expand Down
4 changes: 2 additions & 2 deletions app/ante/handler_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

devgasante "github.com/NibiruChain/nibiru/v2/x/devgas/v1/ante"
devgaskeeper "github.com/NibiruChain/nibiru/v2/x/devgas/v1/keeper"
devgasante "github.com/NibiruChain/nibiru/v2/x/devgas/ante"
devgaskeeper "github.com/NibiruChain/nibiru/v2/x/devgas/keeper"
evmkeeper "github.com/NibiruChain/nibiru/v2/x/evm/keeper"
)

Expand Down
20 changes: 10 additions & 10 deletions app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ import (
"github.com/NibiruChain/nibiru/v2/app/wasmext"
"github.com/NibiruChain/nibiru/v2/eth"
"github.com/NibiruChain/nibiru/v2/x/common"
"github.com/NibiruChain/nibiru/v2/x/devgas/v1"
devgaskeeper "github.com/NibiruChain/nibiru/v2/x/devgas/v1/keeper"
devgastypes "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types"
"github.com/NibiruChain/nibiru/v2/x/devgas"
"github.com/NibiruChain/nibiru/v2/x/devgas/devgasmodule"
devgaskeeper "github.com/NibiruChain/nibiru/v2/x/devgas/keeper"
"github.com/NibiruChain/nibiru/v2/x/epochs"
epochskeeper "github.com/NibiruChain/nibiru/v2/x/epochs/keeper"
epochstypes "github.com/NibiruChain/nibiru/v2/x/epochs/types"
Expand Down Expand Up @@ -205,7 +205,7 @@ func initStoreKeys() (
inflationtypes.StoreKey,
sudotypes.StoreKey,
wasmtypes.StoreKey,
devgastypes.StoreKey,
devgas.StoreKey,
tokenfactorytypes.StoreKey,

evm.StoreKey,
Expand Down Expand Up @@ -508,7 +508,7 @@ func (app *NibiruApp) InitKeepers(

// DevGas uses WasmKeeper
app.DevGasKeeper = devgaskeeper.NewKeeper(
keys[devgastypes.StoreKey],
keys[devgas.StoreKey],
appCodec,
app.BankKeeper,
app.WasmKeeper,
Expand Down Expand Up @@ -675,9 +675,9 @@ func (app *NibiruApp) initAppModules(
appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper,
app.BankKeeper, app.MsgServiceRouter(),
app.GetSubspace(wasmtypes.ModuleName)),
devgas.NewAppModule(
devgasmodule.NewAppModule(
app.DevGasKeeper, app.AccountKeeper,
app.GetSubspace(devgastypes.ModuleName)),
app.GetSubspace(devgas.ModuleName)),
tokenfactory.NewAppModule(
app.TokenFactoryKeeper, app.AccountKeeper,
),
Expand Down Expand Up @@ -745,7 +745,7 @@ func orderedModuleNames() []string {
// --------------------------------------------------------------------
// CosmWasm
wasmtypes.ModuleName,
devgastypes.ModuleName,
devgas.ModuleName,
tokenfactorytypes.ModuleName,

// Everything else should be before genmsg
Expand Down Expand Up @@ -851,7 +851,7 @@ func ModuleBasicManager() module.BasicManager {
inflation.AppModuleBasic{},
sudo.AppModuleBasic{},
wasm.AppModuleBasic{},
devgas.AppModuleBasic{},
devgasmodule.AppModuleBasic{},
tokenfactory.AppModuleBasic{},
ibcfee.AppModuleBasic{},
genmsg.AppModule{},
Expand Down Expand Up @@ -904,7 +904,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(icahosttypes.SubModuleName)
// wasm params keepers
paramsKeeper.Subspace(wasmtypes.ModuleName)
paramsKeeper.Subspace(devgastypes.ModuleName)
paramsKeeper.Subspace(devgas.ModuleName)

return paramsKeeper
}
Expand Down
2 changes: 1 addition & 1 deletion app/keepers/all_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
// Nibiru Custom Modules

"github.com/NibiruChain/nibiru/v2/app/wasmext"
devgaskeeper "github.com/NibiruChain/nibiru/v2/x/devgas/v1/keeper"
devgaskeeper "github.com/NibiruChain/nibiru/v2/x/devgas/keeper"
epochskeeper "github.com/NibiruChain/nibiru/v2/x/epochs/keeper"
evmkeeper "github.com/NibiruChain/nibiru/v2/x/evm/keeper"
inflationkeeper "github.com/NibiruChain/nibiru/v2/x/inflation/keeper"
Expand Down
4 changes: 2 additions & 2 deletions app/simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (

"github.com/NibiruChain/nibiru/v2/app"
"github.com/NibiruChain/nibiru/v2/app/codec"
devgastypes "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types"
devgas "github.com/NibiruChain/nibiru/v2/x/devgas"
epochstypes "github.com/NibiruChain/nibiru/v2/x/epochs/types"
inflationtypes "github.com/NibiruChain/nibiru/v2/x/inflation/types"
oracletypes "github.com/NibiruChain/nibiru/v2/x/oracle/types"
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestAppImportExport(t *testing.T) {
{oldApp.GetKey(evidencetypes.StoreKey), newApp.GetKey(evidencetypes.StoreKey), [][]byte{}},
{oldApp.GetKey(capabilitytypes.StoreKey), newApp.GetKey(capabilitytypes.StoreKey), [][]byte{}},
{oldApp.GetKey(authzkeeper.StoreKey), newApp.GetKey(authzkeeper.StoreKey), [][]byte{authzkeeper.GrantKey, authzkeeper.GrantQueuePrefix}},
{oldApp.GetKey(devgastypes.StoreKey), newApp.GetKey(devgastypes.StoreKey), [][]byte{}},
{oldApp.GetKey(devgas.StoreKey), newApp.GetKey(devgas.StoreKey), [][]byte{}},
{oldApp.GetKey(epochstypes.StoreKey), newApp.GetKey(epochstypes.StoreKey), [][]byte{}},
{oldApp.GetKey(inflationtypes.StoreKey), newApp.GetKey(inflationtypes.StoreKey), [][]byte{}},
{oldApp.GetKey(oracletypes.StoreKey), newApp.GetKey(oracletypes.StoreKey), [][]byte{}},
Expand Down
2 changes: 1 addition & 1 deletion app/wasmext/stargate_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package wasmext
import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"

devgas "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types"
devgas "github.com/NibiruChain/nibiru/v2/x/devgas"
epochs "github.com/NibiruChain/nibiru/v2/x/epochs/types"
inflation "github.com/NibiruChain/nibiru/v2/x/inflation/types"
oracle "github.com/NibiruChain/nibiru/v2/x/oracle/types"
Expand Down
2 changes: 1 addition & 1 deletion app/wasmext/stargate_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/NibiruChain/nibiru/v2/x/common/set"

devgas "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types"
devgas "github.com/NibiruChain/nibiru/v2/x/devgas"
epochs "github.com/NibiruChain/nibiru/v2/x/epochs/types"
inflation "github.com/NibiruChain/nibiru/v2/x/inflation/types"
oracle "github.com/NibiruChain/nibiru/v2/x/oracle/types"
Expand Down
2 changes: 1 addition & 1 deletion gosdk/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
wasm "github.com/CosmWasm/wasmd/x/wasm/types"
"google.golang.org/grpc"

devgas "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types"
devgas "github.com/NibiruChain/nibiru/v2/x/devgas"
epochs "github.com/NibiruChain/nibiru/v2/x/epochs/types"
"github.com/NibiruChain/nibiru/v2/x/evm"
inflation "github.com/NibiruChain/nibiru/v2/x/inflation/types"
Expand Down
2 changes: 1 addition & 1 deletion proto/nibiru/devgas/v1/devgas.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax = "proto3";
package nibiru.devgas.v1;

option go_package = "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types";
option go_package = "github.com/NibiruChain/nibiru/v2/x/devgas";

Check failure on line 4 in proto/nibiru/devgas/v1/devgas.proto

View workflow job for this annotation

GitHub Actions / break-check

File option "go_package" changed from "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types" to "github.com/NibiruChain/nibiru/v2/x/devgas".

// FeeShare defines an instance that organizes fee distribution conditions for
// the owner of a given smart contract
Expand Down
2 changes: 1 addition & 1 deletion proto/nibiru/devgas/v1/event.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax = "proto3";
package nibiru.devgas.v1;

option go_package = "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types";
option go_package = "github.com/NibiruChain/nibiru/v2/x/devgas";

Check failure on line 4 in proto/nibiru/devgas/v1/event.proto

View workflow job for this annotation

GitHub Actions / break-check

File option "go_package" changed from "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types" to "github.com/NibiruChain/nibiru/v2/x/devgas".

// ABCI event emitted when a deployer registers a contract to receive fee
// sharing payouts, specifying the deployer, contract, and withdrawer addresses.
Expand Down
2 changes: 1 addition & 1 deletion proto/nibiru/devgas/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import "nibiru/devgas/v1/devgas.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types";
option go_package = "github.com/NibiruChain/nibiru/v2/x/devgas";

Check failure on line 6 in proto/nibiru/devgas/v1/genesis.proto

View workflow job for this annotation

GitHub Actions / break-check

File option "go_package" changed from "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types" to "github.com/NibiruChain/nibiru/v2/x/devgas".

// GenesisState defines the module's genesis state.
message GenesisState {
Expand Down
2 changes: 1 addition & 1 deletion proto/nibiru/devgas/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";

option go_package = "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types";
option go_package = "github.com/NibiruChain/nibiru/v2/x/devgas";

Check failure on line 10 in proto/nibiru/devgas/v1/query.proto

View workflow job for this annotation

GitHub Actions / break-check

File option "go_package" changed from "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types" to "github.com/NibiruChain/nibiru/v2/x/devgas".

// Query defines the gRPC querier service.
service Query {
Expand Down
2 changes: 1 addition & 1 deletion proto/nibiru/devgas/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import "cosmos_proto/cosmos.proto";
import "nibiru/devgas/v1/genesis.proto";

option go_package = "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types";
option go_package = "github.com/NibiruChain/nibiru/v2/x/devgas";

Check failure on line 11 in proto/nibiru/devgas/v1/tx.proto

View workflow job for this annotation

GitHub Actions / break-check

File option "go_package" changed from "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types" to "github.com/NibiruChain/nibiru/v2/x/devgas".

// Msg defines the fees Msg service.
service Msg {
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions x/devgas/v1/ante/ante.go → x/devgas/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

devgastypes "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types"
"github.com/NibiruChain/nibiru/v2/x/devgas"
)

var _ sdk.AnteDecorator = (*DevGasPayoutDecorator)(nil)
Expand Down Expand Up @@ -77,11 +77,11 @@

bz, err := json.Marshal(feesPaidOutput)
if err != nil {
return devgastypes.ErrFeeSharePayment.Wrapf("failed to marshal feesPaidOutput: %s", err.Error())
return devgas.ErrFeeSharePayment.Wrapf("failed to marshal feesPaidOutput: %s", err.Error())

Check warning on line 80 in x/devgas/ante/ante.go

View check run for this annotation

Codecov / codecov/patch

x/devgas/ante/ante.go#L80

Added line #L80 was not covered by tests
}

return ctx.EventManager().EmitTypedEvent(
&devgastypes.EventPayoutDevGas{Payouts: string(bz)},
&devgas.EventPayoutDevGas{Payouts: string(bz)},
)
}

Expand All @@ -92,7 +92,7 @@

// settleFeePayments sends the funds to the contract developers
func (a DevGasPayoutDecorator) settleFeePayments(
ctx sdk.Context, toPay []sdk.AccAddress, params devgastypes.ModuleParams, totalFees sdk.Coins,
ctx sdk.Context, toPay []sdk.AccAddress, params devgas.ModuleParams, totalFees sdk.Coins,
) ([]FeeSharePayoutEventOutput, error) {
allowedFees := getAllowedFees(params, totalFees)

Expand All @@ -111,7 +111,7 @@
}

if err != nil {
return nil, devgastypes.ErrFeeSharePayment.Wrapf("failed to pay allowedFees to contract developer: %s", err.Error())
return nil, devgas.ErrFeeSharePayment.Wrapf("failed to pay allowedFees to contract developer: %s", err.Error())
}
}
}
Expand All @@ -121,7 +121,7 @@

// getAllowedFees gets the allowed fees to be paid based on the module
// parameters of x/devgas
func getAllowedFees(params devgastypes.ModuleParams, totalFees sdk.Coins) sdk.Coins {
func getAllowedFees(params devgas.ModuleParams, totalFees sdk.Coins) sdk.Coins {
// Get only allowed governance fees to be paid (helps for taxes)
var allowedFees sdk.Coins
if len(params.AllowedDenoms) == 0 {
Expand Down
18 changes: 9 additions & 9 deletions x/devgas/v1/ante/ante_test.go → x/devgas/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/NibiruChain/nibiru/v2/app"
"github.com/NibiruChain/nibiru/v2/x/common/testutil"
"github.com/NibiruChain/nibiru/v2/x/common/testutil/testapp"
devgasante "github.com/NibiruChain/nibiru/v2/x/devgas/v1/ante"
devgastypes "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types"
devgas "github.com/NibiruChain/nibiru/v2/x/devgas"
devgasante "github.com/NibiruChain/nibiru/v2/x/devgas/ante"
)

type AnteTestSuite struct {
Expand Down Expand Up @@ -145,8 +145,8 @@ func (suite *AnteTestSuite) TestDevGasPayout() {
}
devGasForWithdrawer := func(
contractIdx int, withdrawerIdx int,
) devgastypes.FeeShare {
return devgastypes.FeeShare{
) devgas.FeeShare {
return devgas.FeeShare{
ContractAddress: contracts[contractIdx].String(),
DeployerAddress: deployerAddr.String(),
WithdrawerAddress: withdrawAddrs[withdrawerIdx].String(),
Expand All @@ -155,14 +155,14 @@ func (suite *AnteTestSuite) TestDevGasPayout() {

testCases := []struct {
name string
devGasState []devgastypes.FeeShare
devGasState []devgas.FeeShare
wantWithdrawerRoyalties sdk.Coins
wantErr bool
setup func() (*app.NibiruApp, sdk.Context)
}{
{
name: "1 contract, 1 exec, 1 withdrawer",
devGasState: []devgastypes.FeeShare{
devGasState: []devgas.FeeShare{
devGasForWithdrawer(0, 0),
},
// The expected royalty is gas / num_withdrawers / 2. Thus, We
Expand All @@ -180,7 +180,7 @@ func (suite *AnteTestSuite) TestDevGasPayout() {
},
{
name: "1 contract, 4 exec, 2 withdrawer",
devGasState: []devgastypes.FeeShare{
devGasState: []devgas.FeeShare{
devGasForWithdrawer(0, 0),
devGasForWithdrawer(1, 0),
devGasForWithdrawer(2, 1),
Expand All @@ -201,7 +201,7 @@ func (suite *AnteTestSuite) TestDevGasPayout() {
},
{
name: "err: empty fee collector module account",
devGasState: []devgastypes.FeeShare{
devGasState: []devgas.FeeShare{
devGasForWithdrawer(0, 0),
},
// The expected royalty is gas / num_withdrawers / 2. Thus, We
Expand All @@ -216,7 +216,7 @@ func (suite *AnteTestSuite) TestDevGasPayout() {
},
{
name: "happy: no registered dev gas contracts",
devGasState: []devgastypes.FeeShare{},
devGasState: []devgas.FeeShare{},
// The expected royalty is gas / num_withdrawers / 2. Thus, We
// divide gas by (num_withdrawers * 2). The 2 comes from 50% split.
// wantWithdrawerRoyalties: num_withdrawers * 2 = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package ante
import (
sdk "github.com/cosmos/cosmos-sdk/types"

devgastypes "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types"
"github.com/NibiruChain/nibiru/v2/x/devgas"
)

type BankKeeper interface {
Expand All @@ -20,6 +20,6 @@ type BankKeeper interface {
}

type IDevGasKeeper interface {
GetParams(ctx sdk.Context) devgastypes.ModuleParams
GetFeeShare(ctx sdk.Context, contract sdk.Address) (devgastypes.FeeShare, bool)
GetParams(ctx sdk.Context) devgas.ModuleParams
GetFeeShare(ctx sdk.Context, contract sdk.Address) (devgas.FeeShare, bool)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

"github.com/NibiruChain/nibiru/v2/x/common/testutil"
devgas "github.com/NibiruChain/nibiru/v2/x/devgas/v1"
"github.com/NibiruChain/nibiru/v2/x/devgas/v1/client/cli"
"github.com/NibiruChain/nibiru/v2/x/devgas/client/cli"
"github.com/NibiruChain/nibiru/v2/x/devgas/devgasmodule"
)

// CLITestSuite: Tests all tx commands for the module.
Expand All @@ -43,7 +43,7 @@ func TestCLITestSuite(t *testing.T) {

// Runs once before the entire test suite.
func (s *CLITestSuite) SetupSuite() {
s.encCfg = testutilmod.MakeTestEncodingConfig(devgas.AppModuleBasic{})
s.encCfg = testutilmod.MakeTestEncodingConfig(devgasmodule.AppModuleBasic{})
s.keyring = keyring.NewInMemory(s.encCfg.Codec)
s.baseCtx = sdkclient.Context{}.
WithKeyring(s.keyring).
Expand Down
Loading
Loading