Skip to content

Commit

Permalink
feat: map old env variables to new ones
Browse files Browse the repository at this point in the history
  • Loading branch information
gligneul committed Dec 3, 2023
1 parent 477342a commit 24e1725
Show file tree
Hide file tree
Showing 19 changed files with 596 additions and 679 deletions.
4 changes: 2 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ USER root

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq5 ca-certificates curl
libpq5 ca-certificates curl redis-tools redis
RUN rm -rf /var/lib/apt/lists/*

# Copy deployment files
Expand All @@ -156,4 +156,4 @@ RUN chown cartesi:cartesi ${RUNTIME_DIR}
WORKDIR ${RUNTIME_DIR}

USER cartesi
CMD ["/bin/bash"]
CMD ["cartesi-rollups-node"]
72 changes: 72 additions & 0 deletions build/deps-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
version: "3.9"

name: rollups-node
services:
devnet:
image: sunodo/devnet:1.1.1
command:
[
"anvil",
"--block-time",
"${BLOCK_TIME:-5}",
"--load-state",
"/usr/share/sunodo/anvil_state.json",
]
ports:
- 8545:8545
healthcheck:
test: ["CMD", "eth_isready"]
interval: 10s
timeout: 1s
retries: 5
environment:
ANVIL_IP_ADDR: 0.0.0.0
volumes:
- blockchain-data:/usr/share/sunodo

machine_snapshot_setup:
image: cartesi/rollups-machine-snapshot:devel
volumes:
- machine:/var/opt/cartesi/machine-snapshots

dapp_deployer:
image: cartesi/rollups-cli:1.0.2
restart: on-failure
depends_on:
devnet:
condition: service_started
machine_snapshot_setup:
condition: service_completed_successfully
command:
[
"create",
"--rpc",
"http://devnet:8545",
"--deploymentFile",
"/usr/share/sunodo/localhost.json",
"--mnemonic",
"test test test test test test test test test test test junk",
"--templateHashFile",
"/var/opt/cartesi/machine-snapshots/0_0/hash",
"--outputFile",
"/usr/share/sunodo/dapp.json",
]
volumes:
- machine:/var/opt/cartesi/machine-snapshots:ro
- blockchain-data:/usr/share/sunodo

database:
image: postgres:13-alpine
ports:
- 5432:5432
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres || exit 1"]
interval: 10s
timeout: 5s
retries: 5
environment:
- POSTGRES_PASSWORD=password

volumes:
blockchain-data: {}
machine: {}
206 changes: 0 additions & 206 deletions build/docker-compose.yml

This file was deleted.

41 changes: 41 additions & 0 deletions build/node-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: "3.9"

name: rollups-node
services:
node:
image: "cartesi/rollups-node:devel"
ports:
- "10003:4000"
- "10007:5005"
restart: always
depends_on:
devnet:
condition: service_healthy
dapp_deployer:
condition: service_completed_successfully
machine_snapshot_setup:
condition: service_completed_successfully
database:
condition: service_healthy
environment:
CARTESI_LOG_LEVEL: "info"
CARTESI_LOG_TIMESTAMP: "true"
CARTESI_FEATURE_HOST_MODE: "false"
CARTESI_FEATURE_READER_MODE: "false"
CARTESI_EPOCH_DURATION: "120"
CARTESI_BLOCKCHAIN_ID: "31337"
CARTESI_BLOCKCHAIN_HTTP_ENDPOINT: "http://devnet:8545"
CARTESI_BLOCKCHAIN_WS_ENDPOINT: "ws://devnet:8545"
CARTESI_BLOCKCHAIN_IS_LEGACY: "false"
CARTESI_BLOCKCHAIN_GENESIS_BLOCK: "1"
CARTESI_BLOCKCHAIN_READ_DEPTH: "1"
CARTESI_CONTRACTS_DAPP_ADDRESS: "0x70ac08179605AF2D9e75782b8DEcDD3c22aA4D0C"
CARTESI_CONTRACTS_DAPP_DEPLOYMENT_BLOCK_NUMBER: "1"
CARTESI_CONTRACTS_HISTORY_ADDRESS: "0x4FF8BD9122b7D91d56Dd5c88FE6891Fb3c0b5281"
CARTESI_CONTRACTS_AUTHORITY_ADDRESS: "0x5050F233F2312B1636eb7CF6c7876D9cC6ac4785"
CARTESI_CONTRACTS_INPUT_BOX_ADDRESS: "0x59b22D57D4f067708AB0c00552767405926dc768"
CARTESI_SNAPSHOT_DIR: "/var/opt/cartesi/machine-snapshots"
CARTESI_AUTH_MNEMONIC: "test test test test test test test test test test test junk"
CARTESI_POSTGRES_ENDPOINT: "postgres://postgres:password@database:5432/postgres"
volumes:
- machine:/var/opt/cartesi/machine-snapshots
2 changes: 0 additions & 2 deletions cmd/cartesi-rollups-cli/root/send/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ func init() {
}

func run(cmd *cobra.Command, args []string) {
logger.Init("info", true)

payload, err := hexutil.Decode(hexPayload)
cobra.CheckErr(err)

Expand Down
36 changes: 28 additions & 8 deletions cmd/cartesi-rollups-node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,38 @@ package main

import (
"context"
"os"

"github.com/cartesi/rollups-node/internal/logger"
"github.com/cartesi/rollups-node/internal/config"
"github.com/cartesi/rollups-node/internal/services"
)

func main() {
logLevel := os.Getenv("CARTESI_LOG_LEVEL")
_, enableTimestamp := os.LookupEnv("CARTESI_LOG_ENABLE_TIMESTAMP")
logger.Init(logLevel, enableTimestamp)
var s []services.Service

ctx := context.Background()
if err := rootCmd.ExecuteContext(ctx); err != nil {
logger.Error.Panic(err)
// Start Redis first
s = append(s, newRedis())

// Start services without dependencies
s = append(s, newGraphQLServer())
s = append(s, newIndexer())
s = append(s, newStateServer())

// Start either the server manager or host runner
if config.GetFeatureHostMode() {
s = append(s, newHostRunner())
} else {
s = append(s, newServerManager())
}

// Enable claimer if reader mode is disabled
if !config.GetFeatureReaderMode() {
s = append(s, newAuthorityClaimer())
}

// Start services with dependencies
s = append(s, newAdvanceRunner()) // Depends on the server-manager/host-runner
s = append(s, newDispatcher()) // Depends on the state server
s = append(s, newInspectServer()) // Depends on the server-manager/host-runner

services.Run(context.Background(), s)
}
Loading

0 comments on commit 24e1725

Please sign in to comment.