Skip to content

Add simple finality itest#2063

Merged
nickeskov merged 8 commits intodetermenistic-finality-featurefrom
add-simple-finality-itest
Apr 17, 2026
Merged

Add simple finality itest#2063
nickeskov merged 8 commits intodetermenistic-finality-featurefrom
add-simple-finality-itest

Conversation

@alexeykiselev
Copy link
Copy Markdown
Collaborator

No description provided.

@alexeykiselev alexeykiselev added the wip This is a WIP, should not be merged right away label Apr 15, 2026
Base automatically changed from generators-set to determenistic-finality-feature April 16, 2026 07:45
@alexeykiselev alexeykiselev force-pushed the add-simple-finality-itest branch from dfa1861 to 4d4bd2d Compare April 16, 2026 08:04
Updated genesis.json configuration to support go/scala/no -mining.
Enabled log level check added before querying latest finalized block height.
@alexeykiselev alexeykiselev removed the wip This is a WIP, should not be merged right away label Apr 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a smoke integration test around deterministic finality (feature activation + commit-to-generation workflow across Go/Scala nodes) and adjusts supporting state-hash/config plumbing to make the scenario reproducible in itests.

Changes:

  • Add a new smoke itest suite for finality and introduce a dedicated feature settings JSON enabling finality support.
  • Update itests genesis/config plumbing to distinguish Go vs Scala mining key derivation (mining_type) and to pass generation-period length into node configs.
  • Adjust commitments state-hash keying to avoid overwriting hashed components when multiple commitments are stored.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pkg/state/state.go Adds info-level logging around finalization state during block apply.
pkg/state/keys.go Introduces a special key type used for ordering/uniqueness in commitment state-hash tracking.
pkg/state/commitments.go Adds lastIndex() and uses an indexed key for state-hash pushes when storing commitments.
itests/testdata/feature_settings/finality_supported_setting.json New feature settings enabling deterministic finality support in itests.
itests/smoke_finality_internal_test.go New smoke suite that commits to generation periods after finality activation.
itests/init_internal_test.go Forces Docker client API version via environment variables during test setup.
itests/finality_internal_test.go Renames wallet address constants and adds a Scala miner address constant.
itests/docker/docker.go Also forces Docker client API version via environment variables in Docker helper.
itests/config/template.conf Passes generation-period-length into the node configuration template.
itests/config/miningtype.go Adds MiningType enum with go:generate for string/JSON helpers.
itests/config/miningtype_string.go Generated enum string/JSON marshaling code for MiningType.
itests/config/genesis_settings.go Switches genesis distribution from is_miner to mining_type and derives BLS keys differently for Go vs Scala mining.
itests/config/genesis.json Updates genesis distributions to use mining_type and reformats preactivated features.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread itests/init_internal_test.go Outdated
Comment on lines +53 to +60
// Set environment variables to enforce docker client connection with a required API version.
// Non-empty DOCKER_MACHINE_NAME allows to create client with DOCKER_API_VERSION.
if envErr := os.Setenv("DOCKER_MACHINE_NAME", "local"); envErr != nil {
return envErr
}
if envErr := os.Setenv("DOCKER_API_VERSION", "1.45"); envErr != nil {
return envErr
}
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testsSetup() unconditionally overwrites DOCKER_MACHINE_NAME and DOCKER_API_VERSION for the whole process. This can break users/CI that intentionally set these variables (or rely on Docker’s negotiated API version). Consider only setting them when they are not already set (via os.LookupEnv) and/or centralizing this logic in one place (it’s duplicated in itests/docker.NewDocker).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a function to check for an environment variable and set it only if it is not already defined.

Comment thread itests/docker/docker.go Outdated
Comment thread pkg/state/state.go Outdated
Comment thread pkg/state/state.go Outdated
Comment thread pkg/state/state.go
Comment on lines +1458 to +1463
if slog.Default().Enabled(context.Background(), slog.LevelInfo) {
finalizedHeight, err := s.stor.finality.lastFinalizedHeight(blockHeight)
if err != nil {
return fmt.Errorf("failed to build local endorsement message: %w", err)
}
slog.Info("Current finalization state", slog.Uint64("finalizedHeight", finalizedHeight),
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the finalization log from slog.Debug to an Info log executed for every block while DeterministicFinality is active. That can produce very high log volume in normal runs; consider keeping it at debug (or sampling/throttling) and/or using Enabled(..., slog.LevelDebug) to avoid expensive lookups without increasing default verbosity.

Suggested change
if slog.Default().Enabled(context.Background(), slog.LevelInfo) {
finalizedHeight, err := s.stor.finality.lastFinalizedHeight(blockHeight)
if err != nil {
return fmt.Errorf("failed to build local endorsement message: %w", err)
}
slog.Info("Current finalization state", slog.Uint64("finalizedHeight", finalizedHeight),
if slog.Default().Enabled(context.Background(), slog.LevelDebug) {
finalizedHeight, err := s.stor.finality.lastFinalizedHeight(blockHeight)
if err != nil {
return fmt.Errorf("failed to build local endorsement message: %w", err)
}
slog.Debug("Current finalization state", slog.Uint64("finalizedHeight", finalizedHeight),

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this is ok.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess the Enabled check is redundant here, because users mostly use logger at INFO level. What do you think?

Comment thread itests/smoke_finality_internal_test.go
Comment thread itests/smoke_finality_internal_test.go Outdated
Function to retrieve and compare finalized blocks heights added and called in test.
Comment thread pkg/state/keys.go
Comment on lines +788 to +789
// commitmentStateHashKey is used only to correctly order legacy state hash record.
// WARNING! Do not use the key for any storage operations.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move it to a new file? (state_hasher_keys.go, for example)

Comment thread itests/init_internal_test.go Outdated
Comment thread pkg/state/state.go
Comment on lines +1458 to +1463
if slog.Default().Enabled(context.Background(), slog.LevelInfo) {
finalizedHeight, err := s.stor.finality.lastFinalizedHeight(blockHeight)
if err != nil {
return fmt.Errorf("failed to build local endorsement message: %w", err)
}
slog.Info("Current finalization state", slog.Uint64("finalizedHeight", finalizedHeight),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess the Enabled check is redundant here, because users mostly use logger at INFO level. What do you think?

Comment thread itests/smoke_finality_internal_test.go
Comment thread itests/smoke_finality_internal_test.go
Section about env vars added to itest README.
@alexeykiselev alexeykiselev requested a review from nickeskov April 17, 2026 08:34
Copy link
Copy Markdown
Collaborator

@nickeskov nickeskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nickeskov nickeskov merged commit a9ae9e4 into determenistic-finality-feature Apr 17, 2026
11 checks passed
@nickeskov nickeskov deleted the add-simple-finality-itest branch April 17, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants