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

genesis bridge investigation (release 2.1.x) #266

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
12a08b6
use local dymint and rdk
danwt May 22, 2024
5762abd
for investigation
danwt May 22, 2024
4b5f39e
swap relayer path direction
danwt May 22, 2024
f5f275e
integrate a new rdk middleware
danwt May 22, 2024
cb91fd9
wire up the interceptor
danwt May 22, 2024
59e5823
tweaks
danwt May 22, 2024
faafa39
allow hubgenesis to send/receive
danwt May 22, 2024
fc75666
fix transfer plugin
danwt May 24, 2024
7b58643
bump scripts to move the genesis accounts to the rollapp
danwt May 24, 2024
19cdf88
confirm tx to first genesis account works
danwt May 24, 2024
774509a
add burner and minter
danwt May 24, 2024
59ea071
removes the module account funding from the genesis file
danwt May 24, 2024
3ff97a0
confirms minting works
danwt May 24, 2024
c7aa33e
try out dasel in the genesis
danwt May 24, 2024
8c37c3a
removes bogus todo
danwt May 24, 2024
b1145cb
Revert "removes bogus todo"
danwt May 24, 2024
a78023a
Revert "try out dasel in the genesis"
danwt May 24, 2024
3b11f1c
clean up update genesis script
danwt May 24, 2024
1d92d79
confirmining working state Monday morning
danwt May 28, 2024
4814016
fix app go
danwt May 29, 2024
552236c
mod tidy
danwt May 29, 2024
c49ecd7
tidy
danwt May 29, 2024
f146897
bump script to use mnemonic for bob alice
danwt May 29, 2024
ca78220
confirms working with denom
danwt May 29, 2024
81c6eb2
fix genesis account generation script
danwt Jun 4, 2024
1f30f42
confirms working with skip ctx
danwt Jun 4, 2024
cd863e7
fmt
danwt Jun 6, 2024
5bfd13a
adds a build flags debug cmd to makefile
danwt Jun 6, 2024
672062b
next step: check that channel corresponds to the RA and set a canonic…
danwt Jun 6, 2024
c3a5e0d
post merge hub main, now going to do packet authenticity check
danwt Jun 7, 2024
bc4377c
lets try to install
danwt Jun 11, 2024
a32795b
confirm installs
danwt Jun 11, 2024
e5fb04d
pre rebase to main
danwt Jun 11, 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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
# Install #
###########

.PHONY: echoflags
echoflags:
echo $(BUILD_FLAGS)

all: install

Expand Down
25 changes: 18 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,15 @@
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},
hubgentypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // TODO: fix the tests on rdk too
denommetadatamoduletypes.ModuleName: nil,
}

// module accounts that are allowed to receive tokens
allowedReceivingModAcc = map[string]bool{
distrtypes.ModuleName: true,
// true = is able to send/receive
distrtypes.ModuleName: true,
hubgentypes.ModuleName: true,
}
)

Expand Down Expand Up @@ -323,7 +325,6 @@
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {

appCodec := encodingConfig.Codec
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
Expand Down Expand Up @@ -471,9 +472,11 @@
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.SequencersKeeper, app.UpgradeKeeper, scopedIBCKeeper,
)

app.IBCKeeper.ConnectionKeeper.SetParams(ctx, ibchost.ConnectionP)

// Register the proposal types
// Deprecated: Avoid adding new handlers, instead use the new proposal flow
// by granting the governance module the right to execute the message.

Check failure on line 479 in app/app.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: ctx (typecheck)
// See: https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/x/gov/spec/01_concepts.md#proposal-messages
govRouter := govv1beta1.NewRouter()
govRouter.
Expand Down Expand Up @@ -542,8 +545,6 @@
appCodec,
keys[hubgentypes.StoreKey],
app.GetSubspace(hubgentypes.ModuleName),
app.IBCKeeper.ChannelKeeper,
app.BankKeeper,
app.AccountKeeper,
)

Expand All @@ -560,6 +561,16 @@
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = claims.NewIBCMiddleware(*app.ClaimsKeeper, transferStack)
transferStack = erc20.NewIBCMiddleware(app.Erc20Keeper, transferStack)
transferStack = hubgenkeeper.NewIBCModule(
transferStack,
func(ctx sdk.Context, transfer *ibctransfertypes.MsgTransfer) error {
_, err := app.TransferKeeper.Transfer(sdk.WrapSDKContext(ctx), transfer)
return err
},
app.HubGenesisKeeper,
app.BankKeeper.GetDenomMetaData,
app.BankKeeper.MintCoins,
)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
Expand Down Expand Up @@ -794,7 +805,7 @@
panic(err)
}

//Passing the dymint sequencers to the sequencer module from RequestInitChain
// Passing the dymint sequencers to the sequencer module from RequestInitChain
if len(req.Validators) == 0 {
panic("Dymint have no sequencers defined on InitChain")
}
Expand Down Expand Up @@ -963,7 +974,7 @@
return app.StakingKeeper
}

// GetStakingKeeper implements the TestingApp interface.
// GetStakingKeeperSDK implements the TestingApp interface.
func (app *App) GetStakingKeeperSDK() stakingkeeper.Keeper {
return app.StakingKeeper
}
Expand Down
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/cosmos/cosmos-sdk v0.46.16
github.com/cosmos/ibc-go/v6 v6.2.1
github.com/dymensionxyz/dymension-rdk v1.6.0
github.com/dymensionxyz/dymint v1.1.3-rc02
github.com/dymensionxyz/dymint v1.1.3-rc03
github.com/ethereum/go-ethereum v1.12.0
github.com/evmos/evmos/v12 v12.1.6
github.com/gorilla/mux v1.8.1
Expand Down Expand Up @@ -51,8 +51,9 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/celestiaorg/celestia-openrpc v0.4.0-rc.1 // indirect
github.com/celestiaorg/go-fraud v0.2.0 // indirect
github.com/celestiaorg/go-header v0.4.0 // indirect
github.com/celestiaorg/go-header v0.4.1 // indirect
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 // indirect
github.com/celestiaorg/nmt v0.20.0 // indirect
github.com/celestiaorg/rsmt2d v0.11.0 // indirect
Expand Down Expand Up @@ -249,7 +250,6 @@ require (
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rjeczalik/notify v0.9.3 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rollkit/celestia-openrpc v0.0.0-00010101000000-000000000000 // indirect
github.com/rs/cors v1.9.0 // indirect
github.com/rs/zerolog v1.29.1 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
Expand Down Expand Up @@ -332,3 +332,8 @@ replace (
// use cometbft
github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.28
)

replace (
github.com/dymensionxyz/dymension-rdk => /Users/danwt/Documents/dym/d-dymension-rdk
github.com/dymensionxyz/dymint => /Users/danwt/Documents/dym/d-dymint
)
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/celestiaorg/celestia-openrpc v0.3.0 h1:/0lzmgg1v/9ONwFs9fNVti3x11kI/Sk87dsYLcms43Q=
github.com/celestiaorg/celestia-openrpc v0.3.0/go.mod h1:2ZhU01YF2hsHIROWzxfMZOYM09Kgyy4roH5JWoNJzp0=
github.com/celestiaorg/celestia-openrpc v0.4.0-rc.1 h1:CLhcfNP4496pg0aptcgHJubNXoY97PMHF0sDWx4HRrg=
github.com/celestiaorg/celestia-openrpc v0.4.0-rc.1/go.mod h1:+2xwD+PBy76D2XOAwDbkuNVUSAvwUFV54cQqMFBA1s0=
github.com/celestiaorg/go-fraud v0.2.0 h1:aaq2JiW0gTnhEdac3l51UCqSyJ4+VjFGTTpN83V4q7I=
github.com/celestiaorg/go-fraud v0.2.0/go.mod h1:lNY1i4K6kUeeE60Z2VK8WXd+qXb8KRzfBhvwPkK6aUc=
github.com/celestiaorg/go-header v0.4.0 h1:Ine/xpvFx8o9p6fXW+h2RSPp68rn7VUxTkW1okJxcEY=
github.com/celestiaorg/go-header v0.4.0/go.mod h1:H8xhnDLDLbkpwmWPhCaZyTnIV3dlVxBHPnxNXS2Qu6c=
github.com/celestiaorg/go-header v0.4.1 h1:bjbUcKDnhrJJ9EoE7vtPpgleNLVjc2S+cB4/qe8nQmo=
github.com/celestiaorg/go-header v0.4.1/go.mod h1:H8xhnDLDLbkpwmWPhCaZyTnIV3dlVxBHPnxNXS2Qu6c=
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc=
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4/go.mod h1:fzuHnhzj1pUygGz+1ZkB3uQbEUL4htqCGJ4Qs2LwMZA=
github.com/celestiaorg/nmt v0.20.0 h1:9i7ultZ8Wv5ytt8ZRaxKQ5KOOMo4A2K2T/aPGjIlSas=
Expand Down Expand Up @@ -551,12 +551,8 @@ github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQx
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
github.com/dymensionxyz/cosmosclient v0.4.2-beta h1:sokBefcN1tIOlUKmB8Q2E9XMJ93LueqtFThiM/kA4DI=
github.com/dymensionxyz/cosmosclient v0.4.2-beta/go.mod h1:GQQu3ITEjWfi5ULR2B6X2i2YZNennY1yzcT5qdL4MGI=
github.com/dymensionxyz/dymension-rdk v1.6.0 h1:NmJwSchWhrNVSnV1bD6ZL3gV9NSjukmusVQX4SxKpfM=
github.com/dymensionxyz/dymension-rdk v1.6.0/go.mod h1:FRuzA4rZPwehMTQdF2ZRefJElKh9CHkhtCsD9Q1p8VI=
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 h1:cmpJYdRviuUfmlJdHrcAND8Jd6JIY4rp63bWAQzPr54=
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56/go.mod h1:3Pfrr8j/BR9ztNKztGfC5PqDiO6CcrzMLCJtFtPEVW4=
github.com/dymensionxyz/dymint v1.1.3-rc02 h1:sNN75RtHWRWWyFWiUTqo6jUYqqkuply/YHefHGy0gRo=
github.com/dymensionxyz/dymint v1.1.3-rc02/go.mod h1:QedWhB9RjsZOxevADYZz3EFtofQqtQdZyivSmT6QZM0=
github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.4.2 h1:aVP3off7u2vsvRH7lHAUPTLdf9/AfnzC/rvvi0wC/co=
github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.4.2/go.mod h1:CI6D89pkoiIm4BjoMFNnEaCLdKBEobLuwvhS0c1zh7Y=
github.com/dymensionxyz/go-libp2p-pubsub v0.0.0-20231219183151-4504d4995913 h1:sR3nGYRlktL2Xfj5pcOhgG2bvlBOZ14meqdu2TKkSCU=
Expand Down
2 changes: 1 addition & 1 deletion scripts/ibc/hub.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"value": {
"key": "relayer-hub-key",
"chain-id": "dymension_100-1",
"rpc-addr": "http://localhost:36657",
"rpc-addr": "tcp://0.0.0.0:36657",
"account-prefix": "dym",
"keyring-backend": "test",
"gas-adjustment": 1.2,
Expand Down
4 changes: 2 additions & 2 deletions scripts/ibc/rollapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"type": "cosmos",
"value": {
"key": "relayer-rollapp-key",
"chain-id": "rollappevm_122334-1",
"chain-id": "rollappevm_1234-1",
"rpc-addr": "tcp://localhost:26657",
"account-prefix": "abc",
"account-prefix": "eth",
"keyring-backend": "test",
"gas-adjustment": 1.2,
"gas-prices": "0.0arax",
Expand Down
2 changes: 1 addition & 1 deletion scripts/ibc/setup_ibc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fi

echo '--------------------------------- Creating IBC path... --------------------------------'

rly paths new "$ROLLAPP_CHAIN_ID" "$SETTLEMENT_CHAIN_ID" "$RELAYER_PATH" --src-port "$IBC_PORT" --dst-port "$IBC_PORT" --version "$IBC_VERSION"
rly paths new "$SETTLEMENT_CHAIN_ID" "$ROLLAPP_CHAIN_ID" "$RELAYER_PATH" --src-port "$IBC_PORT" --dst-port "$IBC_PORT" --version "$IBC_VERSION"

rly tx link "$RELAYER_PATH" --src-port "$IBC_PORT" --dst-port "$IBC_PORT" --version "$IBC_VERSION"
# Channel is currently not created in the tx link since we changed the relayer to support on demand blocks
Expand Down
7 changes: 5 additions & 2 deletions scripts/settlement/add_genesis_accounts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ else
echo "ROLLAPP_SETTLEMENT_INIT_DIR_PATH already exists: $ROLLAPP_SETTLEMENT_INIT_DIR_PATH"
fi

dymd keys add alice-genesis --keyring-backend test --keyring-dir ${ROLLAPP_HOME_DIR}
dymd keys add bob-genesis --keyring-backend test --keyring-dir ${ROLLAPP_HOME_DIR}
# use concrete mnemonics so the addresses are always the same, just for convenience and recognisability
ALICE_MNEMONIC="mimic ten evoke card crowd upset tragic race borrow final vibrant gesture armed alley figure orange shock strike surge jaguar deposit hockey erosion taste"
BOB_MNEMONIC="matrix venture pair label proud ignore manual crunch brand board welcome suspect purity steak melt atom stadium vanish bullet hill angry bulk visa analyst"
echo $ALICE_MNEMONIC | dymd keys add alice-genesis --keyring-backend test --keyring-dir ${ROLLAPP_HOME_DIR} --recover
echo $BOB_MNEMONIC | dymd keys add bob-genesis --keyring-backend test --keyring-dir ${ROLLAPP_HOME_DIR} --recover

tee "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH/genesis_accounts.json" >/dev/null <<EOF
[
Expand Down
7 changes: 0 additions & 7 deletions scripts/settlement/register_rollapp_to_hub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,9 @@ if [ -z "$HUB_CHAIN_ID" ]; then
HUB_CHAIN_ID="dymension_100-1"
fi

# this file is generated using the scripts/settlement/generate_denom_metadata.sh
DENOM_METADATA_PATH="${ROLLAPP_SETTLEMENT_INIT_DIR_PATH}/denommetadata.json"
# this file is generated using the scripts/settlement/add_genesis_accounts.sh
GENESIS_ACCOUNTS_PATH="${ROLLAPP_SETTLEMENT_INIT_DIR_PATH}/genesis_accounts.json"

set -x
#Register rollapp
dymd tx rollapp create-rollapp "$ROLLAPP_CHAIN_ID" "$MAX_SEQUENCERS" '{"Addresses":[]}' \
"$DENOM_METADATA_PATH" \
--genesis-accounts-path "$GENESIS_ACCOUNTS_PATH" \
--from "$DEPLOYER" \
--keyring-backend test \
--broadcast-mode block \
Expand Down
10 changes: 0 additions & 10 deletions scripts/settlement/trigger_hub_genesis_event.sh

This file was deleted.

6 changes: 0 additions & 6 deletions scripts/trigger_rollapp_genesis_event.sh

This file was deleted.

64 changes: 5 additions & 59 deletions scripts/update_genesis_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,70 +15,16 @@ jq '.consensus_params["block"]["max_bytes"] = "3145728"' "$GENESIS_FILE" >"$tmp"

jq '.app_state.gov.voting_params.voting_period = "300s"' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"

# this is a static module account for the hubgenesis module
# retrieved using 'rollapp-evm q auth module-accounts' command
module_account_address=$(rollapp-evm debug addr F54EBEEF798CA51615C02D13888768F9960863F2 | grep "Bech32 Acc" | awk '{print $3}')

# Construct the JSON object with the obtained address
module_account=$(jq -n \
--arg address "$module_account_address" \
'[{
"@type": "/cosmos.auth.v1beta1.ModuleAccount",
"base_account": {
"account_number": "0",
"address": $address,
"pub_key": null,
"sequence": "0"
},
"name": "hubgenesis",
"permissions": []
}]')

jq --argjson module_account "$module_account" '.app_state.auth.accounts += $module_account' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"

module_account_balance=$(
jq -n \
--arg address "$module_account_address" \
--arg denom "$BASE_DENOM" \
'[{
"address": $address,
"coins": [
{
"denom": $denom,
"amount": "60000000000000000000000"
}
]
}]'
)

hubgenesis_tokens=$(
jq -n \
--arg denom "$BASE_DENOM" \
--arg amount "60000000000000000000000" \
'[{
"denom": $denom,
"amount": $amount
}]'
)

jq --argjson hubgenesis_tokens "$hubgenesis_tokens" '.app_state.hubgenesis.state.genesis_tokens = $hubgenesis_tokens' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"

jq '.app_state.bank.balances[0].coins[0].amount = "2000000000000000000000000000"' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"
jq --argjson module_account_balance "$module_account_balance" '.app_state.bank.balances += $module_account_balance' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"

jq '.app_state.bank.supply[0].amount = "2000060000000000000000000000"' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"
jq '.app_state.bank.supply[0].amount = "2000000000000000000000000000"' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"

# ---------------------------- add elevated account ---------------------------- #
elevated_address=$("$EXECUTABLE" keys show "$KEY_NAME_ROLLAPP" --keyring-backend test --output json | jq -r .address)
elevated_address_json=$(jq -n \
--arg address "$elevated_address" \
'[{
"address": $address
}]')
jq --argjson elevated_address_json "$elevated_address_json" '.app_state.hubgenesis.params.genesis_triggerer_allowlist += $elevated_address_json' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"
# ---------------------------- add genesis accounts for the hub ---------------------------- #
genesis_accounts=$(cat "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH"/genesis_accounts.json)
jq --argjson genesis_accounts "$genesis_accounts" '.app_state.hubgenesis.state.genesis_accounts = $genesis_accounts' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"

# ---------------------------- add denom metadata ---------------------------- #
denom_metadata=$(cat "$ROLLAPP_SETTLEMENT_INIT_DIR_PATH"/denommetadata.json)
elevated_address=$("$EXECUTABLE" keys show "$KEY_NAME_ROLLAPP" --keyring-backend test --output json | jq -r .address)
jq --argjson denom_metadata "$denom_metadata" '.app_state.bank.denom_metadata = $denom_metadata' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"
jq --arg elevated_address "$elevated_address" '.app_state.denommetadata.params.allowed_addresses += [$elevated_address]' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"

Expand Down
Loading