Skip to content

Commit

Permalink
fix!: close epochs based on block numbers
Browse files Browse the repository at this point in the history
- Fixes the ClaimMismatch bug on v.1x.
- BREAKING CHANGE: replaces the CARTESI_EPOCH_DURATION environment
  variable with CARTESI_EPOCH_LENGTH_IN_BLOCKS.
  • Loading branch information
renan061 committed Jun 19, 2024
1 parent a04487a commit 41701d8
Show file tree
Hide file tree
Showing 14 changed files with 800 additions and 632 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@ 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).

<<<<<<< HEAD
## [Unreleased]

Check failure on line 10 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / assess-code-quality

Headings should be surrounded by blank lines

CHANGELOG.md:10 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Above] [Context: "## [Unreleased]"] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md022.md

### Added

- Added Rollups end-to-end test using Echo Dapp

### Fixed

- Fixed a bug that caused a `authority_claimer::ClaimMismatch` error when reprocessing inputs after a reboot.

### Changed

- Changed the dispatcher to close epochs based on block numbers instead of block timestamps.
- **BREAKING**: replaced `CARTESI_EPOCH_DURATION` with `CARTESI_EPOCH_LENGTH_IN_BLOCKS` to match the new epoch algorithm, and set its default value to 7200 (1 day worth of blocks, in average, considering one block is mined every 12 seconds).

## [1.4.0] 2024-04-09

### Added
Expand Down
8 changes: 4 additions & 4 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ for more information.
* **Type:** `string`
* **Default:** `""`

## `CARTESI_EPOCH_DURATION`
## `CARTESI_EPOCH_LENGTH_IN_BLOCKS`

Duration of a rollups epoch in seconds.
Length of a rollups epoch in blocks.

At the end of each epoch, the node will send claims to the blockchain.

* **Type:** `Duration`
* **Default:** `"86400"`
* **Type:** `uint64`
* **Default:** `"7200"`

## `CARTESI_SNAPSHOT_DIR`

Expand Down
4 changes: 2 additions & 2 deletions internal/node/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
type NodeConfig struct {
LogLevel LogLevel
LogPretty bool
RollupsEpochDuration Duration
RollupsEpochLengthInBlocks uint64
BlockchainID uint64
BlockchainHttpEndpoint Redacted[string]
BlockchainWsEndpoint Redacted[string]
Expand Down Expand Up @@ -75,7 +75,7 @@ func FromEnv() NodeConfig {
var config NodeConfig
config.LogLevel = getLogLevel()
config.LogPretty = getLogPretty()
config.RollupsEpochDuration = getEpochDuration()
config.RollupsEpochLengthInBlocks = getEpochLengthInBlocks()
config.BlockchainID = getBlockchainId()
config.BlockchainHttpEndpoint = Redacted[string]{getBlockchainHttpEndpoint()}
config.BlockchainWsEndpoint = Redacted[string]{getBlockchainWsEndpoint()}
Expand Down
8 changes: 4 additions & 4 deletions internal/node/config/generate/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ the snapshot matches the hash in the Application contract."""
# Rollups
#

[rollups.CARTESI_EPOCH_DURATION]
default = "86400" # 1 day in seconds
go-type = "Duration"
[rollups.CARTESI_EPOCH_LENGTH_IN_BLOCKS]
default = "7200" # 1 day (average) in blocks (considering one block is mined every 12 seconds)
go-type = "uint64"
description = """
Duration of a rollups epoch in seconds.
Length of a rollups epoch in blocks.
At the end of each epoch, the node will send claims to the blockchain."""

Expand Down
10 changes: 5 additions & 5 deletions internal/node/config/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions internal/node/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ func newDispatcher(c config.NodeConfig, workDir string) services.CommandService
s.Env = append(s.Env, fmt.Sprintf("HISTORY_ADDRESS=%v", c.ContractsHistoryAddress))
s.Env = append(s.Env, fmt.Sprintf("AUTHORITY_ADDRESS=%v", c.ContractsAuthorityAddress))
s.Env = append(s.Env, fmt.Sprintf("INPUT_BOX_ADDRESS=%v", c.ContractsInputBoxAddress))
s.Env = append(s.Env, fmt.Sprintf("RD_EPOCH_DURATION=%v",
int(c.RollupsEpochDuration.Seconds())))
s.Env = append(s.Env, fmt.Sprintf("RD_EPOCH_DURATION=%v", c.RollupsEpochLengthInBlocks))
s.Env = append(s.Env, fmt.Sprintf("CHAIN_ID=%v", c.BlockchainID))
s.Env = append(s.Env, fmt.Sprintf("DISPATCHER_HTTP_SERVER_PORT=%v",
getPort(c, portOffsetDispatcher)))
Expand Down
4 changes: 2 additions & 2 deletions offchain/dispatcher/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub struct DispatcherEnvCLIConfig {
#[command(flatten)]
pub blockchain_config: BlockchainCLIConfig,

/// Duration of rollups epoch in seconds, for which dispatcher will make claims.
#[arg(long, env, default_value = "604800")]
/// Duration of rollups epoch in blocks, for which dispatcher will make claims.
#[arg(long, env, default_value = "7200")]
pub rd_epoch_duration: u64,

/// Chain ID
Expand Down
Loading

0 comments on commit 41701d8

Please sign in to comment.