Skip to content

Commit

Permalink
feat(hubgenesis): add genesis checksum to genesis-info (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 authored Nov 4, 2024
1 parent fd1f992 commit a8716c7
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 11 deletions.
4 changes: 4 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,10 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
panic(err)
}

genesisInfo := app.HubGenesisKeeper.GetGenesisInfo(ctx)
genesisInfo.GenesisChecksum = req.GenesisChecksum
app.HubGenesisKeeper.SetGenesisInfo(ctx, genesisInfo)

// Passing the dymint sequencers to the sequencer module from RequestInitChain
if len(req.Validators) == 0 {
panic(fmt.Sprint("Dymint have no sequencers defined on InitChain, req:", req))
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ require (
github.com/cosmos/gogoproto v1.5.0
github.com/cosmos/ibc-go/v6 v6.3.0
github.com/dvsekhvalnov/jose2go v1.5.0
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241030213845-88f668faab66
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241031114544-58b9cafae18c
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241104174622-ef99c12f13b4
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241104173413-6ae1dc10f0bf
github.com/ethereum/go-ethereum v1.12.0
github.com/evmos/evmos/v12 v12.1.6
github.com/gogo/protobuf v1.3.3
Expand Down Expand Up @@ -360,5 +360,5 @@ replace (
// replace broken goleveldb
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
// use cometbft
github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20241030154748-3f9dfa21d17b
github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20241104165035-feade34f8f89
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,14 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM=
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
github.com/dymensionxyz/cometbft v0.34.29-0.20241030154748-3f9dfa21d17b h1:rxkH+9cBG2nnReMavb2FqQXwDLjKcz0/KB8/6SV5Xlo=
github.com/dymensionxyz/cometbft v0.34.29-0.20241030154748-3f9dfa21d17b/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw=
github.com/dymensionxyz/cometbft v0.34.29-0.20241104165035-feade34f8f89 h1:rGkCcx4dWX9mxAUrq7zrdOc44XddMY/nM6kqYTWjerY=
github.com/dymensionxyz/cometbft v0.34.29-0.20241104165035-feade34f8f89/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw=
github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13 h1:u5yeve5jZR6TdRjjR+vYT/8PWKbhwCZxUmAu+/Tnxyg=
github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13/go.mod h1:jabDQYXrccscSE0fXkh7eQFYPWJCRiuWKonFGObVq6s=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241030213845-88f668faab66 h1:6fcEO/tyf9bKsyCA/x0nSo5gMig7HDUme2xFqMorkpc=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241030213845-88f668faab66/go.mod h1:HH7sGM/4MSI8OLces8axABf7K0ppXNok+G2nxC/l5YI=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241031114544-58b9cafae18c h1:NiIwXgG8vbPh1a/mRqLK4wOf7W1jvc5Cm4aOCEvx7z8=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241031114544-58b9cafae18c/go.mod h1:BTc0Br+c1YyBGeI1O1inU+pxeifDnyzz/Muu/dgDUKI=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241104174622-ef99c12f13b4 h1:3R7XqM0Hstb9GxZtuijarVSXTEDu24ywlyFUCjCT9sQ=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241104174622-ef99c12f13b4/go.mod h1:y89w1OG4C4aF7yyW8bv9PwV3o1KkCx1hyt34ap04Rnk=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241104173413-6ae1dc10f0bf h1:2ChqhjDO12ggf4Xh7dovYamrJlF3eyGIh3co0PAMsVk=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241104173413-6ae1dc10f0bf/go.mod h1:Qc4FqIlTdIUROQIS0mkIWF5wA6C4AM6znoDKzkHJ5EY=
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/gerr-cosmos v1.0.0 h1:oi91rgOkpJWr41oX9JOyjvvBnhGY54tj513x8VlDAEc=
Expand Down
1 change: 1 addition & 0 deletions rollappd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func queryCommand() *cobra.Command {
rpc.BlockCommand(),
authcmd.QueryTxsByEventsCmd(),
authcmd.QueryTxCmd(),
genesisChecksumCmd(),
)

app.ModuleBasics.AddQueryCommands(cmd)
Expand Down
27 changes: 27 additions & 0 deletions rollappd/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (

"github.com/dymensionxyz/dymension-rdk/utils"
rdklogger "github.com/dymensionxyz/dymension-rdk/utils/logger"
"github.com/dymensionxyz/dymint/cmd/dymint/commands"
dymintconf "github.com/dymensionxyz/dymint/config"
dymintconv "github.com/dymensionxyz/dymint/conv"
dymintmemp "github.com/dymensionxyz/dymint/mempool"
Expand Down Expand Up @@ -300,6 +301,11 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, nodeConfig *d
return err
}

genesisChecksum, err := commands.ComputeGenesisHash(cfg.GenesisFile())
if err != nil {
return fmt.Errorf("failed to compute genesis checksum: %w", err)
}

ctx.Logger.Info("starting node with ABCI dymint in-process")
tmNode, err := dymintnode.NewNode(
context.Background(),
Expand All @@ -308,6 +314,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, nodeConfig *d
signingKey,
proxy.NewLocalClientCreator(app),
genesis,
genesisChecksum,
ctx.Logger,
dymintmemp.PrometheusMetrics("dymint"),
)
Expand Down Expand Up @@ -596,3 +603,23 @@ func wrapCPUProfile(ctx *server.Context, callback func() error) error {

return <-errCh
}

func genesisChecksumCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "genesis-checksum",
Short: "Compute the checksum of the genesis file",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
serverCtx := server.GetServerContextFromCmd(cmd)
checksum, err := commands.ComputeGenesisHash(serverCtx.Config.GenesisFile())
if err != nil {
return err
}

fmt.Println(checksum)
return nil
},
}

return cmd
}
3 changes: 1 addition & 2 deletions scripts/settlement/register_rollapp_to_hub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ EOF

fi

GENESIS_PATH="${ROLLAPP_HOME_DIR}/config/genesis.json"
GENESIS_HASH=$(sha256sum "$GENESIS_PATH" | awk '{print $1}' | sed 's/[[:space:]]*$//')
GENESIS_HASH=$($EXECUTABLE q genesis-checksum)
SEQUENCER_ADDR=$(dymd keys show "$SEQUENCER_KEY_NAME" --address --keyring-backend test --keyring-dir "$SEQUENCER_KEY_PATH")

echo "deployer" $DEPLOYER;
Expand Down

0 comments on commit a8716c7

Please sign in to comment.