Skip to content

Commit

Permalink
feat(devnet): add devnet devnet-finalization-offset config
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura authored and vfusco committed Sep 9, 2024
1 parent 84e4f2e commit c71013f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
8 changes: 6 additions & 2 deletions cmd/cartesi-rollups-cli/root/deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ func init() {

Cmd.Flags().StringVar(&depsConfig.Devnet.BlockTime, "devnet-block-time",
deps.DefaultDevnetBlockTime,
"Devnet mining block time")
"Devnet mining block time in seconds when 'interval mining' is enabled.")

Cmd.Flags().BoolVar(&depsConfig.Devnet.NoMining, "devnet-no-mining",
deps.DefaultDevnetNoMining,
"Devnet disable mining")
"Disable Devnet 'auto/interval mining'.")

Cmd.Flags().StringVar(&depsConfig.Devnet.BlockFinalizationOffset, "devnet-finalization-offset",
deps.DefaultSlotsInAnEpoch,
"Devnet finalization block offset in blocks")

Cmd.Flags().BoolVar(&disablePostgres, "disable-postgres", false, "Disable Postgres")

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 in seconds when 'interval mining' is enabled. (default "1")
--devnet-docker-image string Devnet docker image name (default "cartesi/rollups-node-devnet:devel")
--devnet-finalization-offset string Devnet finalization block offset in blocks (default "1")
--devnet-mapped-port string Devnet local listening port number (default "8545")
--devnet-no-mining Disable Devnet 'auto/interval 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
```

### 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
BlockFinalizationOffset string
BlockToWaitForOnStartup string
NoMining bool
}
Expand All @@ -77,6 +79,7 @@ func NewDefaultDepsConfig() *DepsConfig {
DefaultDevnetDockerImage,
DefaultDevnetPort,
DefaultDevnetBlockTime,
DefaultSlotsInAnEpoch,
DefaultDevnetBlockToWaitForOnStartup,
DefaultDevnetNoMining,
},
Expand Down Expand Up @@ -257,6 +260,14 @@ func Run(ctx context.Context, depsConfig DepsConfig) (*DepsContainers, error) {
"--load-state",
"/usr/share/devnet/anvil_state.json",
}

if depsConfig.Devnet.BlockFinalizationOffset != "" {
cmd = append(cmd,
"--slots-in-an-epoch",
depsConfig.Devnet.BlockFinalizationOffset,
)
}

var waitStrategy *wait.LogStrategy
if depsConfig.Devnet.NoMining {
cmd = append(cmd, "--no-mining")
Expand Down

0 comments on commit c71013f

Please sign in to comment.