Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ localnet-build-env:
$(MAKE) -C contrib/images evmd-env

localnet-build-nodes:
$(DOCKER) run --rm -v $(CURDIR)/.testnets:/data cosmos/evmd \
$(DOCKER) run --rm --entrypoint evmd -v $(CURDIR)/.testnets:/data cosmos/evmd \
testnet init-files --validator-count 4 -o /data --starting-ip-address 192.168.10.2 --keyring-backend=test --chain-id=local-4221 --use-docker=true
docker compose up -d

Expand Down
2 changes: 2 additions & 0 deletions ante/cosmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
evmante "github.com/cosmos/evm/ante/evm"
evmtypes "github.com/cosmos/evm/x/vm/types"
ibcante "github.com/cosmos/ibc-go/v10/modules/core/ante"
poaante "github.com/xrplevm/node/v10/x/poa/ante"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand Down Expand Up @@ -40,5 +41,6 @@ func newCosmosAnteHandler(ctx sdk.Context, options HandlerOptions) sdk.AnteHandl
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
poaante.NewPoaDecorator(),
)
}
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ services:
evmdnode0:
container_name: evmdnode0
image: "cosmos/evmd"
entrypoint: ["/usr/bin/wrapper.sh"]
command: ["start", "--chain-id", "local-4221", "--json-rpc.api", "eth,txpool,personal,net,debug,web3"]
environment:
- DEBUG=0
- ID=0
Expand All @@ -28,6 +30,8 @@ services:
evmdnode1:
container_name: evmdnode1
image: "cosmos/evmd"
entrypoint: ["/usr/bin/wrapper.sh"]
command: ["start", "--chain-id", "local-4221", "--json-rpc.api", "eth,txpool,personal,net,debug,web3"]
environment:
- DEBUG=0
- ID=1
Expand All @@ -52,6 +56,8 @@ services:
evmdnode2:
container_name: evmdnode2
image: "cosmos/evmd"
entrypoint: ["/usr/bin/wrapper.sh"]
command: ["start", "--chain-id", "local-4221", "--json-rpc.api", "eth,txpool,personal,net,debug,web3"]
environment:
- DEBUG=0
- ID=2
Expand All @@ -76,6 +82,8 @@ services:
evmdnode3:
container_name: evmdnode3
image: "cosmos/evmd"
entrypoint: ["/usr/bin/wrapper.sh"]
command: ["start", "--chain-id", "local-4221", "--json-rpc.api", "eth,txpool,personal,net,debug,web3"]
environment:
- DEBUG=0
- ID=3
Expand Down
13 changes: 10 additions & 3 deletions evmd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ By default, this chain has the following configuration:

| Option | Value |
|---------------------|------------------------|
| Binary | `evmd` |
| Chain ID | `cosmos_262144-1` |
| Binary | `emvd` |
| Chain ID | `10740` |
| Custom Opcodes | - |
| Default Token Pairs | 1 for the native token |
| Denomination | `atest` |
| Denomination | `ogwei` |
| EVM permissioning | permissionless |
| Enabled Precompiles | all |

Expand Down Expand Up @@ -55,6 +55,12 @@ unhappy lunar seat`
![RPC URL Settings](guide/rpc_url.png "RPC URL")
![Overview of required settings](guide/settings.png "Settings Overview")

## Proof of Authority (PoA)

Currently this is a PoA chain. The validator set is managed through governance, not open staking. Regular staking transactions like delegate and undelegate are blocked at the ante handler level. Validators can only be added or removed via governance proposals. The PoA module is built by the [xrplevm/node](https://github.com/xrplevm/node) team.

See [evmd/docs/POA_ADD_VALIDATOR_VIA_GOV.md](docs/POA_ADD_VALIDATOR_VIA_GOV.md) for a step-by-step guide on adding a validator.

## Available Cosmos SDK Modules

As mentioned above, this exemplary chain implementation is a reduced version of `simapp`.
Expand All @@ -72,6 +78,7 @@ Specifically, instead of offering access to all Cosmos SDK modules, it just incl
- `gov`
- `mint`
- `params`
- `poa`
- `slashing`
- `staking`
- `upgrade`
44 changes: 43 additions & 1 deletion evmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,17 @@ import (
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/xrplevm/node/v10/x/poa"
poakeeper "github.com/xrplevm/node/v10/x/poa/keeper"
poatypes "github.com/xrplevm/node/v10/x/poa/types"
)

func init() {
Expand Down Expand Up @@ -160,6 +165,7 @@ type EVMD struct {

// keys to access the substores
keys map[string]*storetypes.KVStoreKey
tkeys map[string]*storetypes.TransientStoreKey
oKeys map[string]*storetypes.ObjectStoreKey

// keepers
Expand All @@ -175,6 +181,8 @@ type EVMD struct {
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper
ParamsKeeper paramskeeper.Keeper
PoaKeeper poakeeper.Keeper

// IBC keepers
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
Expand Down Expand Up @@ -233,12 +241,14 @@ func NewExampleApp(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, consensusparamtypes.StoreKey,
paramstypes.StoreKey,
upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, authzkeeper.StoreKey,
// ibc keys
ibcexported.StoreKey, ibctransfertypes.StoreKey,
// Cosmos EVM store keys
evmtypes.StoreKey, feemarkettypes.StoreKey, erc20types.StoreKey, precisebanktypes.StoreKey,
)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
oKeys := storetypes.NewObjectStoreKeys(banktypes.ObjectStoreKey, evmtypes.ObjectKey)

var nonTransientKeys []storetypes.StoreKey
Expand Down Expand Up @@ -267,10 +277,20 @@ func NewExampleApp(
txConfig: txConfig,
interfaceRegistry: interfaceRegistry,
keys: keys,
tkeys: tkeys,
oKeys: oKeys,
}

// removed x/params: no ParamsKeeper initialization
// params keeper is used by the PoA module
// it is deprecated in the SDK but still required for the xrplevm/node PoA keeper
app.ParamsKeeper = paramskeeper.NewKeeper(
appCodec,
legacyAmino,
keys[paramstypes.StoreKey],
tkeys[paramstypes.TStoreKey],
)
// Register subspace for PoA so GetSubspace(poatypes.ModuleName) returns a valid subspace.
app.ParamsKeeper.Subspace(poatypes.ModuleName).WithKeyTable(poatypes.ParamKeyTable())

// get authority address
authAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
Expand Down Expand Up @@ -550,6 +570,15 @@ func NewExampleApp(
tmLightClientModule := ibctm.NewLightClientModule(appCodec, storeProvider)
clientKeeper.AddRoute(ibctm.ModuleName, &tmLightClientModule)

app.PoaKeeper = *poakeeper.NewKeeper(
appCodec,
app.GetSubspace(poatypes.ModuleName),
app.MsgServiceRouter(),
app.BankKeeper,
app.StakingKeeper,
authAddr,
)

// Override the ICS20 app module
transferModule := transfer.NewAppModule(app.TransferKeeper)

Expand All @@ -570,6 +599,7 @@ func NewExampleApp(
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, nil, app.interfaceRegistry),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, nil),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, nil),
poa.NewAppModule(appCodec, app.PoaKeeper, app.BankKeeper, app.StakingKeeper, app.AccountKeeper, app.interfaceRegistry),
upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()),
evidence.NewAppModule(app.EvidenceKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
Expand Down Expand Up @@ -641,6 +671,7 @@ func NewExampleApp(
banktypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
poatypes.ModuleName,
authtypes.ModuleName,

// Cosmos EVM EndBlockers
Expand All @@ -662,6 +693,7 @@ func NewExampleApp(
genesisModuleOrder := []string{
authtypes.ModuleName, banktypes.ModuleName,
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
poatypes.ModuleName,
minttypes.ModuleName,
ibcexported.ModuleName,

Expand Down Expand Up @@ -718,6 +750,7 @@ func NewExampleApp(
// initialize stores
app.MountKVStores(keys)
app.MountObjectStores(oKeys)
app.MountTransientStores(tkeys)

maxGasWanted := cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted))

Expand Down Expand Up @@ -918,6 +951,15 @@ func (app *EVMD) GetKey(storeKey string) *storetypes.KVStoreKey {
return app.keys[storeKey]
}

// GetSubspace returns a params subspace for a given module name.
func (app *EVMD) GetSubspace(moduleName string) paramstypes.Subspace {
subspace, ok := app.ParamsKeeper.GetSubspace(moduleName)
if !ok {
panic(fmt.Sprintf("subspace for module %s not registered", moduleName))
}
return subspace
}

// SimulationManager implements the SimulationApp interface
func (app *EVMD) SimulationManager() *module.SimulationManager {
return app.sm
Expand Down
2 changes: 2 additions & 0 deletions evmd/config/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
precisebanktypes "github.com/cosmos/evm/x/precisebank/types"
vmtypes "github.com/cosmos/evm/x/vm/types"
transfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
poatypes "github.com/xrplevm/node/v10/x/poa/types"
corevm "github.com/ethereum/go-ethereum/core/vm"
)

Expand Down Expand Up @@ -59,6 +60,7 @@ var maccPerms = map[string][]string{
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
poatypes.ModuleName: {authtypes.Minter, authtypes.Burner},

// Cosmos EVM modules
vmtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
Expand Down
Loading
Loading