Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ env:
@echo export CARTESI_LOG_LEVEL="info"
@echo export CARTESI_BLOCKCHAIN_DEFAULT_BLOCK="latest"
@echo export CARTESI_BLOCKCHAIN_HTTP_ENDPOINT="http://localhost:8545"
@echo export CARTESI_BLOCKCHAIN_WS_ENDPOINT="ws://localhost:8545"
@echo export CARTESI_BLOCKCHAIN_ID="31337"
@echo export CARTESI_EVM_READER_POLLING_INTERVAL="1"
@echo export CARTESI_CONTRACTS_INPUT_BOX_ADDRESS="0x346B3df038FE9f8380071eC6514D5a83aD143939"
@echo export CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS="0x3C1FE01c542a88A523FF6847eD1E26176c8C4ED0"
@echo export CARTESI_CONTRACTS_QUORUM_FACTORY_ADDRESS="0x1f94009389F408B8D0ADfFcF8BBDCe5552BaCa5F"
Expand Down
11 changes: 6 additions & 5 deletions cmd/cartesi-rollups-claimer/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
logLevel string
logColor bool
defaultBlockString string
blockchainHttpEndpoint string
blockchainHTTPEndpoint string
databaseConnection string
pollInterval string
maxStartupTime string
Expand Down Expand Up @@ -54,7 +54,7 @@ func init() {
"tint the logs (colored output)")
cli.AddFlagStrVar(flags, &databaseConnection, "database-connection", config.DATABASE_CONNECTION,
"Database connection string in the URL format\n(eg.: 'postgres://user:password@hostname:port/database') ")
cli.AddFlagStrVar(flags, &blockchainHttpEndpoint, "blockchain-http-endpoint", config.BLOCKCHAIN_HTTP_ENDPOINT,
cli.AddFlagStrVar(flags, &blockchainHTTPEndpoint, "blockchain-http-endpoint", config.BLOCKCHAIN_HTTP_ENDPOINT,
"Blockchain http endpoint")
cli.AddFlagStrVar(flags, &pollInterval, "poll-interval", config.CLAIMER_POLLING_INTERVAL,
"Poll interval")
Expand Down Expand Up @@ -100,9 +100,10 @@ func run(cmd *cobra.Command, args []string) {
createInfo.EthConn, err = ethutil.NewEthClient(
ctx, cfg.BlockchainHttpEndpoint.Raw(), logger,
ethutil.RetryConfig{
MaxRetries: cfg.BlockchainHttpMaxRetries,
RetryMinWait: cfg.BlockchainHttpRetryMinWait,
RetryMaxWait: cfg.BlockchainHttpRetryMaxWait,
MaxRetries: cfg.BlockchainHttpMaxRetries,
RetryMinWait: cfg.BlockchainHttpRetryMinWait,
RetryMaxWait: cfg.BlockchainHttpRetryMaxWait,
RequestTimeout: cfg.BlockchainHttpRequestTimeout,
}, authOpt)
cli.CheckErr(logger, err)

Expand Down
28 changes: 13 additions & 15 deletions cmd/cartesi-rollups-evm-reader/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/cartesi/rollups-node/internal/version"
"github.com/cartesi/rollups-node/pkg/ethutil"
"github.com/cartesi/rollups-node/pkg/service"
"github.com/ethereum/go-ethereum/ethclient"

"github.com/spf13/cobra"
)
Expand All @@ -22,8 +21,8 @@ var (
logLevel string
logColor bool
defaultBlockString string
blockchainHttpEndpoint string
blockchainWsEndpoint string
blockchainHTTPEndpoint string
pollInterval string
databaseConnection string
maxStartupTime string
enableInputReader bool
Expand Down Expand Up @@ -55,10 +54,10 @@ func init() {
"Tint the logs (colored output)")
cli.AddFlagStrVar(flags, &databaseConnection, "database-connection", config.DATABASE_CONNECTION,
"Database connection string in the URL format\n(eg.: 'postgres://user:password@hostname:port/database') ")
cli.AddFlagStrVar(flags, &blockchainHttpEndpoint, "blockchain-http-endpoint", config.BLOCKCHAIN_HTTP_ENDPOINT,
cli.AddFlagStrVar(flags, &blockchainHTTPEndpoint, "blockchain-http-endpoint", config.BLOCKCHAIN_HTTP_ENDPOINT,
"Blockchain http endpoint")
cli.AddFlagStrVar(flags, &blockchainWsEndpoint, "blockchain-ws-endpoint", config.BLOCKCHAIN_WS_ENDPOINT,
"Blockchain WS Endpoint")
cli.AddFlagStrVar(flags, &pollInterval, "poll-interval", config.EVM_READER_POLLING_INTERVAL,
"Poll interval")
cli.AddFlagStrVar(flags, &maxStartupTime, "max-startup-time", config.MAX_STARTUP_TIME,
"Maximum startup time in seconds")
cli.AddFlagBoolVar(flags, &enableInputReader, "input-reader", config.FEATURE_INPUT_READER_ENABLED,
Expand Down Expand Up @@ -89,6 +88,7 @@ func run(cmd *cobra.Command, args []string) {
EnableSignalHandling: true,
TelemetryCreate: true,
TelemetryAddress: cfg.EvmReaderTelemetryAddress,
PollInterval: cfg.EvmReaderPollingInterval,
},
Config: *cfg,
}
Expand All @@ -101,19 +101,17 @@ func run(cmd *cobra.Command, args []string) {
createInfo.EthClient, err = ethutil.NewEthClient(
ctx, cfg.BlockchainHttpEndpoint.Raw(), logger,
ethutil.RetryConfig{
MaxRetries: cfg.BlockchainHttpMaxRetries,
RetryMinWait: cfg.BlockchainHttpRetryMinWait,
RetryMaxWait: cfg.BlockchainHttpRetryMaxWait,
MaxRetries: cfg.BlockchainHttpMaxRetries,
RetryMinWait: cfg.BlockchainHttpRetryMinWait,
RetryMaxWait: cfg.BlockchainHttpRetryMaxWait,
RequestTimeout: cfg.BlockchainHttpRequestTimeout,
}, authOpt)
cli.CheckErr(logger, err)

wsEndpoint := cfg.BlockchainWsEndpoint.Raw()
createInfo.EthWsClient, err = ethclient.DialContext(ctx, wsEndpoint)
cli.CheckErr(logger, ethutil.RedactEndpointFromError(err, wsEndpoint))

createInfo.Repository, err = factory.NewRepositoryFromConnectionString(ctx, cfg.DatabaseConnection.Raw())
repo, err := factory.NewRepositoryFromConnectionString(ctx, cfg.DatabaseConnection.Raw())
cli.CheckErr(logger, err)
defer createInfo.Repository.Close()
defer repo.Close()
createInfo.Repository = repo

readerService, err := evmreader.Create(ctx, &createInfo)
cli.CheckErr(logger, err)
Expand Down
36 changes: 17 additions & 19 deletions cmd/cartesi-rollups-node/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package root

import (
"context"
"time"

"github.com/cartesi/rollups-node/internal/cli"
"github.com/cartesi/rollups-node/internal/config"
Expand All @@ -28,9 +29,9 @@ var (
logLevelPrt string
logLevelValidator string
defaultBlockString string
blockchainHttpEndpoint string
blockchainWsEndpoint string
blockchainHTTPEndpoint string
databaseConnection string
evmReaderPollInterval string
advancerPollInterval string
validatorPollInterval string
claimerPollInterval string
Expand All @@ -41,7 +42,7 @@ var (
enableJsonrpc bool
enableSubmission bool
enableMachineHashCheck bool
jsonrpcApiAddress string
jsonrpcAPIAddress string
inspectAddress string
telemetryAddress string
machinelogLevel string
Expand All @@ -64,7 +65,7 @@ func init() {

cli.AddFlagStrVarP(flags, &defaultBlockString, "default-block", "d", config.BLOCKCHAIN_DEFAULT_BLOCK,
"Default block to be used when fetching new blocks.\nOne of 'latest', 'safe', 'pending', 'finalized'")
cli.AddFlagStrVar(flags, &jsonrpcApiAddress, "jsonrpc-address", config.JSONRPC_API_ADDRESS,
cli.AddFlagStrVar(flags, &jsonrpcAPIAddress, "jsonrpc-address", config.JSONRPC_API_ADDRESS,
"Jsonrpc API service address and port")
cli.AddFlagStrVar(flags, &inspectAddress, "inspect-address", config.INSPECT_ADDRESS,
"Inspect service address and port")
Expand All @@ -88,18 +89,18 @@ func init() {
"Override log level for the validator service (default: inherit --log-level)")
cli.AddFlagStrVar(flags, &databaseConnection, "database-connection", config.DATABASE_CONNECTION,
"Database connection string in the URL format\n(eg.: 'postgres://user:password@hostname:port/database') ")
cli.AddFlagStrVar(flags, &blockchainHttpEndpoint, "blockchain-http-endpoint", config.BLOCKCHAIN_HTTP_ENDPOINT,
cli.AddFlagStrVar(flags, &blockchainHTTPEndpoint, "blockchain-http-endpoint", config.BLOCKCHAIN_HTTP_ENDPOINT,
"Blockchain HTTP endpoint")
cli.AddFlagStrVar(flags, &blockchainWsEndpoint, "blockchain-ws-endpoint", config.BLOCKCHAIN_WS_ENDPOINT,
"Blockchain WS Endpoint")
cli.AddFlagStrVar(flags, &evmReaderPollInterval, "evm-reader-poll-interval", config.EVM_READER_POLLING_INTERVAL,
"EVM reader poll interval")
cli.AddFlagStrVar(flags, &advancerPollInterval, "advancer-poll-interval", config.ADVANCER_POLLING_INTERVAL,
"Advancer poll interval")
cli.AddFlagStrVar(flags, &validatorPollInterval, "validator-poll-interval", config.VALIDATOR_POLLING_INTERVAL,
"Validator poll interval")
cli.AddFlagStrVar(flags, &claimerPollInterval, "claimer-poll-interval", config.CLAIMER_POLLING_INTERVAL,
"Claimer poll interval")
cli.AddFlagStrVar(flags, &prtPollInterval, "prt-poll-interval", config.PRT_POLLING_INTERVAL,
"Claimer poll interval")
"PRT poll interval")
cli.AddFlagStrVar(flags, &maxStartupTime, "max-startup-time", config.MAX_STARTUP_TIME,
"Maximum startup time in seconds")
cli.AddFlagBoolVar(flags, &enableInputReader, "input-reader", config.FEATURE_INPUT_READER_ENABLED,
Expand Down Expand Up @@ -128,7 +129,7 @@ func init() {
}
}

func newEthClient(ctx context.Context, svcName string) (*ethclient.Client, error) {
func newEthClient(ctx context.Context, svcName string, requestTimeout time.Duration) (*ethclient.Client, error) {
level := config.ResolveServiceLogLevel(svcName, cfg.LogLevel)
logger := service.NewLogger(level, cfg.LogColor).With("service", svcName)

Expand All @@ -139,9 +140,10 @@ func newEthClient(ctx context.Context, svcName string) (*ethclient.Client, error

return ethutil.NewEthClient(ctx, cfg.BlockchainHttpEndpoint.Raw(), logger,
ethutil.RetryConfig{
MaxRetries: cfg.BlockchainHttpMaxRetries,
RetryMinWait: cfg.BlockchainHttpRetryMinWait,
RetryMaxWait: cfg.BlockchainHttpRetryMaxWait,
MaxRetries: cfg.BlockchainHttpMaxRetries,
RetryMinWait: cfg.BlockchainHttpRetryMinWait,
RetryMaxWait: cfg.BlockchainHttpRetryMaxWait,
RequestTimeout: requestTimeout,
}, authOpt)
}

Expand All @@ -164,17 +166,13 @@ func run(cmd *cobra.Command, args []string) {
createInfo.CreateInfo.Logger = logger

var err error
createInfo.ReaderClient, err = newEthClient(ctx, config.ServiceEvmReader)
createInfo.ReaderClient, err = newEthClient(ctx, config.ServiceEvmReader, cfg.BlockchainHttpRequestTimeout)
cli.CheckErr(logger, err)

wsEndpoint := cfg.BlockchainWsEndpoint.Raw()
createInfo.ReaderWSClient, err = ethclient.DialContext(ctx, wsEndpoint)
cli.CheckErr(logger, ethutil.RedactEndpointFromError(err, wsEndpoint))

createInfo.ClaimerClient, err = newEthClient(ctx, config.ServiceClaimer)
createInfo.ClaimerClient, err = newEthClient(ctx, config.ServiceClaimer, cfg.BlockchainHttpRequestTimeout)
cli.CheckErr(logger, err)

createInfo.PrtClient, err = newEthClient(ctx, config.ServicePrt)
createInfo.PrtClient, err = newEthClient(ctx, config.ServicePrt, cfg.BlockchainHttpRequestTimeout)
cli.CheckErr(logger, err)

createInfo.Repository, err = factory.NewRepositoryFromConnectionString(ctx, cfg.DatabaseConnection.Raw())
Expand Down
7 changes: 4 additions & 3 deletions cmd/cartesi-rollups-prt/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ func run(cmd *cobra.Command, args []string) {
createInfo.EthClient, err = ethutil.NewEthClient(
ctx, cfg.BlockchainHttpEndpoint.Raw(), logger,
ethutil.RetryConfig{
MaxRetries: cfg.BlockchainHttpMaxRetries,
RetryMinWait: cfg.BlockchainHttpRetryMinWait,
RetryMaxWait: cfg.BlockchainHttpRetryMaxWait,
MaxRetries: cfg.BlockchainHttpMaxRetries,
RetryMinWait: cfg.BlockchainHttpRetryMinWait,
RetryMaxWait: cfg.BlockchainHttpRetryMaxWait,
RequestTimeout: cfg.BlockchainHttpRequestTimeout,
}, authOpt)
cli.CheckErr(logger, err)

Expand Down
5 changes: 1 addition & 4 deletions compose.individual-services.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
x-env: &env
CARTESI_LOG_LEVEL: info
CARTESI_BLOCKCHAIN_HTTP_ENDPOINT_FILE: /run/secrets/blockchain_http_endpoint
CARTESI_BLOCKCHAIN_WS_ENDPOINT_FILE: /run/secrets/blockchain_http_endpoint
CARTESI_BLOCKCHAIN_ID: 31337
CARTESI_EVM_READER_POLLING_INTERVAL: 1
CARTESI_CONTRACTS_INPUT_BOX_ADDRESS: 0x346B3df038FE9f8380071eC6514D5a83aD143939
CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS: 0x3C1FE01c542a88A523FF6847eD1E26176c8C4ED0
CARTESI_CONTRACTS_QUORUM_FACTORY_ADDRESS: 0x1f94009389F408B8D0ADfFcF8BBDCe5552BaCa5F
Expand Down Expand Up @@ -66,7 +66,6 @@ services:
secrets:
- auth_mnemonic
- blockchain_http_endpoint
- blockchain_ws_endpoint
- database_connection
environment:
<<: *env
Expand Down Expand Up @@ -155,7 +154,5 @@ secrets:
file: test/secrets/auth_mnemonic.txt
blockchain_http_endpoint:
file: test/secrets/blockchain_http_endpoint.txt
blockchain_ws_endpoint:
file: test/secrets/blockchain_ws_endpoint.txt
database_connection:
file: test/secrets/database_connection.txt
5 changes: 1 addition & 4 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
x-env: &env
CARTESI_LOG_LEVEL: info
CARTESI_BLOCKCHAIN_HTTP_ENDPOINT_FILE: /run/secrets/blockchain_http_endpoint
CARTESI_BLOCKCHAIN_WS_ENDPOINT_FILE: /run/secrets/blockchain_http_endpoint
CARTESI_BLOCKCHAIN_ID: 31337
CARTESI_EVM_READER_POLLING_INTERVAL: 1
CARTESI_CONTRACTS_INPUT_BOX_ADDRESS: 0x346B3df038FE9f8380071eC6514D5a83aD143939
CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS: 0x3C1FE01c542a88A523FF6847eD1E26176c8C4ED0
CARTESI_CONTRACTS_QUORUM_FACTORY_ADDRESS: 0x1f94009389F408B8D0ADfFcF8BBDCe5552BaCa5F
Expand Down Expand Up @@ -71,7 +71,6 @@ services:
secrets:
- auth_mnemonic
- blockchain_http_endpoint
- blockchain_ws_endpoint
- database_connection
environment:
<<: *env
Expand All @@ -87,7 +86,5 @@ secrets:
file: test/secrets/auth_mnemonic.txt
blockchain_http_endpoint:
file: test/secrets/blockchain_http_endpoint.txt
blockchain_ws_endpoint:
file: test/secrets/blockchain_ws_endpoint.txt
database_connection:
file: test/secrets/database_connection.txt
34 changes: 10 additions & 24 deletions internal/config/generate/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ Maximum number of inputs fetched per database query during advance processing an
synchronization. Bounds memory usage for applications with large backlogs of unprocessed inputs."""
used-by = ["advancer", "node"]

[rollups.CARTESI_EVM_READER_POLLING_INTERVAL]
default = "12"
go-type = "Duration"
description = """
Time in seconds to wait before checking for a new block header. The default (12s) is tuned for mainnet. Reduce for faster chains or devnets."""
used-by = ["evmreader", "node"]

[rollups.CARTESI_ADVANCER_POLLING_INTERVAL]
default = "3"
go-type = "Duration"
Expand Down Expand Up @@ -196,13 +203,6 @@ Examples:
omit = true
used-by = ["evmreader", "claimer", "node"]

[blockchain.CARTESI_BLOCKCHAIN_WS_ENDPOINT]
file = true
go-type = "URL"
description = """
WebSocket endpoint for the blockchain RPC provider."""
used-by = ["evmreader", "node"]

[blockchain.CARTESI_BLOCKCHAIN_LEGACY_ENABLED]
default = "false"
go-type = "bool"
Expand Down Expand Up @@ -240,26 +240,12 @@ description = """
Maximum wait time in seconds for the exponential backoff retry policy. The delay between retries for HTTP blockchain requests will never exceed this value, regardless of the backoff calculation."""
used-by = ["evmreader", "claimer", "node", "prt"]

[rollups.CARTESI_BLOCKCHAIN_WS_LIVENESS_TIMEOUT]
[rollups.CARTESI_BLOCKCHAIN_HTTP_REQUEST_TIMEOUT]
default = "120"
go-type = "Duration"
description = """
Maximum time in seconds to wait for a new block header on the WebSocket subscription before treating the connection as stalled and reconnecting. Handles silent connection drops where no error is delivered. The default (120s) is tuned for mainnet (~12s block time). Reduce for faster chains or devnets."""
used-by = ["evmreader", "node"]

[rollups.CARTESI_BLOCKCHAIN_WS_MAX_RETRIES]
default = "4"
go-type = "uint64"
description = """
Maximum number of consecutive WebSocket subscription failures before the service gives up and exits. A failure is counted only when a subscription attempt produces zero headers before disconnecting. Successful header processing resets the counter."""
used-by = ["evmreader", "node"]

[rollups.CARTESI_BLOCKCHAIN_WS_RECONNECT_INTERVAL]
default = "1"
go-type = "Duration"
description = """
Wait time in seconds between WebSocket subscription reconnection attempts after a connection failure."""
used-by = ["evmreader", "node"]
Maximum time in seconds allowed for each HTTP request to the blockchain provider. This prevents a single slow or stuck provider request from blocking a service indefinitely."""
used-by = ["evmreader", "claimer", "node", "prt"]

[rollups.CARTESI_BLOCKCHAIN_MAX_BLOCK_RANGE]
default = "0"
Expand Down
Loading
Loading