Skip to content

feat(params): add the staking subspace - #4727

Open
codchen wants to merge 13 commits into
claude/giga-staking-docs-simplifyfrom
claude/giga-staking-params-subspace
Open

codchen wants to merge 13 commits into
claude/giga-staking-docs-simplifyfrom
claude/giga-staking-params-subspace

Conversation

@codchen

@codchen codchen commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds staking's params to the giga params precompile's storage, for the staking precompile to read.

  • A Staking struct in ParamsStorage at slot 16: unbondingTime, maxValidators, maxEntries, maxVotingPowerRatio and maxVotingPowerEnforcementThreshold.
  • ReadStaking, HasStaking and WriteStaking. They are written once at genesis; later changes go through gov.
  • Bounds, so a change can't wedge staking: unbonding time within the period bounds, 1 to 100 bonded validators (the most an autobahn committee can hold), at least one entry, and a ratio in (0, 1].
  • Regenerated harness and layout testdata. Gov's param-change test now uses only gov's own keys.

Test plan

  • go test -race ./giga/evmonly/precompiles/...
  • Layout pinned against solc output; the harness's writes are read back through Go.

Stack

Replaces #4713. Each PR's base is the one above it; review and merge from the top.

  1. docs(giga-storage): keep only the staking structures an on-chain path reads #4726 docs(giga-storage): keep only the staking structures an on-chain path reads
  2. feat(params): add the staking subspace #4727 feat(params): add the staking subspace ← this PR
  3. feat(staking): read and write the staking precompile's storage #4728 feat(staking): read and write the staking precompile's storage
  4. feat(staking): delegate, redelegate and undelegate in a giga evmonly precompile #4729 feat(staking): delegate, redelegate and undelegate in a giga evmonly precompile
  5. test(staking): check delegations and EndBlock against x/staking #4730 test(staking): check delegations and EndBlock against x/staking

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedNov 16, 2026, 4:13 AM

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.43%. Comparing base (0ca730f) to head (3bf68ef).

Files with missing lines Patch % Lines
giga/evmonly/client/cli/paramchange.go 90.90% 1 Missing ⚠️
giga/evmonly/precompiles/params/staking.go 97.14% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                          Coverage Diff                          @@
##           claude/giga-staking-docs-simplify    #4727      +/-   ##
=====================================================================
+ Coverage                              61.40%   61.43%   +0.02%     
=====================================================================
  Files                                   2066     2067       +1     
  Lines                                 160953   160999      +46     
=====================================================================
+ Hits                                   98841    98903      +62     
+ Misses                                 62107    62091      -16     
  Partials                                   5        5              
Flag Coverage Δ
sei-chain 59.62% <95.65%> (+0.02%) ⬆️
sei-db 75.17% <ø> (ø)
sei-db-state-db 81.62% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
giga/evmonly/precompiles/params/table.go 96.22% <ø> (ø)
giga/evmonly/client/cli/paramchange.go 90.05% <90.90%> (+1.30%) ⬆️
giga/evmonly/precompiles/params/staking.go 97.14% <97.14%> (ø)

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codchen
codchen marked this pull request as ready for review November 9, 2026 03:49
@cursor

cursor Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches on-chain param storage layout and consensus-relevant staking limits, but changes are additive with validation, genesis one-shot writes, and broad tests.

Overview
Adds a staking subspace to the params precompile (0x1013) so x/staking settings live in ParamsStorage at slot 16 and can be read via ReadStaking / written once at genesis with WriteStaking (gov Apply for later changes).

The new Staking struct covers unbonding time, max validators/entries, max voting power ratio, and enforcement threshold, with whole-struct validation (period bounds, ≤100 validators, ratio in (0,1]). KindInt / uint32 storage kinds and CLI encode/format support round-trip staking param proposals.

Layout and harness testdata are updated so Go slot layout and compiler-written values stay pinned; gov’s “change every param” test is limited to gov keys only.

Reviewed by Cursor Bugbot for commit 3bf68ef. Bugbot is set up for automated code reviews on this repo. Configure here.

@seidroid seidroid Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Adds a staking subspace at slot 16 of the giga params precompile's storage, with typed read, write and validate functions, new uint32 and Int kinds, and regenerated layout and harness testdata. The layout, packing offsets, bit-width checks in decode and validate, and the whole-struct check that stops a gov change before genesis writes staking all hold, so nothing blocks; codex reported nothing, which matches this review, and codex added no findings of its own.

Non-blocking

1 finding on the changed lines, as inline comments.

1 nit, not posted on the code
  • giga/evmonly/precompiles/params/testdata/ParamsStorageHarness.bin-runtime:1 — The CBOR metadata in the regenerated bytecode records solc 0.8.28 (0x00081c). The harness and ParamsStorage.sol both pin pragma solidity 0.8.30, so the 0.8.28 compiler would reject them. Following the rebuild steps in the test comment will not reproduce this artifact as committed.

seidroid review · decision approve · session b5841916f62e4b9e9f9b84dfde426be7 · turn resp_claude_d4d8ca6120fbe286e02065f402250020 · item 4a01abd2899b5fa3bdf439cc1ad56053

Findings: 0 blocking | 1 non-blocking | 1 posted inline

shemnon and others added 10 commits November 12, 2026 11:59
Draft storage layouts for the EVM-only staking, distribution and slashing
precompiles, and the rationale behind them, taken from ffd15bb, which is not
merged on its own.

- staking-design-rationale.md: the proposal, built from three principles
  (Solidity slot layout, V2 structures for migration, rewards undesigned)
- StakingStorage, DistributionStorage, SlashingStorage: draft layouts
- Sets.sol: dependency-free AddressSet/UintSet with EnumerableSet's layout
… reads

- Drop the consensus address: validators are keyed by operator in staking,
  distribution and slashing. 0x22 is keyed by the ed25519 key, for the
  duplicate-key check and key lookups; slashing's 0x03 relation is dropped.
- Drop the enumeration sets read only by queries (0x37, unbonding and
  redelegations by delegator) or by entry slashing (0x33, 0x35).
- Keep redelegation entries in the redelegation queue, with a per-triple
  count for maxEntries.
- Store the bonded set as one ValidatorPower array instead of a mapping
  and a set.
- Update the rationale doc to match, including which queue entries the
  FIFO clamp delays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A mapping value grows at its end and needs no reserved slots. A struct
inside another, a top-level struct with variables after it, and an array
element cannot grow at their end; say what each can do instead, and add
an open question on validatorSlashEvents, the one array of structs kept
for good.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Validator is a mapping value, so it grows at its end and needs no
__gap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alues and sets in the growth rule

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only queries walk signing infos, so the slashing layout keeps no enumeration of
them, as the rule for enumerations says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add a Staking struct to ParamsStorage at slot 16: unbondingTime,
  maxValidators, maxEntries, maxVotingPowerRatio and
  maxVotingPowerEnforcementThreshold.
- ReadStaking, HasStaking and WriteStaking, which writes them once at
  genesis; later changes go through gov.
- Bound them so a change cannot wedge staking: unbonding time within the
  period bounds, 1..100 bonded validators (an autobahn committee's limit),
  at least one entry, and a ratio in (0, 1].
- Regenerate the harness and layout testdata, and keep the gov
  param-change test to gov's own keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codchen
codchen force-pushed the claude/giga-staking-params-subspace branch from 5a5dda3 to edf0390 Compare November 12, 2026 04:08
@codchen
codchen force-pushed the claude/giga-staking-docs-simplify branch from 90fa425 to 717798f Compare November 12, 2026 04:08
The harness and ParamsStorage declare pragma solidity 0.8.30, and the
committed binary came from 0.8.28. Rebuild it with 0.8.30 and name the
command that reproduces it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codchen
codchen force-pushed the claude/giga-staking-docs-simplify branch from 717798f to 01eba02 Compare November 16, 2026 03:48
codchen and others added 2 commits November 16, 2026 11:55
…king-params-subspace

Main now gives every param a Kind, which seid's param-change and query
commands parse and format by. Staking's integer params get KindInt: the CLI
reads a whole number and writes it back as V2 does, a uint32 as a JSON number
and an sdk.Int as a string.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants