Skip to content

Commit

Permalink
feat(devnet): add devnet slots-in-an-epoch config
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura committed Jul 26, 2024
1 parent bfe28af commit 91aedcf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
4 changes: 4 additions & 0 deletions cmd/cartesi-rollups-cli/root/deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
23 changes: 12 additions & 11 deletions docs/cli/cartesi-rollups-cli_run-deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions internal/deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
DefaultDevnetDockerImage = "cartesi/rollups-node-devnet:devel"
DefaultDevnetPort = "8545"
DefaultDevnetBlockTime = "1"
DefaultSlotsInAnEpoch = "1"
DefaultDevnetBlockToWaitForOnStartup = "21"
DefaultDevnetNoMining = false

Expand Down Expand Up @@ -61,6 +62,7 @@ type DevnetConfig struct {
DockerImage string
Port string
BlockTime string
SlotsInAnEpoch string
BlockToWaitForOnStartup string
NoMining bool
}
Expand All @@ -77,6 +79,7 @@ func NewDefaultDepsConfig() *DepsConfig {
DefaultDevnetDockerImage,
DefaultDevnetPort,
DefaultDevnetBlockTime,
DefaultSlotsInAnEpoch,
DefaultDevnetBlockToWaitForOnStartup,
DefaultDevnetNoMining,
},
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 91aedcf

Please sign in to comment.