Skip to content
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
54ea182
docs(giga-storage): propose staking, distribution and slashing storage
shemnon Nov 2, 2026
701b205
docs(giga-storage): keep only the staking structures an on-chain path…
codchen Nov 3, 2026
dcce426
docs(giga-storage): say where each kind of struct can grow
codchen Nov 5, 2026
269733b
docs(giga-storage): drop Validator's reserved slots
codchen Nov 5, 2026
ea164b7
docs(giga-storage): let an array element grow into a gap of its own
codchen Nov 5, 2026
2c812ee
docs(giga-storage): cover deletes, top-level values, scalar mapping v…
codchen Nov 5, 2026
6994fac
docs(giga-storage): give ValidatorSlashEvent a __gap
codchen Nov 5, 2026
717798f
docs(giga-storage): drop signingInfoSet
codchen Nov 9, 2026
81c182a
feat(params): add the staking subspace
codchen Nov 3, 2026
f30ab46
feat(staking): read and write the staking precompile's storage
codchen Nov 4, 2026
edf0390
refactor(params): take MaxBondedValidators from autobahn's committee cap
codchen Nov 9, 2026
8bafe18
feat(staking): store a validator in 15 slots
codchen Nov 5, 2026
ebe97e0
feat(staking): delegate, redelegate and undelegate in a precompile
codchen Nov 4, 2026
310f32a
feat(staking): never jail a validator
codchen Nov 9, 2026
2117c93
test(staking): check delegations and EndBlock against x/staking
codchen Nov 4, 2026
60ada4b
docs(staking): state the unbonding queue's real EndBlock throughput
codchen Nov 9, 2026
4c53cb4
test(staking): undo x/staking's jailing in the parity tests
codchen Nov 9, 2026
7982369
fix(staking): take calls only once an EndBlock has bonded validators
codchen Nov 9, 2026
ade0e82
test(staking): scope the parity coverage check and the invalid-reques…
codchen Nov 9, 2026
690a174
feat(evmonly): serve staking's bonded set as the validator set
codchen Nov 5, 2026
bf37f04
refactor(evmonlyapp): stop handling an ed25519 key error that cannot …
codchen Nov 5, 2026
1324fee
fix(evmonlyapp): serve no validators after a failed block commit
codchen Nov 9, 2026
4c7f65b
test(params): build the storage harness with solc 0.8.30
codchen Nov 12, 2026
d2cdc61
Merge branch 'claude/giga-staking-params-subspace' into claude/giga-s…
codchen Nov 12, 2026
9626d69
test(staking): build the storage harness with solc 0.8.30
codchen Nov 12, 2026
67974b9
Merge branch 'claude/giga-staking-storage-layer' into claude/giga-sta…
codchen Nov 12, 2026
288e5c1
Merge branch 'claude/giga-staking-precompile' into claude/giga-stakin…
codchen Nov 12, 2026
1ef21c9
Merge branch 'claude/giga-staking-parity-tests' into claude/giga-evmo…
codchen Nov 12, 2026
2665668
refactor(evmonly): move 1e18 decimal math to a shared dec package
codchen Nov 12, 2026
01fac38
Merge branch 'claude/giga-staking-storage-layer' into claude/giga-sta…
codchen Nov 12, 2026
c874455
Merge branch 'claude/giga-staking-precompile' into claude/giga-stakin…
codchen Nov 12, 2026
30fa8b4
Merge branch 'claude/giga-staking-parity-tests' into claude/giga-evmo…
codchen Nov 12, 2026
035bb86
fix(staking): refuse genesis validators worth no consensus power
codchen Nov 12, 2026
a0f9511
Merge branch 'claude/giga-staking-precompile' into claude/giga-stakin…
codchen Nov 12, 2026
4e32d71
Merge branch 'claude/giga-staking-parity-tests' into claude/giga-evmo…
codchen Nov 12, 2026
d830d0f
docs(giga-storage): propose staking, distribution and slashing storage
shemnon Nov 2, 2026
ca72590
docs(giga-storage): keep only the staking structures an on-chain path…
codchen Nov 3, 2026
a9bf44a
docs(giga-storage): say where each kind of struct can grow
codchen Nov 5, 2026
23de979
docs(giga-storage): drop Validator's reserved slots
codchen Nov 5, 2026
a576e3e
docs(giga-storage): let an array element grow into a gap of its own
codchen Nov 5, 2026
eb2760f
docs(giga-storage): cover deletes, top-level values, scalar mapping v…
codchen Nov 5, 2026
c2f60cd
docs(giga-storage): give ValidatorSlashEvent a __gap
codchen Nov 5, 2026
01eba02
docs(giga-storage): drop signingInfoSet
codchen Nov 9, 2026
66c7450
Merge branch 'claude/giga-staking-docs-simplify' into claude/giga-sta…
codchen Nov 16, 2026
16e8636
Merge branch 'claude/giga-staking-params-subspace' into claude/giga-s…
codchen Nov 16, 2026
a1f5106
Merge branch 'claude/giga-staking-storage-layer' into claude/giga-sta…
codchen Nov 16, 2026
8d4fb35
Merge branch 'claude/giga-staking-precompile' into claude/giga-stakin…
codchen Nov 16, 2026
df4c62b
Merge branch 'claude/giga-staking-parity-tests' into claude/giga-evmo…
codchen Nov 16, 2026
0ca730f
docs(giga-storage): keep delegations by validator
codchen Nov 16, 2026
3bf68ef
Merge branch 'claude/giga-staking-docs-simplify' into claude/giga-sta…
codchen Nov 16, 2026
12c5ad7
Merge branch 'claude/giga-staking-params-subspace' into claude/giga-s…
codchen Nov 16, 2026
c77cd41
feat(staking): keep each validator's delegators
codchen Nov 16, 2026
4358d77
Merge branch 'claude/giga-staking-storage-layer' into claude/giga-sta…
codchen Nov 16, 2026
2d7fcc3
Merge branch 'claude/giga-staking-precompile' into claude/giga-stakin…
codchen Nov 16, 2026
22f564f
test(staking): compare each validator's delegators with V2
codchen Nov 16, 2026
a78b084
Merge branch 'claude/giga-staking-parity-tests' into claude/giga-evmo…
codchen Nov 16, 2026
3eecf14
fix(evmonlyapp): serve validators without waiting for the commit in f…
codchen Nov 16, 2026
2c46720
feat(autobahn): tell the app which block closes an epoch
codchen Nov 16, 2026
6285f35
feat(staking): snapshot the bonded set when an epoch closes
codchen Nov 16, 2026
5240b62
Merge remote-tracking branch 'origin/main' into claude/giga-staking-s…
codchen Nov 16, 2026
9876bd8
Merge branch 'claude/giga-staking-storage-layer' into claude/giga-sta…
codchen Nov 16, 2026
2822d53
Merge branch 'claude/giga-staking-precompile' into claude/giga-stakin…
codchen Nov 16, 2026
f43c1f4
Merge branch 'claude/giga-staking-parity-tests' into claude/giga-evmo…
codchen Nov 16, 2026
ce583aa
docs(staking): say a redelegation that empties an unbonded source waits
codchen Nov 16, 2026
1617a68
Merge branch 'claude/giga-staking-precompile' into claude/giga-stakin…
codchen Nov 16, 2026
3790e4b
test(staking): compare redelegating an unbonded validator's last shar…
codchen Nov 16, 2026
4715836
Merge branch 'claude/giga-staking-parity-tests' into claude/giga-evmo…
codchen Nov 16, 2026
8a6aa88
fix(staking): keep each member's consensus key in the epoch snapshot
codchen Nov 16, 2026
6dc432b
Merge remote-tracking branch 'origin/main' into claude/giga-evmonly-g…
codchen Nov 16, 2026
24acfa7
feat(evmonly): serve staking's current bonded set as the validator set
codchen Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions docs/giga-storage/DistributionStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

/// @notice Storage schema of the evmonly distribution precompile (0x1007), held as
/// that address's contract storage. Each state variable is an x/distribution
/// store prefix, named in its comment.
/// @dev Params are `ParamsStorage.distribution`. Outstanding rewards and the
/// community pool sit in the balance of `DistributionEscrow`, a derived address
/// in `distribution/layout.go`. Amounts and stakes are wei; reward ratios and
/// slash fractions are 1e18-scaled.
contract DistributionStorage {
struct ValidatorHistoricalRewards {
uint256 cumulativeRewardRatio;
uint32 referenceCount;
}

struct ValidatorCurrentRewards {
uint256 rewards;
uint64 period;
}

struct DelegatorStartingInfo {
uint64 previousPeriod;
uint64 height;
uint256 stake;
}

struct ValidatorSlashEvent {
uint64 height;
uint64 validatorPeriod;
uint256 fraction;
uint256[8] __gap;
}

uint256 internal communityPool; // 0x00: FeePool.community_pool
address internal previousProposer; // 0x01: operator
mapping(address => uint256) internal validatorOutstandingRewards; // 0x02: validator =>
mapping(address => address) internal delegatorWithdrawAddr; // 0x03: delegator => payee; zero is the delegator
mapping(address => mapping(address => DelegatorStartingInfo)) internal delegatorStartingInfo; // 0x04: validator => delegator =>
mapping(address => mapping(uint64 => ValidatorHistoricalRewards)) internal validatorHistoricalRewards; // 0x05: validator => period =>
mapping(address => ValidatorCurrentRewards) internal validatorCurrentRewards; // 0x06: validator =>
mapping(address => uint256) internal validatorAccumulatedCommission; // 0x07: validator =>
mapping(address => ValidatorSlashEvent[]) internal validatorSlashEvents; // 0x08: validator => ascending by height
}
13 changes: 13 additions & 0 deletions docs/giga-storage/ParamsStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pragma solidity 0.8.30;
/// - Dec: uint256, fixed point with 18 decimal places (1e18 is 1).
/// - Duration: uint64 nanoseconds.
/// - Coins: uint256 wei, a whole number of usei; only the usei denom exists.
/// - Int: uint256.
/// - uint32: uint32.
/// Other V2 types have no stored form until a param needs one.
///
/// Once a public network runs this, the layout only grows: a new param takes
Expand All @@ -29,5 +31,16 @@ contract ParamsStorage {
uint256[8] __gap;
}

/// @dev x/staking's params. The enforcement threshold is consensus power.
struct Staking {
uint64 unbondingTime; // UnbondingTime
uint32 maxValidators; // MaxValidators
uint32 maxEntries; // MaxEntries
uint256 maxVotingPowerRatio; // MaxVotingPower
uint256 maxVotingPowerEnforcementThreshold; // MaxVotingPowerEnforcementThreshold
uint256[8] __gap;
}

Gov internal gov; // subspace "gov"
Staking internal staking; // subspace "staking"
}
16 changes: 16 additions & 0 deletions docs/giga-storage/Sets.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

/// @notice A set of addresses. positions holds each member's 1-based index into
/// values, 0 when absent; removal moves the last value into the gap. Read and
/// written by solstorage.Set.
struct AddressSet {
address[] values;
mapping(address => uint256) positions;
}

/// @notice A set of uint256 values, laid out as AddressSet.
struct UintSet {
uint256[] values;
mapping(uint256 => uint256) positions;
}
26 changes: 26 additions & 0 deletions docs/giga-storage/SlashingStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

/// @notice Storage schema of the evmonly slashing precompile (0x1014), held as that
/// address's contract storage. Each state variable is an x/slashing store prefix,
/// named in its comment.
/// @dev Params are `ParamsStorage.slashing`. Keys are validator operators. A
/// validator's ed25519 key is `StakingStorage.validators[operator].consensusPubkey`.
/// Times are Unix nanoseconds.
contract SlashingStorage {
struct ValidatorSigningInfo {
uint64 startHeight;
uint64 indexOffset;
uint64 jailedUntil;
bool tombstoned;
uint64 missedBlocksCounter;
}

struct ValidatorMissedBlockArray {
uint64 windowSize;
uint64[] missedBlocks; // bit i of the window is bit i%64 of word i/64
}

mapping(address => ValidatorSigningInfo) internal validatorSigningInfo; // 0x01: operator =>
mapping(address => ValidatorMissedBlockArray) internal validatorMissedBlocks; // 0x02: operator =>
}
126 changes: 126 additions & 0 deletions docs/giga-storage/StakingStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

import "./Sets.sol";

/// @notice Storage schema of the evmonly staking precompile (0x1005), held as that
/// address's contract storage. Each state variable is an x/staking store prefix,
/// named in its comment.
/// @dev Params are `ParamsStorage.staking`. Bonded tokens sit in the balance of
/// `BondedEscrow` and unbonded and unbonding tokens in `NotBondedEscrow`, derived
/// addresses in `staking/layout.go`. Tokens and balances are wei; shares and
/// rates are 1e18-scaled; times are Unix nanoseconds. Accounts are EVM addresses,
/// and a validator is keyed by its operator's. An enumeration is kept only where an
/// on-chain path walks it.
contract StakingStorage {
struct Description {
string moniker;
string identity;
string website;
string securityContact;
string details;
}

struct CommissionRates {
uint256 rate;
uint256 maxRate;
uint256 maxChangeRate;
}

struct Commission {
CommissionRates commissionRates;
uint64 updateTime;
}

struct Validator {
bytes32 consensusPubkey; // ed25519
bool jailed;
uint8 status; // 1=Unbonded, 2=Unbonding, 3=Bonded
uint256 tokens;
uint256 delegatorShares;
Description description;
uint64 unbondingHeight;
uint64 unbondingTime;
Commission commission;
uint256 minSelfDelegation;
}

/// @dev A bonded validator and the consensus power last sent for it.
struct ValidatorPower {
address operator;
uint64 power;
}

struct Delegation {
uint256 shares;
}

struct UnbondingDelegationEntry {
uint64 creationHeight;
uint64 completionTime;
uint256 initialBalance;
uint256 balance;
}

/// @dev A queue entry's completionTime is never earlier than the one before it.
struct UnbondingQueueEntry {
uint64 completionTime;
address delegator;
address validator;
}

/// @dev A redelegation entry's only record: V2's queue triplet and its
/// RedelegationEntry together.
struct RedelegationQueueEntry {
uint64 completionTime;
address delegator;
uint64 creationHeight;
address srcValidator;
address dstValidator;
uint256 initialBalance;
uint256 sharesDst;
}

/// @dev completionTime and unbondingHeight are the operator's validator's
/// unbondingTime and unbondingHeight when it began unbonding.
struct ValidatorQueueEntry {
uint64 completionTime;
uint64 unbondingHeight;
address operator;
}

/// @dev A first-in first-out queue: entries are at indexes [head, tail).
struct QueueBounds {
uint64 head;
uint64 tail;
}

ValidatorPower[] internal lastValidators; // 0x11: the bonded set, as last sent to consensus
uint256 internal lastTotalPower; // 0x12

mapping(address => Validator) internal validators; // 0x21: operator =>
AddressSet internal validatorSet; // every operator in validators
mapping(bytes32 => address) internal validatorsByConsensusPubkey; // 0x22, keyed by the key itself: consensusPubkey => operator
address[] internal validatorsByPower; // 0x23: unjailed operators, descending by power, ties to the lower address

mapping(address => mapping(address => Delegation)) internal delegations; // 0x31: delegator => validator =>
mapping(address => AddressSet) internal delegationsByDelegator; // delegator => validators

mapping(address => mapping(address => UnbondingDelegationEntry[])) internal unbondingDelegations; // 0x32: delegator => validator => entries, at most maxEntries

mapping(address => mapping(address => mapping(address => uint256))) internal redelegationEntryCounts; // 0x34: delegator => src => dst => open entries, at most maxEntries
mapping(address => mapping(address => uint256)) internal redelegationsByValDst; // 0x36: dst => delegator => open entries into dst

QueueBounds internal unbondingQueueBounds;
mapping(uint64 => UnbondingQueueEntry) internal unbondingQueue; // 0x41: index =>
QueueBounds internal redelegationQueueBounds;
mapping(uint64 => RedelegationQueueEntry) internal redelegationQueue; // 0x42: index =>
QueueBounds internal validatorQueueBounds;
mapping(uint64 => ValidatorQueueEntry) internal validatorQueue; // 0x43: index =>

/// @dev V2 to giga migration. The phase runs from the cutover height until
/// migrationCursor passes the last V2 key.
bool internal migrating;
bytes internal migrationCursor; // last V2 store key copied
bytes[] internal migrationFailures; // V2 store keys that could not be copied
}
25 changes: 20 additions & 5 deletions docs/giga-storage/params-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,21 @@ subspace.
| Dec | `uint256`, fixed point with 18 decimal places |
| Duration | `uint64` nanoseconds; every period, read or written, is nanoseconds |
| Coins | `uint256` wei, a whole number of usei; only the usei denom exists |
| Int | `uint256` |
| uint32 | `uint32` |

Another V2 type gets a stored form when a param first needs one. A value of
any unsigned width is stored in the bytes of its slot that solc gives its
field, so packed fields keep their neighbours. Values decode as unsigned: a
signed type needs a decoder before a param can use it.

- Owners read their params from 0x1013's storage with the `params` package's
Go readers (`ReadGov`). Gov reads `gov`. Nothing keeps a second copy.
Go readers (`ReadGov`, `ReadStaking`). Gov reads `gov` and staking reads
`staking`. Nothing keeps a second copy.
Planned readers for other subspaces are in *Later subspaces*.
- Params are written only at genesis (`WriteGov`, which refuses once gov's
params exist) and by a passed gov proposal (`Apply`). Both check the whole
subspace first.
- Params are written only at genesis (`WriteGov` and `WriteStaking`, which
refuse once their subspace's params exist) and by a passed gov proposal
(`Apply`). Both check the whole subspace first.

## Declaration table

Expand Down Expand Up @@ -165,6 +168,19 @@ naming `param`.
- Autobahn registers the params precompile next to gov when `evm_governance`
is set. Like gov, it refuses calls until the first block writes gov's params.

## Staking

- `staking` holds x/staking's `UnbondingTime`, `MaxValidators`, `MaxEntries`,
`MaxVotingPower` (the max voting power ratio) and
`MaxVotingPowerEnforcementThreshold`, in consensus power. `BondDenom` has no
param, since only usei exists; `HistoricalEntries` has none, since giga keeps
no historical info; `MinCommissionRate` comes with validator creation.
- Its check is x/staking's validation plus an unbonding time of `MinPeriod` to
`MaxPeriod`, and `MaxValidators` at most 100 (`MaxBondedValidators`), the
most members an autobahn committee holds.
- `HasStaking` reads `UnbondingTime`, which the check keeps nonzero. Staking
refuses calls, and its EndBlock does nothing, until the params are written.

## Tests

- Layout: every `ParamsStorage.sol` slot, offset and field type, and values the
Expand Down Expand Up @@ -193,5 +209,4 @@ has eleven today.
| baseapp | `BlockParams.max_gas` (and the other BlockParams fields) | evmonlyapp, per block |
| evm | `KeyMinFeePerGas`, `KeySeiSstoreSetGasEIP2200`, later the EIP-1559 set | executor, per block |
| migration | `NumKeysToMigratePerBlock`, `MigrateCosmosEnabled` | as needed |
| staking | the staking params | native staking |
| slashing | the slashing params | native slashing |
Loading
Loading