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(genesis bridge): genesis transfers #279

Merged
merged 62 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
8b99b7a
for investigation
danwt May 22, 2024
447a1d0
swap relayer path direction
danwt May 22, 2024
7be8f24
integrate a new rdk middleware
danwt May 22, 2024
b0dd4ab
wire up the interceptor
danwt May 22, 2024
b3f4ddd
tweaks
danwt May 22, 2024
e0555ae
allow hubgenesis to send/receive
danwt May 22, 2024
fce9a6e
fix transfer plugin
danwt May 24, 2024
61e9b83
bump scripts to move the genesis accounts to the rollapp
danwt May 24, 2024
3e82b94
cp
danwt May 24, 2024
645da70
add burner and minter
danwt May 24, 2024
94dcf17
removes the module account funding from the genesis file
danwt May 24, 2024
c8dc299
confirms minting works
danwt May 24, 2024
493ff39
try out dasel in the genesis
danwt May 24, 2024
e852752
removes bogus todo
danwt May 24, 2024
30634d0
Revert "removes bogus todo"
danwt May 24, 2024
4a8fe14
Revert "try out dasel in the genesis"
danwt May 24, 2024
57f3a9a
clean up update genesis script
danwt May 24, 2024
78cca69
confirmining working state Monday morning
danwt May 28, 2024
1d11235
fix app go
danwt May 29, 2024
3db78be
mod tidy
danwt May 29, 2024
d3dd288
tidy
danwt May 29, 2024
dcdf6ff
bump script to use mnemonic for bob alice
danwt May 29, 2024
dd572bb
confirms working with denom
danwt May 29, 2024
2d7e249
fix genesis account generation script
danwt Jun 4, 2024
b964ef3
confirms working with skip ctx
danwt Jun 4, 2024
6dd38ac
fmt
danwt Jun 6, 2024
3a852e4
adds a build flags debug cmd to makefile
danwt Jun 6, 2024
3573048
next step: check that channel corresponds to the RA and set a canonic…
danwt Jun 6, 2024
7b9f9e8
post merge hub main, now going to do packet authenticity check
danwt Jun 7, 2024
dea326d
lets try to install
danwt Jun 11, 2024
b910ca7
confirm installs
danwt Jun 11, 2024
926b888
pre rebase to main
danwt Jun 11, 2024
188baa2
confirms installs
danwt Jun 11, 2024
c00ab94
fix scripts
danwt Jun 11, 2024
093fd16
block connection opening
danwt Jun 11, 2024
69ecdda
ready
danwt Jun 11, 2024
2ba0607
bump scripts
danwt Jun 12, 2024
52db286
new branch
danwt Jun 12, 2024
902ed71
reset makefile
danwt Jun 12, 2024
1abab16
bump
danwt Jun 12, 2024
fd0a18e
removes burner capability
danwt Jun 12, 2024
288f03a
confirms with manual test that the genesis accounts do receive their …
danwt Jun 12, 2024
c6ce9a9
app.go
danwt Jun 14, 2024
30c7131
removes replacements in go.mod
danwt Jun 19, 2024
495eecb
go mod tidy
danwt Jun 19, 2024
c75f115
updates readme
danwt Jun 19, 2024
5e66ce1
bump readme
danwt Jun 19, 2024
5d22e13
bump readme
danwt Jun 19, 2024
dc183c1
bump readme
danwt Jun 19, 2024
e90f832
go mod tidy
danwt Jun 20, 2024
43019c5
gonna try to rip out the denom meta stuff
danwt Jun 20, 2024
0486ffe
builds
danwt Jun 20, 2024
161f985
fix app.go
danwt Jun 20, 2024
21b3b02
fix constructor
danwt Jun 20, 2024
a93e74f
mod tidy and readme
danwt Jun 20, 2024
adc5a8f
confirms builds
danwt Jun 20, 2024
53ab1d4
go mod
danwt Jun 21, 2024
17aea90
bump
danwt Jun 21, 2024
d2653c9
mod tidy
danwt Jun 25, 2024
0326c6f
merge main but its broken
danwt Jun 25, 2024
7fe7c01
remove denom
danwt Jun 25, 2024
4fafcb7
golangcilint
danwt Jun 25, 2024
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
105 changes: 31 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ It uses Cosmos-SDK's [simapp](https://github.com/cosmos/cosmos-sdk/tree/main/sim

## Overview

**Note**: Requires [Go 1.22.1](https://go.dev/dl/)
**Note**: Requires [Go 1.22.1](https://go.dev/dl/). Requires [Dasel](https://formulae.brew.sh/formula/dasel) and [JQ](https://formulae.brew.sh/formula/jq).

## Installing / Getting started

Expand All @@ -25,24 +25,35 @@ Build and install the ```rollapp-evm``` binary:
```shell
export BECH32_PREFIX=ethm
make install BECH32_PREFIX=$BECH32_PREFIX
export EXECUTABLE="rollapp-evm"
```

### Initial configuration

export the following variables:

```shell
export EXECUTABLE="rollapp-evm"
export BECH32_PREFIX="ethm"
export ROLLAPP_CHAIN_ID="rollappevm_1234-1"
export KEY_NAME_ROLLAPP="rol-user"
export BASE_DENOM="arax"
export DENOM=$(echo "$BASE_DENOM" | sed 's/^.//')
export MONIKER="$ROLLAPP_CHAIN_ID-sequencer"

export ROLLAPP_HOME_DIR="$HOME/.rollapp_evm"
export ROLLAPP_SETTLEMENT_INIT_DIR_PATH="${ROLLAPP_HOME_DIR}/init"
export SKIP_EVM_BASE_FEE=true # optional, removes fees on the rollapp
export SKIP_EVM_BASE_FEE=true # optional, disables rollapp fees

$EXECUTABLE config keyring-backend test

# (if running hub too)
export HUB_KEY_WITH_FUNDS="hub-user"
export HUB_RPC_ENDPOINT="localhost"
export HUB_RPC_PORT="36657" # default: 36657
export HUB_RPC_URL="http://${HUB_RPC_ENDPOINT}:${HUB_RPC_PORT}"
export HUB_CHAIN_ID="dymension_100-1"

dymd config chain-id "${HUB_CHAIN_ID}"
dymd config node "${HUB_RPC_URL}"
dymd config keyring-backend test
```

And initialize the rollapp:
Expand All @@ -54,33 +65,20 @@ sh scripts/init.sh
### Run rollapp

```shell
rollapp-evm start
$EXECUTABLE start
```

You should have a running local rollapp!

## Run a rollapp with a settlement node
## Run a settlement node too

### Run local dymension hub node

Follow the instructions on [Dymension Hub docs](https://docs.dymension.xyz/develop/get-started/run-base-layers) to run local dymension hub node

all scripts are adjusted to use local hub node that's hosted on the default port `localhost:36657`.

configuration with a remote hub node is also supported, the following variables must be set:

```shell
export HUB_RPC_ENDPOINT="localhost"
export HUB_RPC_PORT="36657" # default: 36657

export HUB_RPC_URL="http://${HUB_RPC_ENDPOINT}:${HUB_RPC_PORT}"
export HUB_CHAIN_ID="dymension_100-1"

dymd config chain-id ${HUB_CHAIN_ID}
dymd config node ${HUB_RPC_URL}

export HUB_KEY_WITH_FUNDS="hub-user" # This key should exist on the keyring-backend test
```
configuration with a remote hub node is also supported. Configure env vars above appropriately (RPC_URL)

### Create sequencer keys

Expand Down Expand Up @@ -144,20 +142,13 @@ sh scripts/settlement/register_sequencer_to_hub.sh

Modify `dymint.toml` in the chain directory (`~/.rollapp_evm/config`)

linux:

```shell
sed -i 's/settlement_layer.*/settlement_layer = "dymension"/' ${ROLLAPP_HOME_DIR}/config/dymint.toml
sed -i '/node_address =/c\node_address = '\"$HUB_RPC_URL\" "${ROLLAPP_HOME_DIR}/config/dymint.toml"
sed -i '/rollapp_id =/c\rollapp_id = '\"$ROLLAPP_CHAIN_ID\" "${ROLLAPP_HOME_DIR}/config/dymint.toml"
```

mac:

```shell
sed -i '' 's/settlement_layer.*/settlement_layer = "dymension"/' ${ROLLAPP_HOME_DIR}/config/dymint.toml
sed -i '' 's|node_address =.*|node_address = '\"$HUB_RPC_URL\"'|' "${ROLLAPP_HOME_DIR}/config/dymint.toml"
sed -i '' 's|rollapp_id =.*|rollapp_id = '\"$ROLLAPP_CHAIN_ID\"'|' "${ROLLAPP_HOME_DIR}/config/dymint.toml"
dasel put -f "${ROLLAPP_HOME_DIR}"/config/dymint.toml "settlement_layer" -v "dymension"
dasel put -f "${ROLLAPP_HOME_DIR}"/config/dymint.toml "node_address" -v "$HUB_RPC_URL"
dasel put -f "${ROLLAPP_HOME_DIR}"/config/dymint.toml "rollapp_id" -v "$ROLLAPP_CHAIN_ID"
dasel put -f "${ROLLAPP_HOME_DIR}"/config/dymint.toml "max_idle_time" -v "2s" # may want to change to something longer after setup (see below)
dasel put -f "${ROLLAPP_HOME_DIR}"/config/dymint.toml "max_proof_time" -v "1s"
dasel put -f "${ROLLAPP_HOME_DIR}"/config/app.toml "minimum-gas-prices" -v "1arax"
```

### Update the Genesis file to include the denommetadata, genesis accounts, module account and elevated accounts
Expand All @@ -169,32 +160,18 @@ sh scripts/update_genesis_file.sh
Validate genesis file:

```shell
rollapp-evm validate-genesis
$EXECUTABLE validate-genesis
```

```shell
# this script automatically adds 2 vesting accounts, adjust the timestampts to your liking or skip this step
# this script automatically adds 2 vesting accounts, adjust the timestamps to your liking or skip this step
danwt marked this conversation as resolved.
Show resolved Hide resolved
sh scripts/add_vesting_accounts_to_genesis_file.sh
```

### Change to 3s block time for ibc connection initialization

Linux:

```shell
sed -i 's/empty_blocks_max_time = "1h0m0s"/empty_blocks_max_time = "3s"/' ${ROLLAPP_HOME_DIR}/config/dymint.toml
```

Mac:

```shell
sed -i '' 's/empty_blocks_max_time = "1h0m0s"/empty_blocks_max_time = "3s"/' ${ROLLAPP_HOME_DIR}/config/dymint.toml
```

### Run rollapp locally

```shell
rollapp-evm start
$EXECUTABLE start --log_level=debug
```

## Setup IBC between rollapp and local dymension hub node
Expand Down Expand Up @@ -222,25 +199,19 @@ After successful run, the new established channels will be shown
Stop the rollapp:

```shell
kill $(pgrep rollapp-evm)
kill $(pgrep $EXECUTABLE)
```

Linux:

```shell
sed -i 's/empty_blocks_max_time = "3s"/empty_blocks_max_time = "3600s"/' ${ROLLAPP_HOME_DIR}/config/dymint.toml
```

Mac:

```shell
sed -i '' 's/empty_blocks_max_time = "3s"/empty_blocks_max_time = "3600s"/' ${ROLLAPP_HOME_DIR}/config/dymint.toml
dasel put -f "${ROLLAPP_HOME_DIR}"/config/dymint.toml "max_idle_time" -v "1h"
danwt marked this conversation as resolved.
Show resolved Hide resolved
```

Start the rollapp:

```shell
rollapp-evm start
$EXECUTABLE start
```

### run the relayer
Expand All @@ -249,20 +220,6 @@ rollapp-evm start
rly start hub-rollapp
```

### Trigger genesis events

Trigger the genesis events on the rollapp

```shell
sh ./scripts/trigger_rollapp_genesis_event.sh
```

Trigger the genesis events on the hub

```shell
sh ./scripts/settlement/trigger_hub_genesis_event.sh
```

## Developers guide

For support, join our [Discord](http://discord.gg/dymension) community and find us in the Developer section.
Expand Down
2 changes: 2 additions & 0 deletions app/ante/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
sdkvestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
conntypes "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types"
ibcante "github.com/cosmos/ibc-go/v6/modules/core/ante"
cosmosante "github.com/evmos/evmos/v12/app/ante/cosmos"
evmante "github.com/evmos/evmos/v12/app/ante/evm"
Expand Down Expand Up @@ -43,6 +44,7 @@ func cosmosHandler(options HandlerOptions, sigChecker sdk.AnteDecorator) sdk.Ant
cosmosante.NewRejectMessagesDecorator(
[]string{
sdk.MsgTypeURL(&evmtypes.MsgEthereumTx{}),
sdk.MsgTypeURL(&conntypes.MsgConnectionOpenInit{}), // don't let any connection open from the Rollapp side (it's still possible from the other side)
mtsitrin marked this conversation as resolved.
Show resolved Hide resolved
},
),
cosmosante.NewAuthzLimiterDecorator( // disable the Msg types that cannot be included on an authz.MsgExec msgs field
Expand Down
60 changes: 17 additions & 43 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ import (
distr "github.com/dymensionxyz/dymension-rdk/x/dist"
distrkeeper "github.com/dymensionxyz/dymension-rdk/x/dist/keeper"

"github.com/dymensionxyz/dymension-rdk/x/denommetadata"
denommetadatamodulekeeper "github.com/dymensionxyz/dymension-rdk/x/denommetadata/keeper"
denommetadatamoduletypes "github.com/dymensionxyz/dymension-rdk/x/denommetadata/types"
"github.com/evmos/evmos/v12/ethereum/eip712"
ethermint "github.com/evmos/evmos/v12/types"
"github.com/evmos/evmos/v12/x/claims"
Expand Down Expand Up @@ -167,7 +164,6 @@ var (
// evmos keys
erc20types.StoreKey,
claimstypes.StoreKey,
denommetadatamoduletypes.StoreKey,
}
)

Expand Down Expand Up @@ -222,24 +218,22 @@ var (
erc20.AppModuleBasic{},
transfer.AppModuleBasic{AppModuleBasic: &ibctransfer.AppModuleBasic{}},
claims.AppModuleBasic{},
denommetadata.AppModuleBasic{},
)

// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
authz.ModuleName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
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
erc20types.ModuleName: {authtypes.Minter, authtypes.Burner},
claimstypes.ModuleName: nil,
hubgentypes.ModuleName: {authtypes.Burner},
denommetadatamoduletypes.ModuleName: nil,
authtypes.FeeCollectorName: nil,
authz.ModuleName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
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
erc20types.ModuleName: {authtypes.Minter, authtypes.Burner},
claimstypes.ModuleName: nil,
hubgentypes.ModuleName: {authtypes.Burner},
}

// module accounts that are allowed to receive tokens
Expand Down Expand Up @@ -315,8 +309,6 @@ type App struct {
Erc20Keeper erc20keeper.Keeper
ClaimsKeeper *claimskeeper.Keeper

DenomMetadataKeeper denommetadatamodulekeeper.Keeper

// mm is the module manager
mm *module.Manager

Expand Down Expand Up @@ -541,10 +533,6 @@ func NewRollapp(
),
)

denomMetadataHooks := denommetadatamoduletypes.NewMultiDenommetadataHooks(
erc20keeper.NewERC20ContractRegistrationHook(app.Erc20Keeper),
)

app.TransferKeeper = transferkeeper.NewKeeper(
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
app.ClaimsKeeper, // ICS4 Wrapper: claims IBC middleware
Expand All @@ -553,21 +541,10 @@ func NewRollapp(
app.Erc20Keeper, // Add ERC20 Keeper for ERC20 transfers
)

app.DenomMetadataKeeper = denommetadatamodulekeeper.NewKeeper(
appCodec,
keys[denommetadatamoduletypes.StoreKey],
app.BankKeeper,
app.TransferKeeper,
denomMetadataHooks,
app.GetSubspace(denommetadatamoduletypes.ModuleName),
)

app.HubGenesisKeeper = hubgenkeeper.NewKeeper(
appCodec,
keys[hubgentypes.StoreKey],
app.GetSubspace(hubgentypes.ModuleName),
app.IBCKeeper.ChannelKeeper,
app.BankKeeper,
app.AccountKeeper,
)

Expand Down Expand Up @@ -615,7 +592,7 @@ func NewRollapp(
params.NewAppModule(app.ParamsKeeper),
ibc.NewAppModule(app.IBCKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
hubgenesis.NewAppModule(appCodec, app.HubGenesisKeeper, app.AccountKeeper),
hubgenesis.NewAppModule(appCodec, app.HubGenesisKeeper),

// Ethermint app modules
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, app.GetSubspace(evmtypes.ModuleName)),
Expand All @@ -624,7 +601,6 @@ func NewRollapp(
transferModule,
erc20.NewAppModule(app.Erc20Keeper, app.AccountKeeper, app.GetSubspace(erc20types.ModuleName)),
claims.NewAppModule(appCodec, *app.ClaimsKeeper, app.GetSubspace(claimstypes.ModuleName)),
denommetadata.NewAppModule(app.DenomMetadataKeeper, app.BankKeeper),
}

app.mm = module.NewManager(modules...)
Expand Down Expand Up @@ -657,7 +633,6 @@ func NewRollapp(
epochstypes.ModuleName,
paramstypes.ModuleName,
hubgentypes.ModuleName,
denommetadatamoduletypes.ModuleName,
}
app.mm.SetOrderBeginBlockers(beginBlockersList...)

Expand All @@ -684,7 +659,6 @@ func NewRollapp(
ibchost.ModuleName,
ibctransfertypes.ModuleName,
hubgentypes.ModuleName,
denommetadatamoduletypes.ModuleName,
}
app.mm.SetOrderEndBlockers(endBlockersList...)

Expand Down Expand Up @@ -718,7 +692,6 @@ func NewRollapp(
ibctransfertypes.ModuleName,
feegrant.ModuleName,
hubgentypes.ModuleName,
denommetadatamoduletypes.ModuleName,
}
app.mm.SetOrderInitGenesis(initGenesisList...)

Expand Down Expand Up @@ -761,13 +734,15 @@ func NewRollapp(
encodingConfig.TxConfig,
maxGasWanted,
func(ctx sdk.Context, accAddr sdk.AccAddress, perm string) bool {
return true
/*
TODO:
We had a plan to use the sequencers module to manager permissions, but that idea was changed
For now, we just assume the only account with permission is the denom one
We will eventually replace with something more substantial
TODO:
The denom one was ripped out https://github.com/dymensionxyz/dymension-rdk/pull/433/files#diff-2caeed9462180cba822eeaff485f2bb87c9c9464040fb65f0f5dcac66fb0e18fL58-L67
*/
return app.DenomMetadataKeeper.IsAddressPermissioned(ctx, accAddr.String())
},
app.AccountKeeper,
app.StakingKeeper,
Expand Down Expand Up @@ -992,7 +967,7 @@ func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper {
return app.StakingKeeper
}

// GetStakingKeeper implements the TestingApp interface.
// GetStakingKeeperSDK implements the TestingApp interface.
danwt marked this conversation as resolved.
Show resolved Hide resolved
func (app *App) GetStakingKeeperSDK() stakingkeeper.Keeper {
return app.StakingKeeper
}
Expand Down Expand Up @@ -1055,7 +1030,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
// evmos subspaces
paramsKeeper.Subspace(erc20types.ModuleName)
paramsKeeper.Subspace(claimstypes.ModuleName)
paramsKeeper.Subspace(denommetadatamoduletypes.ModuleName)

return paramsKeeper
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/rollappd/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, nodeConfig *d
grpcAddress := fmt.Sprintf("127.0.0.1:%s", port)

// If grpc is enabled, configure grpc client for grpc gateway.
grpcClient, err := grpc.Dial(
grpcClient, err := grpc.NewClient(
grpcAddress,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultCallOptions(
Expand Down
Loading
Loading