Skip to content

Feat/lean rainbowstaking#36

Closed
vlladin wants to merge 12 commits intoleanEthereum:mainfrom
gorondan:feat/lean-rainbowstaking
Closed

Feat/lean rainbowstaking#36
vlladin wants to merge 12 commits intoleanEthereum:mainfrom
gorondan:feat/lean-rainbowstaking

Conversation

@vlladin
Copy link
Copy Markdown

@vlladin vlladin commented Sep 8, 2025

🗒️ Description

This PR introduces the concept of the Staker and the roles it can assume. It is intended as a discussion starter and a foundation to build on top.

The main idea behind these roles is to give a Staker the ability to activate one or more roles at any given time. These roles can be: Attester, Includer, Proposer. They are currently defined in src/lean_spec/subspecs/staker/role.py. I also mocked some parameters I expect will be useful moving forward.

I’ve added a subspec called staker (though it might need renaming to rainbow staking) where the roles and staker settings are defined, along with a new Staker container that uses them. There is no real implementation of the roles yet (so no tests). I also added some types needed by the roles (e.g., Gwei, Epoch). I assume these types will need to be expanded anyway, so I went ahead and started on that.

One discussion point I want to raise is the separation of state between roles. For example, the balance of a Staker could be global (shared between roles) or separated for each role. I’m not sure what the best approach is, so for now I assumed some form of separation (also needed for staking/delegation).

Currently, these roles connect to the Staker via src/lean_spec/subspecs/staker/settings.py. Stakers are now part of the State via the Staker container.

Getting these roles set up is necessary to advance the Rainbow Staking specs. As discussions and development begin to crystallize, I will update the docs and tests as needed.

✅ Checklist

  • Ran tox checks to avoid unnecessary CI fails:
    uvx --with=tox-uv tox
  • Considered adding appropriate tests for the changes.
  • Considered updating the online docs in the ./docs/ directory.

gorondan and others added 2 commits September 4, 2025 16:44
…roposer roles for Staker. Added needed new types: Byte1, Epoch, Gwei, StakerIndex.
Copy link
Copy Markdown
Collaborator

@tcoratger tcoratger left a comment

Choose a reason for hiding this comment

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

It looks good to me. I just left minor comments, mostly due to very recent and significant changes to the repo. But the logic looks good to me, and this doesn't affect the rest of the code in any way, so we can merge without any worries and come back to it later.

For now, there are no methods implemented here, and I think we'll see what's wrong when we merge the first methods and interact with the client teams.

@@ -0,0 +1,26 @@
"""Staker Container"""
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.

Here in the header can we put a 5 lines (IA generated no problem) summary of this 3TS proposal https://ethresear.ch/t/three-tier-staking-3ts-unbundling-attesters-includers-and-execution-proposers/21648/1 as I imagine this is where this comes from?

We could also put the link or multiple links if needed for the reader to understand here what we are talking about.

I suspect that this container will be able to evolve over time but this is good to have an updated summary of what we are doing each time and update the description as this evolves.

Comment on lines +13 to +16
role_config: Annotated[
list[StakerSettings],
Field(min_length=3, max_length=3),
]
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.

We should be able to use List or Vector now that we have them.

See https://github.com/leanEthereum/leanSpec/blob/main/src/lean_spec/types/collections.py and usage over the codebase.

Comment on lines +64 to +67
stakers: Annotated[
list[Staker],
Field(max_length=DEVNET_CONFIG.staker_registry_limit),
]
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.

Same here you should be able to use List instead now

for performance optimisation purposes."""


class ProposerRole(BaseModel):
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.

strict base model no?

Comment on lines +118 to +128
delegations_quotas: Annotated[
list[Uint64],
Field(max_length=DEVNET_STAKER_CONFIG.delegations_registry_limit),
]
"""The quotas of each delegated balance for this role. This list is
parallel with the stakers list from the state."""

delegated_balances: Annotated[
list[Uint64],
Field(max_length=DEVNET_STAKER_CONFIG.delegations_registry_limit),
]
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.

List could be used here as well

class StakerSettings(BaseModel):
"""Parameters for the StakerSettings."""

role_identifier: Bytes1
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.

Comment on lines +1 to +16
"""This defines all Byte types used."""

from pydantic import Field
from typing_extensions import Annotated

Bytes1 = Annotated[
bytes,
Field(
min_length=1,
max_length=1,
description="A Byte1 type.",
),
]
"""
A type alias for a 1 byte value.
"""
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.

gorondan and others added 5 commits September 12, 2025 20:42
Co-authored-by: Thomas Coratger <60488569+tcoratger@users.noreply.github.com>
Co-authored-by: Thomas Coratger <60488569+tcoratger@users.noreply.github.com>
Co-authored-by: Thomas Coratger <60488569+tcoratger@users.noreply.github.com>
VALIDATOR_REGISTRY_LIMIT: Final = Uint64(2**12)
"""The maximum number of validators that can be in the registry."""

STAKER_REGISTRY_LIMIT: Final = 2**12
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.

Why this is not a Uint64 anymore?

@vlladin vlladin marked this pull request as ready for review September 16, 2025 18:25
@unnawut unnawut added the specs Scope: Changes to the specifications label Oct 28, 2025
@tcoratger
Copy link
Copy Markdown
Collaborator

@vlladin Can I close this one for now?

Seems like stale and rebasing would be a nightmare so that it is better to reopen when needed, what do you think?

@gorondan
Copy link
Copy Markdown

gorondan commented Nov 19, 2025

We were planning to reopen the PR from another branch, later, so I think it's ok to close this one.

@tcoratger tcoratger closed this Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

specs Scope: Changes to the specifications

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants