Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cleanup more tests #33

Draft
wants to merge 6 commits into
base: feature/cleanup
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 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
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
/rollups-espresso-reader
/rollups-node
/cartesi-rollups-*
.vscode
rollups-espresso-reader
docs
11 changes: 0 additions & 11 deletions .gitpod.yml

This file was deleted.

33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- markdownlint-disable MD024 -->
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.1-node-20250128]

### Changed

- Binary generation in CI now supporting multiple platforms

## [0.2.0-node-20250128]

### Changed

- Adapt to new node version (2025-01-28)
- Safer parsing of EIP-712 structures

## [0.1.0]

### Added

- Initial EspressoReader implementation


<!-- markdownlint-disable MD053 -->
[Unreleased]: https://github.com/cartesi/rollups-espresso-reader/compare/v0.2.1-node-20250128...HEAD
[0.2.1-node-20250128]: https://github.com/cartesi/rollups-espresso-reader/releases/tag/v0.2.1-node-20250128
[0.2.0-node-20250128]: https://github.com/cartesi/rollups-espresso-reader/releases/tag/v0.2.0-node-20250128
[0.1.0]: https://github.com/cartesi/rollups-espresso-reader/releases/tag/v0.1.0
7 changes: 1 addition & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@
#

env:
@echo export CGO_CFLAGS=\"$(CGO_CFLAGS)\"
@echo export CGO_LDFLAGS=\"$(CGO_LDFLAGS)\"
@echo export CARTESI_LOG_LEVEL="debug"
@echo export CARTESI_BLOCKCHAIN_HTTP_ENDPOINT=""
@echo export CARTESI_BLOCKCHAIN_WS_ENDPOINT=""
@echo export CARTESI_AUTH_MNEMONIC=\"test test test test test test test test test test test junk\"
@echo export CARTESI_POSTGRES_ENDPOINT="postgres://postgres:password@localhost:5432/rollupsdb?sslmode=disable"
@echo export CARTESI_TEST_POSTGRES_ENDPOINT="postgres://test_user:password@localhost:5432/test_rollupsdb?sslmode=disable"
@echo export CARTESI_TEST_MACHINE_IMAGES_PATH=\"$(CARTESI_TEST_MACHINE_IMAGES_PATH)\"
@echo export PATH=$(CURDIR):$$PATH
@echo export PATH=\"$(CURDIR):$$PATH\"
@echo export ESPRESSO_BASE_URL="https://query.decaf.testnet.espresso.network"
@echo export ESPRESSO_STARTING_BLOCK="1490657"
@echo export ESPRESSO_NAMESPACE="55555"
Expand Down
114 changes: 13 additions & 101 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,22 @@
// The sub-package generate specifies these environment variables.
package config

import (
"fmt"
"os"
)

// NodeConfig contains all the Node variables.
// See the corresponding environment variable for the variable documentation.
type NodeConfig struct {
LogLevel LogLevel
LogPrettyEnabled bool
BlockchainHttpEndpoint Redacted[string]
BlockchainWsEndpoint Redacted[string]
LegacyBlockchainEnabled bool
EvmReaderDefaultBlock DefaultBlock
BlockchainBlockTimeout int
SnapshotDir string
PostgresEndpoint Redacted[string]
HttpAddress string
HttpPort int
FeatureClaimSubmissionEnabled bool
FeatureMachineHashCheckEnabled bool
Auth Auth
AdvancerPollingInterval Duration
ValidatorPollingInterval Duration
ClaimerPollingInterval Duration
EspressoBaseUrl string
EspressoStartingBlock uint64
EspressoNamespace uint64
EspressoServiceEndpoint string
MaxRetries uint64
MaxDelay Duration
}

// Auth is used to sign transactions.
type Auth any

// AuthPrivateKey allows signing through private keys.
type AuthPrivateKey struct {
PrivateKey Redacted[string]
}

// AuthMnemonic allows signing through mnemonics.
type AuthMnemonic struct {
Mnemonic Redacted[string]
AccountIndex Redacted[int]
}

// AuthAWS allows signing through AWS services.
type AuthAWS struct {
KeyID Redacted[string]
Region Redacted[string]
LogLevel LogLevel
LogPrettyEnabled bool
BlockchainHttpEndpoint Redacted[string]
BlockchainWsEndpoint Redacted[string]
EvmReaderDefaultBlock DefaultBlock
BlockchainBlockTimeout int
PostgresEndpoint Redacted[string]
EspressoBaseUrl string
EspressoStartingBlock uint64
EspressoNamespace uint64
EspressoServiceEndpoint string
MaxRetries uint64
MaxDelay Duration
}

// Redacted is a wrapper that redacts a given field from the logs.
Expand All @@ -74,21 +39,8 @@ func FromEnv() NodeConfig {
config.LogPrettyEnabled = GetLogPrettyEnabled()
config.BlockchainHttpEndpoint = Redacted[string]{GetBlockchainHttpEndpoint()}
config.BlockchainWsEndpoint = Redacted[string]{GetBlockchainWsEndpoint()}
config.LegacyBlockchainEnabled = GetLegacyBlockchainEnabled()
config.EvmReaderDefaultBlock = GetEvmReaderDefaultBlock()
config.BlockchainBlockTimeout = GetBlockchainBlockTimeout()
config.SnapshotDir = GetSnapshotDir()
config.PostgresEndpoint = Redacted[string]{GetPostgresEndpoint()}
config.HttpAddress = GetHttpAddress()
config.HttpPort = GetHttpPort()
config.FeatureClaimSubmissionEnabled = GetFeatureClaimSubmissionEnabled()
config.FeatureMachineHashCheckEnabled = GetFeatureMachineHashCheckEnabled()
if config.FeatureClaimSubmissionEnabled {
config.Auth = AuthFromEnv()
}
config.AdvancerPollingInterval = GetAdvancerPollingInterval()
config.ValidatorPollingInterval = GetValidatorPollingInterval()
config.ClaimerPollingInterval = GetClaimerPollingInterval()
config.EspressoBaseUrl = GetBaseUrl() + "/v0"
config.EspressoStartingBlock = GetStartingBlock()
config.EspressoNamespace = GetNamespace()
Expand All @@ -97,43 +49,3 @@ func FromEnv() NodeConfig {
config.MaxDelay = GetPolicyMaxDelay()
return config
}

func AuthFromEnv() Auth {
switch GetAuthKind() {
case AuthKindPrivateKeyVar:
return AuthPrivateKey{
PrivateKey: Redacted[string]{GetAuthPrivateKey()},
}
case AuthKindPrivateKeyFile:
path := GetAuthPrivateKeyFile()
privateKey, err := os.ReadFile(path)
if err != nil {
panic(fmt.Sprintf("failed to read private-key file: %v", err))
}
return AuthPrivateKey{
PrivateKey: Redacted[string]{string(privateKey)},
}
case AuthKindMnemonicVar:
return AuthMnemonic{
Mnemonic: Redacted[string]{GetAuthMnemonic()},
AccountIndex: Redacted[int]{GetAuthMnemonicAccountIndex()},
}
case AuthKindMnemonicFile:
path := GetAuthMnemonicFile()
mnemonic, err := os.ReadFile(path)
if err != nil {
panic(fmt.Sprintf("failed to read mnemonic file: %v", err))
}
return AuthMnemonic{
Mnemonic: Redacted[string]{string(mnemonic)},
AccountIndex: Redacted[int]{GetAuthMnemonicAccountIndex()},
}
case AuthKindAWS:
return AuthAWS{
KeyID: Redacted[string]{GetAuthAwsKmsKeyId()},
Region: Redacted[string]{GetAuthAwsKmsRegion()},
}
default:
panic("invalid auth kind")
}
}
140 changes: 0 additions & 140 deletions internal/config/generate/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,6 @@ go-type = "bool"
description = """
If set to true, the node will add colors to its log output."""

#
# Features
#

[features.CARTESI_FEATURE_CLAIM_SUBMISSION_ENABLED]
default = "true"
go-type = "bool"
description = """
If set to false, the node will not submit claims (reader mode)."""

[features.CARTESI_FEATURE_MACHINE_HASH_CHECK_ENABLED]
default = "true"
go-type = "bool"
description = """
If set to false, the node will *not* check whether the Cartesi machine hash from
the snapshot matches the hash in the Application contract."""

#
# Rollups
#

[rollups.CARTESI_ADVANCER_POLLING_INTERVAL]
default = "7"
go-type = "Duration"
description = """
How many seconds the node will wait before querying the database for new inputs."""

[rollups.CARTESI_VALIDATOR_POLLING_INTERVAL]
default = "7"
go-type = "Duration"
description = """
How many seconds the node will wait before trying to finish epochs for all applications."""

[rollups.CARTESI_CLAIMER_POLLING_INTERVAL]
default = "7"
go-type = "Duration"
description = """
How many seconds the node will wait before querying the database for new claims."""

#
# Blockchain
#
Expand All @@ -68,88 +29,13 @@ go-type = "string"
description = """
WebSocket endpoint for the blockchain RPC provider."""

[blockchain.CARTESI_LEGACY_BLOCKCHAIN_ENABLED]
default = "false"
go-type = "bool"
description = """
If set to true the node will send transactions using the legacy gas fee model
(instead of EIP-1559)."""

[blockchain.CARTESI_EVM_READER_DEFAULT_BLOCK]
default = "finalized"
go-type = "DefaultBlock"
description = """
The default block to be used by EVM Reader when requesting new blocks.
One of 'latest', 'pending', 'safe', 'finalized'"""

[blockchain.CARTESI_BLOCKCHAIN_BLOCK_TIMEOUT]
default = "60"
go-type = "int"
description = """
Block subscription timeout in seconds."""

#
# Snapshot
#

[snapshot.CARTESI_SNAPSHOT_DIR]
default = "/var/lib/cartesi-rollups-node/snapshots"
go-type = "string"
description = """
Path to the directory with the cartesi-machine snapshot that will be loaded by the node."""

#
# Auth
#

[auth.CARTESI_AUTH_KIND]
default = "mnemonic"
go-type = "AuthKind"
description = """
One of "private_key", "private_key_file", "mnemonic", "mnemonic_file", "aws"."""

[auth.CARTESI_AUTH_PRIVATE_KEY]
go-type = "string"
description = """
The node will use this private key to sign transactions."""

[auth.CARTESI_AUTH_PRIVATE_KEY_FILE]
go-type = "string"
description = """
The node will use the private key contained in this file to sign transactions."""

[auth.CARTESI_AUTH_MNEMONIC]
go-type = "string"
description = """
The node will use the private key generated from this mnemonic to sign transactions."""

[auth.CARTESI_AUTH_MNEMONIC_FILE]
go-type = "string"
description = """
The node will use the private key generated from the mnemonic contained in this file
to sign transactions."""

[auth.CARTESI_AUTH_MNEMONIC_ACCOUNT_INDEX]
default = "0"
go-type = "int"
description = """
When using mnemonics to sign transactions,
the node will use this account index to generate the private key."""

[auth.CARTESI_AUTH_AWS_KMS_KEY_ID]
go-type = "string"
description = """
If set, the node will use the AWS KMS service with this key ID to sign transactions.

Must be set alongside `CARTESI_AUTH_AWS_KMS_REGION`."""

[auth.CARTESI_AUTH_AWS_KMS_REGION]
go-type = "string"
description = """
An AWS KMS Region.

Must be set alongside `CARTESI_AUTH_AWS_KMS_KEY_ID`."""

#
# Postgres
#
Expand All @@ -167,23 +53,6 @@ It is also possible to set the endpoint without a password and load it from Post
See [this](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-PASSFILE)
for more information."""

#
# HTTP
#

[http.CARTESI_HTTP_ADDRESS]
default = "127.0.0.1"
go-type = "string"
description = """
HTTP address for the node."""

[http.CARTESI_HTTP_PORT]
default = "10000"
go-type = "int"
description = """
HTTP port for the node.
The node will also use the 20 ports after this one for internal services."""

#
# Espresso
#
Expand Down Expand Up @@ -224,12 +93,3 @@ go-type = "Duration"
description = """
How many seconds the retry policy will wait between retries."""

#
# Temporary
#

[temp.CARTESI_MACHINE_SERVER_VERBOSITY]
default = "info"
go-type = "string"
description = """
TODO."""
Loading
Loading