diff --git a/Makefile b/Makefile index 7bdf95da..517b9579 100644 --- a/Makefile +++ b/Makefile @@ -76,6 +76,9 @@ BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' # Install # ########### +.PHONY: echoflags +echoflags: + echo $(BUILD_FLAGS) all: install diff --git a/app/app.go b/app/app.go index 98999df5..88eaa9f0 100644 --- a/app/app.go +++ b/app/app.go @@ -223,13 +223,15 @@ var ( 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, } ) @@ -323,7 +325,6 @@ func NewRollapp( appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *App { - appCodec := encodingConfig.Codec cdc := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry @@ -471,6 +472,8 @@ func NewRollapp( 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. @@ -542,8 +545,6 @@ func NewRollapp( appCodec, keys[hubgentypes.StoreKey], app.GetSubspace(hubgentypes.ModuleName), - app.IBCKeeper.ChannelKeeper, - app.BankKeeper, app.AccountKeeper, ) @@ -560,6 +561,16 @@ func NewRollapp( 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() @@ -794,7 +805,7 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res 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") } @@ -963,7 +974,7 @@ func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper { return app.StakingKeeper } -// GetStakingKeeper implements the TestingApp interface. +// GetStakingKeeperSDK implements the TestingApp interface. func (app *App) GetStakingKeeperSDK() stakingkeeper.Keeper { return app.StakingKeeper } diff --git a/go.mod b/go.mod index 1f79e525..2d09164d 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 @@ -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 @@ -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 +) diff --git a/go.sum b/go.sum index 5b6bba9d..a044bf0a 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= diff --git a/scripts/ibc/hub.json b/scripts/ibc/hub.json index f1f43f08..dde2665e 100644 --- a/scripts/ibc/hub.json +++ b/scripts/ibc/hub.json @@ -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, diff --git a/scripts/ibc/rollapp.json b/scripts/ibc/rollapp.json index 79befd30..21b997cb 100644 --- a/scripts/ibc/rollapp.json +++ b/scripts/ibc/rollapp.json @@ -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", diff --git a/scripts/ibc/setup_ibc.sh b/scripts/ibc/setup_ibc.sh index 9fbcf3e9..af5698cb 100755 --- a/scripts/ibc/setup_ibc.sh +++ b/scripts/ibc/setup_ibc.sh @@ -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 diff --git a/scripts/settlement/add_genesis_accounts.sh b/scripts/settlement/add_genesis_accounts.sh index 24baf1e2..62e3cb42 100755 --- a/scripts/settlement/add_genesis_accounts.sh +++ b/scripts/settlement/add_genesis_accounts.sh @@ -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 <"$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"