feat: gate skip-app-hash-validation behind //go:build shadow via ConsensusPolicy#3401
Open
feat: gate skip-app-hash-validation behind //go:build shadow via ConsensusPolicy#3401
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3401 +/- ##
==========================================
- Coverage 59.04% 59.04% -0.01%
==========================================
Files 2105 2105
Lines 173297 173269 -28
==========================================
- Hits 102327 102300 -27
+ Misses 62091 62090 -1
Partials 8879 8879
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
b20f4d8 to
5908b0a
Compare
…ensusPolicy
Replaces the runtime --skip-app-hash-validation CLI flag with a
build-tag-gated ConsensusPolicy value owned by BlockExecutor. The
seid validator binary built without -tags shadow cannot bypass
AppHash, LastCommitHash, DataHash, EvidenceHash, ValidatorsHash, or
NextValidatorsHash checks — the flag, the bypass field, and the
bypass branches do not exist in the production binary. The shadow
binary always runs in shadow mode; there is no runtime knob.
Why no runtime config
Earlier drafts threaded a CLI flag and AppOptions value into a
ConsensusPolicy{skipAppHashValidation bool} struct. That worked but
left an operator footgun: a shadow binary would silently behave like
production unless the operator remembered to pass the flag, then fail
on the first AppHash mismatch and surprise the operator.
The build tag IS the toggle. The shadow binary's purpose is to
shadow-sync, period. ConsensusPolicy carries no fields; the method
SkipAppHashValidation() returns a different constant in each build
and the compiler folds it.
Refactor
- types.ConsensusPolicy is an empty struct in both builds. Method
set differs: default returns false, shadow returns true.
DefaultConsensusPolicy() is the only constructor.
- Block.ValidateBasic now does shape-only validation. The 3 hash
checks (LastCommitHash / DataHash / EvidenceHash) move into a new
Block.ValidateHashes(policy) gated by SkipAppHashValidation.
Deserialization paths (BlockFromProto, light-client, store load)
call ValidateBasic and pick up the shape-only contract.
- validateBlock(state, block, policy) plumbs the policy to the
AppHash / ValidatorsHash / NextValidatorsHash gates.
- BlockExecutor carries policy as a struct field; NewBlockExecutor
takes it as a constructor arg.
- node.New / makeNode / Handshaker thread the policy through.
- sei-cosmos/server/start.go passes tmtypes.DefaultConsensusPolicy()
unconditionally. No CLI flag, no viper, no AppOptions.
What stays unchanged
tmtypes.SkipLastResultsHashValidation remains a global atomic.Bool
flipped from gigaExecutorConfig.Enabled. Giga is a first-class
runtime-togglable production feature with intentional gas-accounting
divergence; that bypass is not in scope.
Empirical proof
- strings seid-default | grep skip-app-hash → 0 hits
- strings seid-shadow | grep skip-app-hash → 0 hits
(the flag literal never existed since we never registered it)
- Both builds clean: go build ./... and go build -tags shadow ./...
- Original 6 hash gates (AppHash, LastCommitHash, DataHash,
EvidenceHash, ValidatorsHash, NextValidatorsHash from commits
9fa70d2, 4ce5ed3, d9b7f9283) preserved.
Workflow
.github/workflows/ecr.yml adds sei-chain:shadow-<sha> mirroring the
existing mock_balances build-tag pattern.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5908b0a to
721d5ff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Shadow nodes need to bypass header / state hash checks to validate alternate execution engines (e.g., Giga V2) against canonical-chain blocks. The previous shape exposed
--skip-app-hash-validationas a runtime CLI flag on every seid binary, which made the production validator one config edit away from accepting bad blocks.Approach
The build tag is the toggle — there is no runtime knob.
ConsensusPolicyis an empty struct in both builds; the method returns a different constant per build and the compiler folds it. Bypass branches DCE in production. There is no Go API in either build to construct a policy with the opposite behavior.Block.ValidateBasicis split: shape-only checks stay there for deserializers, hash-integrity checks move toBlock.ValidateHashes(policy).validateBlock(state, block, policy)plumbs the policy toBlockExecutor, threaded fromnode.Newdown. Productionstart.gopassesDefaultConsensusPolicy()unconditionally — no cobra, no AppOptions, no viper.This eliminates two failure modes the runtime-flag shape allowed: (1) production binary accepting bad blocks via flag flip, (2) shadow binary silently behaving like production when the operator forgets to pass the flag.
Coverage
All 6 hash gates from the original implementation (commits
9fa70d2ff,4ce5ed348,d9b7f9283) are preserved: AppHash, LastCommitHash, DataHash, EvidenceHash, ValidatorsHash, NextValidatorsHash.SkipLastResultsHashValidationis left as-is — that's a first-class production feature gated ongigaExecutorConfig.Enabled, different security model..github/workflows/ecr.ymlpublishessei-chain:shadow-<sha>alongside the existing prod andmock_balancesimages.Verification
strings seid-default | grep skip-app-hash→ 0 hits (no flag, no string in either binary)go build ./...andgo build -tags shadow ./...both clean