Skip to content

Commit

Permalink
Update iritamod and module definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
cyilong committed Jun 5, 2024
1 parent bf0ab63 commit b3c84ec
Show file tree
Hide file tree
Showing 21 changed files with 27 additions and 336 deletions.
2 changes: 0 additions & 2 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"runtime/debug"

evmmoduleante "github.com/bianjieai/irita/modules/evm"
"github.com/bianjieai/iritamod/modules/perm"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand All @@ -19,7 +18,6 @@ import (
)

type HandlerOptions struct {
PermKeeper perm.Keeper
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
FeegrantKeeper authante.FeegrantKeeper
Expand Down
6 changes: 0 additions & 6 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ante

import (
evmmoduleante "github.com/bianjieai/irita/modules/evm"
"github.com/bianjieai/iritamod/modules/perm"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
tokenkeeper "github.com/irisnet/irismod/modules/token/keeper"
Expand All @@ -13,8 +12,6 @@ func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ethermintante.NewEthSetUpContextDecorator(options.EvmKeeper), // outermost AnteDecorator. SetUpContext must be called first

perm.NewAuthDecorator(options.PermKeeper),
evmmoduleante.NewEthContractCallableDecorator(options.PermKeeper),
evmmoduleante.NewEthSigVerificationDecorator(options.EvmKeeper, options.AccountKeeper, options.SignModeHandler),

ethermintante.NewEthMempoolFeeDecorator(options.EvmKeeper), // Check eth effective gas price against minimal-gas-prices
Expand All @@ -30,7 +27,6 @@ func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
perm.NewAuthDecorator(options.PermKeeper),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
Expand All @@ -53,8 +49,6 @@ func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
ante.NewSetUpContextDecorator(),

// perm check
perm.NewAuthDecorator(options.PermKeeper),
evmmoduleante.NewEthContractCallableDecorator(options.PermKeeper),
evmmoduleante.NewEthSigVerificationDecorator(options.EvmKeeper, options.AccountKeeper, options.SignModeHandler),

// NOTE: extensions option decorator removed
Expand Down
63 changes: 0 additions & 63 deletions app/ante/perm.go

This file was deleted.

16 changes: 0 additions & 16 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ import (
nodekeeper "github.com/bianjieai/iritamod/modules/node/keeper"
nodetypes "github.com/bianjieai/iritamod/modules/node/types"
cparams "github.com/bianjieai/iritamod/modules/params"
"github.com/bianjieai/iritamod/modules/perm"
permkeeper "github.com/bianjieai/iritamod/modules/perm/keeper"
permtypes "github.com/bianjieai/iritamod/modules/perm/types"
cslashing "github.com/bianjieai/iritamod/modules/slashing"
"github.com/bianjieai/iritamod/modules/upgrade"
upgradekeeper "github.com/bianjieai/iritamod/modules/upgrade/keeper"
Expand Down Expand Up @@ -146,7 +143,6 @@ var storeKeys = []string{
servicetypes.StoreKey,
oracletypes.StoreKey,
randomtypes.StoreKey,
permtypes.StoreKey,
identitytypes.StoreKey,
nodetypes.StoreKey,
tibchost.StoreKey,
Expand Down Expand Up @@ -181,7 +177,6 @@ var (
service.AppModuleBasic{},
oracle.AppModuleBasic{},
random.AppModuleBasic{},
perm.AppModuleBasic{},
identity.AppModuleBasic{},
node.AppModuleBasic{},
tibc.AppModule{},
Expand Down Expand Up @@ -263,7 +258,6 @@ type IritaApp struct {
serviceKeeper servicekeeper.Keeper
oracleKeeper oraclekeeper.Keeper
randomKeeper randomkeeper.Keeper
permKeeper permkeeper.Keeper
identityKeeper identitykeeper.Keeper
nodeKeeper nodekeeper.Keeper
feeGrantKeeper feegrantkeeper.Keeper
Expand Down Expand Up @@ -379,9 +373,6 @@ func NewIritaApp(
stakingtypes.NewMultiStakingHooks(app.slashingKeeper.Hooks()),
)

permKeeper := permkeeper.NewKeeper(appCodec, keys[permtypes.StoreKey])
app.permKeeper = appante.RegisterAccessControl(permKeeper)

app.identityKeeper = identitykeeper.NewKeeper(appCodec, keys[identitytypes.StoreKey])

// evm
Expand Down Expand Up @@ -448,7 +439,6 @@ func NewIritaApp(
service.NewAppModule(appCodec, app.serviceKeeper, app.accountKeeper, app.bankKeeper),
oracle.NewAppModule(appCodec, app.oracleKeeper, app.accountKeeper, app.bankKeeper),
random.NewAppModule(appCodec, app.randomKeeper, app.accountKeeper, app.bankKeeper),
perm.NewAppModule(appCodec, app.permKeeper),
identity.NewAppModule(app.identityKeeper),
record.NewAppModule(appCodec, app.recordKeeper, app.accountKeeper, app.bankKeeper),
node.NewAppModule(appCodec, app.nodeKeeper),
Expand All @@ -467,7 +457,6 @@ func NewIritaApp(
app.mm.SetOrderBeginBlockers(
paramstypes.ModuleName,
upgradetypes.ModuleName,
permtypes.ModuleName,
authtypes.ModuleName,
nodetypes.ModuleName,
banktypes.ModuleName,
Expand All @@ -494,7 +483,6 @@ func NewIritaApp(
app.mm.SetOrderEndBlockers(
paramstypes.ModuleName,
upgradetypes.ModuleName,
permtypes.ModuleName,
authtypes.ModuleName,
nodetypes.ModuleName,
banktypes.ModuleName,
Expand Down Expand Up @@ -527,7 +515,6 @@ func NewIritaApp(
app.mm.SetOrderInitGenesis(
paramstypes.ModuleName,
upgradetypes.ModuleName,
permtypes.ModuleName,
authtypes.ModuleName,
nodetypes.ModuleName,
banktypes.ModuleName,
Expand Down Expand Up @@ -555,7 +542,6 @@ func NewIritaApp(
app.mm.SetOrderMigrations(
paramstypes.ModuleName,
upgradetypes.ModuleName,
permtypes.ModuleName,
authtypes.ModuleName,
nodetypes.ModuleName,
banktypes.ModuleName,
Expand Down Expand Up @@ -603,7 +589,6 @@ func NewIritaApp(
service.NewAppModule(appCodec, app.serviceKeeper, app.accountKeeper, app.bankKeeper),
oracle.NewAppModule(appCodec, app.oracleKeeper, app.accountKeeper, app.bankKeeper),
random.NewAppModule(appCodec, app.randomKeeper, app.accountKeeper, app.bankKeeper),
perm.NewAppModule(appCodec, app.permKeeper),
identity.NewAppModule(app.identityKeeper),
node.NewAppModule(appCodec, app.nodeKeeper),
tibc.NewAppModule(app.tibcKeeper),
Expand All @@ -626,7 +611,6 @@ func NewIritaApp(
app.SetBeginBlocker(app.BeginBlocker)
anteHandler := appante.NewAnteHandler(
appante.HandlerOptions{
PermKeeper: app.permKeeper,
AccountKeeper: app.accountKeeper,
BankKeeper: app.bankKeeper,
TokenKeeper: app.tokenKeeper,
Expand Down
17 changes: 1 addition & 16 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/tmhash"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

Expand All @@ -21,12 +20,10 @@ import (
tokentypes "github.com/irisnet/irismod/modules/token/types"

"github.com/bianjieai/iritamod/modules/node"
"github.com/bianjieai/iritamod/modules/perm"
)

var (
rootAdmin = sdk.AccAddress(tmhash.SumTruncated([]byte("rootAdmin")))
rootStr = `-----BEGIN CERTIFICATE-----
rootStr = `-----BEGIN CERTIFICATE-----
MIIBxTCCAXegAwIBAgIUHMPutrm+7FT7fIFf2fEgyQnIg8kwBQYDK2VwMFgxCzAJ
BgNVBAYTAkNOMQ0wCwYDVQQIDARyb290MQ0wCwYDVQQHDARyb290MQ0wCwYDVQQK
DARyb290MQ0wCwYDVQQLDARyb290MQ0wCwYDVQQDDARyb290MB4XDTIwMDYxOTA3
Expand Down Expand Up @@ -97,18 +94,6 @@ func setGenesis(iapp *IritaApp) error {
tokenGenState.Tokens = append(tokenGenState.Tokens, pointToken)
genesisState[tokentypes.ModuleName] = iapp.appCodec.MustMarshalJSON(&tokenGenState)

// add root admin
permGenState := perm.GetGenesisStateFromAppState(iapp.appCodec, genesisState)
permGenState.RoleAccounts = append(
permGenState.RoleAccounts,
perm.RoleAccount{
Address: rootAdmin.String(),
Roles: []perm.Role{perm.RoleRootAdmin},
},
)
permGenStateBz := iapp.cdc.MustMarshalJSON(permGenState)
genesisState[perm.ModuleName] = permGenStateBz

stateBytes, err := codec.MarshalJSONIndent(iapp.cdc, genesisState)
if err != nil {
return err
Expand Down
21 changes: 0 additions & 21 deletions cmd/irita/cmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
evmtypes "github.com/tharsis/ethermint/x/evm/types"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand All @@ -22,8 +21,6 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"

"github.com/bianjieai/iritamod/modules/perm"
)

const (
Expand Down Expand Up @@ -126,7 +123,6 @@ func AddGenesisAccountCmd(defaultNodeHome string, defaultCliHome string) *cobra.
}

authGenState := authtypes.GetGenesisStateFromAppState(cdc, appState)
permGenState := perm.GetGenesisStateFromAppState(cdc, appState)

accs, err := authtypes.UnpackAccounts(authGenState.Accounts)
if err != nil {
Expand All @@ -148,17 +144,6 @@ func AddGenesisAccountCmd(defaultNodeHome string, defaultCliHome string) *cobra.
}
authGenState.Accounts = genAccs

// Add root admin
if viper.GetBool(flagRootAdmin) {
permGenState.RoleAccounts = append(
permGenState.RoleAccounts,
perm.RoleAccount{
Address: addr.String(),
Roles: []perm.Role{perm.RoleRootAdmin},
},
)
}

authGenStateBz, err := cdc.MarshalJSON(&authGenState)
if err != nil {
return fmt.Errorf("failed to marshal auth genesis state: %w", err)
Expand All @@ -175,13 +160,7 @@ func AddGenesisAccountCmd(defaultNodeHome string, defaultCliHome string) *cobra.
return fmt.Errorf("failed to marshal bank genesis state: %w", err)
}

permGenStateBz, err := cdc.MarshalJSON(&permGenState)
if err != nil {
return fmt.Errorf("failed to marshal perm genesis state: %w", err)
}

appState[banktypes.ModuleName] = bankGenStateBz
appState[perm.ModuleName] = permGenStateBz

//evm config
var evmGenState evmtypes.GenesisState
Expand Down
4 changes: 2 additions & 2 deletions cmd/irita/cmd/genrootcert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"

"github.com/spf13/cobra"

Expand All @@ -29,7 +29,7 @@ func GenRootCert(defaultNodeHome string) *cobra.Command {
serverCtx := server.GetServerContextFromCmd(cmd)
config := serverCtx.Config

cert, err := ioutil.ReadFile(args[0])
cert, err := os.ReadFile(args[0])
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit b3c84ec

Please sign in to comment.