From 91aedcf58b3a9c15401daad7b1260d413ca30f37 Mon Sep 17 00:00:00 2001 From: Francisco Moura Date: Thu, 25 Jul 2024 14:08:04 -0300 Subject: [PATCH] feat(devnet): add devnet slots-in-an-epoch config --- cmd/cartesi-rollups-cli/root/deps/deps.go | 4 ++++ docs/cli/cartesi-rollups-cli_run-deps.md | 23 ++++++++++++----------- internal/deps/deps.go | 11 +++++++++++ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/cmd/cartesi-rollups-cli/root/deps/deps.go b/cmd/cartesi-rollups-cli/root/deps/deps.go index 9c49693f1..75fce18a3 100644 --- a/cmd/cartesi-rollups-cli/root/deps/deps.go +++ b/cmd/cartesi-rollups-cli/root/deps/deps.go @@ -56,6 +56,10 @@ func init() { deps.DefaultDevnetBlockTime, "Devnet mining block time") + Cmd.Flags().StringVar(&depsConfig.Devnet.SlotsInAnEpoch, "devnet-slots-in-an-epoch", + deps.DefaultSlotsInAnEpoch, + "Devnet slots in an epoch") + Cmd.Flags().BoolVar(&depsConfig.Devnet.NoMining, "devnet-no-mining", deps.DefaultDevnetNoMining, "Devnet disable mining") diff --git a/docs/cli/cartesi-rollups-cli_run-deps.md b/docs/cli/cartesi-rollups-cli_run-deps.md index e8f7bfc79..57c7c7f34 100644 --- a/docs/cli/cartesi-rollups-cli_run-deps.md +++ b/docs/cli/cartesi-rollups-cli_run-deps.md @@ -16,17 +16,18 @@ cartesi-rollups-cli run-deps ### Options ``` - --devnet-block-time string Devnet mining block time (default "1") - --devnet-docker-image string Devnet docker image name (default "cartesi/rollups-node-devnet:devel") - --devnet-mapped-port string Devnet local listening port number (default "8545") - --devnet-no-mining Devnet disable mining - --disable-devnet Disable Devnet - --disable-postgres Disable Postgres - -h, --help help for run-deps - --postgres-docker-image string Postgres docker image name (default "postgres:16-alpine") - --postgres-mapped-port string Postgres local listening port number (default "5432") - --postgres-password string Postgres password (default "password") - -v, --verbose verbose logs + --devnet-block-time string Devnet mining block time (default "1") + --devnet-docker-image string Devnet docker image name (default "cartesi/rollups-node-devnet:devel") + --devnet-mapped-port string Devnet local listening port number (default "8545") + --devnet-no-mining Devnet disable mining + --devnet-slots-in-an-epoch string Devnet slots in an epoch (default "1") + --disable-devnet Disable Devnet + --disable-postgres Disable Postgres + -h, --help help for run-deps + --postgres-docker-image string Postgres docker image name (default "postgres:16-alpine") + --postgres-mapped-port string Postgres local listening port number (default "5432") + --postgres-password string Postgres password (default "password") + -v, --verbose verbose logs ``` ### SEE ALSO diff --git a/internal/deps/deps.go b/internal/deps/deps.go index b985d2a36..a4cbfe046 100644 --- a/internal/deps/deps.go +++ b/internal/deps/deps.go @@ -28,6 +28,7 @@ const ( DefaultDevnetDockerImage = "cartesi/rollups-node-devnet:devel" DefaultDevnetPort = "8545" DefaultDevnetBlockTime = "1" + DefaultSlotsInAnEpoch = "1" DefaultDevnetBlockToWaitForOnStartup = "21" DefaultDevnetNoMining = false @@ -61,6 +62,7 @@ type DevnetConfig struct { DockerImage string Port string BlockTime string + SlotsInAnEpoch string BlockToWaitForOnStartup string NoMining bool } @@ -77,6 +79,7 @@ func NewDefaultDepsConfig() *DepsConfig { DefaultDevnetDockerImage, DefaultDevnetPort, DefaultDevnetBlockTime, + DefaultSlotsInAnEpoch, DefaultDevnetBlockToWaitForOnStartup, DefaultDevnetNoMining, }, @@ -256,6 +259,14 @@ func Run(ctx context.Context, depsConfig DepsConfig) (*DepsContainers, error) { "--load-state", "/usr/share/devnet/anvil_state.json", } + + if depsConfig.Devnet.SlotsInAnEpoch != "" { + cmd = append(cmd, + "--slots-in-an-epoch", + depsConfig.Devnet.SlotsInAnEpoch, + ) + } + var waitStrategy *wait.LogStrategy if depsConfig.Devnet.NoMining { cmd = append(cmd, "--no-mining")