Skip to content

Comments

feat: auto-detect network module, deprecate --attester-mode flag#357

Closed
tac0turtle wants to merge 2 commits intomainfrom
feat/auto-detect-network-module
Closed

feat: auto-detect network module, deprecate --attester-mode flag#357
tac0turtle wants to merge 2 commits intomainfrom
feat/auto-detect-network-module

Conversation

@tac0turtle
Copy link
Contributor

Summary

  • Auto-detect the network module at startup via an ABCI Params query, removing the need for the --evnode.attester-mode CLI flag
  • Deprecate FlagAttesterMode using cobra's MarkDeprecated (kept for backward compatibility, no effect)
  • Remove the now-unnecessary --evnode.attester-mode flag from integration test start args

How it works

At startup in setupNodeAndExecutor, detectNetworkModule issues an ABCI query to /evabci.network.v1.Query/Params. If the query returns code 0, the network module is registered and attester mode is enabled automatically. If the module is absent (non-zero code or error), sequencer mode is used.

Test plan

  • Unit tests for detectNetworkModule covering: module present, module absent (non-zero code), query error
  • All existing server/ and pkg/rpc/ tests pass
  • Linter passes with zero issues
  • Integration test with network module enabled confirms auto-detection works

Closes #156

🤖 Generated with Claude Code

Instead of requiring the --attester-mode CLI flag, detect the network
module at startup by issuing an ABCI Query for its Params endpoint.
If the query succeeds the module is present and attester mode is
enabled automatically.

The flag is marked deprecated via cobra's MarkDeprecated and kept for
backward compatibility but has no effect.

Closes #156

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tac0turtle tac0turtle requested a review from a team as a code owner February 23, 2026 19:00
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tac0turtle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors how attester mode is determined within the system. Instead of relying on a manual command-line flag, the system now intelligently detects the presence of the network module via an ABCI query during startup. This change simplifies node configuration, reduces potential for misconfiguration, and ensures that the operational mode aligns dynamically with the deployed application modules.

Highlights

  • Attester Mode Auto-detection: Implemented automatic detection of attester mode at startup by querying the ABCI Params for the network module, eliminating the need for a manual CLI flag.
  • Flag Deprecation: The --evnode.attester-mode CLI flag has been deprecated using Cobra's MarkDeprecated function, remaining for backward compatibility but having no functional effect.
  • Integration Test Cleanup: Removed the now-unnecessary --evnode.attester-mode flag from integration test startup arguments, streamlining test configurations.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • server/flags.go
    • Deprecated the FlagAttesterMode constant and its associated CLI flag.
    • Added comments to reflect the new auto-detection mechanism for attester mode.
  • server/start.go
    • Imported abci types from CometBFT and network/types from ev-abci.
    • Introduced a new detectNetworkModule function to query the ABCI application for the network module's presence.
    • Modified setupNodeAndExecutor to call detectNetworkModule and use its result to determine attesterMode, replacing the direct flag check.
    • Updated log messages to reflect the new attester/sequencer mode detection logic.
    • Passed the attesterMode variable to the rpc.NewServer constructor.
  • server/start_test.go
    • Added context, errors, log, and abci imports for testing.
    • Implemented a mockQuerier to simulate ABCI query responses for unit testing.
    • Added TestDetectNetworkModule to unit test the new auto-detection logic under various scenarios (module present, module absent, query error).
  • tests/integration/gm_gaia_health_test.go
    • Removed the deprecated --evnode.attester-mode flag from the getGmChain function's start arguments, aligning integration tests with the new auto-detection behavior.
Activity
  • Unit tests for detectNetworkModule were implemented and passed, covering scenarios where the module is present, absent (non-zero code), or a query error occurs.
  • All existing server/ and pkg/rpc/ tests passed successfully.
  • The linter passed with zero issues, ensuring code quality.
  • An integration test with the network module enabled is planned to confirm auto-detection works as expected.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively implements the auto-detection of the network module, which simplifies configuration by removing the --evnode.attester-mode flag. The flag is correctly deprecated for backward compatibility, and the integration tests are updated accordingly. The new detection logic is well-tested with unit tests.

I've added a few comments with suggestions to improve context handling and code maintainability, which will make the implementation more robust.

server/start.go Outdated

// Auto-detect attester mode by probing the network module via ABCI query.
// This makes the --attester-mode flag obsolete.
attesterMode := detectNetworkModule(app, sdkLogger)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

With the suggested change to detectNetworkModule to accept a context, this call site needs to be updated to pass it.

Suggested change
attesterMode := detectNetworkModule(app, sdkLogger)
attesterMode := detectNetworkModule(ctx, app, sdkLogger)

server/start.go Outdated
Comment on lines 564 to 587
func detectNetworkModule(app abciQuerier, logger log.Logger) bool {
req := &types.QueryParamsRequest{}
reqBytes, err := req.Marshal()
if err != nil {
logger.Error("failed to marshal network module probe request", "error", err)
return false
}

resp, err := app.Query(context.Background(), &abci.RequestQuery{
Path: "/evabci.network.v1.Query/Params",
Data: reqBytes,
})
if err != nil {
logger.Debug("network module not detected (query error)", "error", err)
return false
}
if resp.Code != 0 {
logger.Debug("network module not detected (non-zero response code)", "code", resp.Code)
return false
}

logger.Info("network module detected, enabling attester mode automatically")
return true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This function can be improved in two ways:

  1. Context Propagation: The function currently uses context.Background() for the ABCI query. It's better to propagate the context.Context from the caller (setupNodeAndExecutor) to allow for cancellation and proper lifecycle management.
  2. Magic String: The query path "/evabci.network.v1.Query/Params" is a magic string. It should be defined as a constant to improve maintainability and avoid typos. For example: const networkParamsQueryPath = "/evabci.network.v1.Query/Params".

Here is a suggested implementation addressing the context propagation. You'll also need to update the call site in setupNodeAndExecutor to pass the context.

func detectNetworkModule(ctx context.Context, app abciQuerier, logger log.Logger) bool {
	req := &types.QueryParamsRequest{}
	reqBytes, err := req.Marshal()
	if err != nil {
		logger.Error("failed to marshal network module probe request", "error", err)
		return false
	}

	resp, err := app.Query(ctx, &abci.RequestQuery{
		Path: "/evabci.network.v1.Query/Params",
		Data: reqBytes,
	})
	if err != nil {
		logger.Debug("network module not detected (query error)", "error", err)
		return false
	}
	if resp.Code != 0 {
		logger.Debug("network module not detected (non-zero response code)", "code", resp.Code)
		return false
	}

	logger.Info("network module detected, enabling attester mode automatically")
	return true
}


for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
result := detectNetworkModule(tc.querier, nopLogger)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This test will fail to compile if detectNetworkModule is updated to accept a context.Context as suggested in another comment. Please update this call to pass a context. context.Background() is appropriate for this test case.

Suggested change
result := detectNetworkModule(tc.querier, nopLogger)
result := detectNetworkModule(context.Background(), tc.querier, nopLogger)

…tant

- Pass context.Context from setupNodeAndExecutor to detectNetworkModule
  instead of using context.Background()
- Extract query path as networkParamsQueryPath constant
- Update test to pass context.Background()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

// Deprecated: FlagAttesterMode is no longer needed. Attester mode is now
// auto-detected by probing the network module at startup.
const FlagAttesterMode = config.FlagPrefixEvnode + "attester-mode"
Copy link
Member

Choose a reason for hiding this comment

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

AFAIK attester needs to be a flag, as not all nodes are attesters

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

I checked the issue, we were talking about another flag:

FlagNetworkSoftConfirmation and not FlagAttesterMode

@tac0turtle
Copy link
Contributor Author

I checked the issue, we were talking about another flag:

FlagNetworkSoftConfirmation and not FlagAttesterMode

interesting how it totally missed it.

@tac0turtle
Copy link
Contributor Author

ah i know the flag doesnt exist. the issue should have been closed

@tac0turtle tac0turtle closed this Feb 23, 2026
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.

[Feature Request]: Make FlagNetworkSoftConfirmation obsolete

2 participants