Skip to content

Commit

Permalink
feat(evm-reader): Add input-reader retry policy
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura committed Jul 10, 2024
1 parent dee51a5 commit f9c9a73
Show file tree
Hide file tree
Showing 20 changed files with 636 additions and 298 deletions.
22 changes: 22 additions & 0 deletions cmd/cartesi-rollups-cli/root/deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const examples = `# Run all deps:
cartesi-rollups-cli run-deps`

var depsConfig = deps.NewDefaultDepsConfig()
var disablePostgres = false
var disableDevnet = false
var verbose = false

func init() {
Expand All @@ -42,6 +44,14 @@ func init() {
deps.DefaultPostgresPassword,
"Postgres password")

Cmd.Flags().BoolVar(&depsConfig.Postgres.SaveData, "postgres-save-data",
deps.DefaultPostgresSaveData,
"Postgres enable save data to local storage")

Cmd.Flags().StringVar(&depsConfig.Postgres.DataDir, "postrgres-data-dir",
deps.DefaultPostgresDataDir,
"Postgres local data dir")

Cmd.Flags().StringVar(&depsConfig.Devnet.DockerImage, "devnet-docker-image",
deps.DefaultDevnetDockerImage,
"Devnet docker image name")
Expand All @@ -58,6 +68,10 @@ func init() {
deps.DefaultDevnetNoMining,
"Devnet disable mining")

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

Cmd.Flags().BoolVar(&disableDevnet, "disable-devnet", false, "Disable Devnet")

Cmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "verbose logs")
}

Expand All @@ -77,6 +91,14 @@ func run(cmd *cobra.Command, args []string) {
slog.SetDefault(logger)
}

if disablePostgres {
depsConfig.Postgres = nil
}

if disableDevnet {
depsConfig.Devnet = nil
}

depsContainers, err := deps.Run(ctx, *depsConfig)
cobra.CheckErr(err)

Expand Down
2 changes: 2 additions & 0 deletions docs/cli/cartesi-rollups-cli_run-deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ cartesi-rollups-cli run-deps
--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 Postgress docker image name (default "postgres:16-alpine")
--postgres-mapped-port string Postgres local listening port number (default "5432")
Expand Down
15 changes: 15 additions & 0 deletions internal/deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const (
DefaultPostgresPort = "5432"
DefaultPostgresUser = "postgres"
DefaultPostgresPassword = "password"
DefaultPostgresSaveData = false
DefaultPostgresDataDir = "./postgres-data"
DefaultDevnetDockerImage = "cartesi/rollups-node-devnet:devel"
DefaultDevnetPort = "8545"
DefaultDevnetBlockTime = "1"
Expand All @@ -48,6 +50,8 @@ type PostgresConfig struct {
DockerImage string
Port string
Password string
SaveData bool
DataDir string
}

type DevnetConfig struct {
Expand All @@ -65,6 +69,8 @@ func NewDefaultDepsConfig() *DepsConfig {
DefaultPostgresDockerImage,
DefaultPostgresPort,
DefaultPostgresPassword,
DefaultPostgresSaveData,
DefaultPostgresDataDir,
},
&DevnetConfig{
DefaultDevnetDockerImage,
Expand Down Expand Up @@ -178,6 +184,15 @@ func Run(ctx context.Context, depsConfig DepsConfig) (*DepsContainers, error) {
postgresExposedPorts = strings.Join([]string{
depsConfig.Postgres.Port, ":", postgresExposedPorts}, "")
}

// var mounts []testcontainers.ContainerMount
// if depsConfig.Postgres.SaveData {
// mounts = append(mounts, testcontainers.GenericVolumeMountSource{
// Name: "app-data",

// }
// }

postgresReq := testcontainers.ContainerRequest{
Image: depsConfig.Postgres.DockerImage,
ExposedPorts: []string{postgresExposedPorts},
Expand Down
Loading

0 comments on commit f9c9a73

Please sign in to comment.