Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch Permissioned Stake Table from L1 #2361

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open

Conversation

tbro
Copy link
Contributor

@tbro tbro commented Dec 5, 2024

Branched from #2325. Adds most everything from #2237. Main blocker now is to iron out ChainConfig versions. Then we can get into the actual stake table retrieval logic.

Closes #EspressoSystems/HotShot#3726
Supersedes: #2237
Targets: #2325

This PR

Adds the ability to fetch stake table from l1. It adds StaticCommittee type which replaces hotshot's StaticCommittee. This new type implements Membershp trait, holds L1Client in order to update Self.stake_table. In this way, hotshot will be able to obtain StakeTable via SystemContextHandle.members.

TODO

  • Fix ChainConfig versions
  • Implement l1 fetcher.
  • test

sveitser and others added 21 commits November 25, 2024 15:16
Missing conversion from G2 Affine to BLSPubKey.
- Update bindings.
- Add tests for event emission.
- The stake table isn't useful without stakers I think it makes sense to
  require it to be provided on deployment.
We will add some more ergonomic code for conversion to jellyfish at some
point. This code can be used as a stop gap until then.
breaks if we use: `serde.workspace = true`
@tbro tbro changed the title boilerplate Fetch Stake Table Dec 5, 2024
@tbro tbro mentioned this pull request Dec 5, 2024
@tbro tbro self-assigned this Dec 5, 2024
types/src/v0/impls/l1.rs Outdated Show resolved Hide resolved
sveitser and others added 4 commits December 6, 2024 17:15
Branched from #2325. Adds most everything from #2237. Main blocker now is to iron out
`ChainConfig` versions. Then we can get into the actual stake table
retrieval logic.
imabdulbasit and others added 4 commits December 10, 2024 12:02
* change lc proxy addr

* fix deploy-sequencer-contracts in docker compose

* test for stake table from toml file

* initial stake table toml file

* exclude toml file in typos

* remove custom deser
* remove generic from stake table

* lint

* move types to top, remove some more specified types

* update v99 reference test files
// If the last event for a stakers is `Added` the staker is currently
// staking, if the last event is removed or (or the staker is not present)
// they are not staking.
let currently_staking = changes_per_node
Copy link
Contributor

Choose a reason for hiding this comment

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

can a node be added and then removed or vice versa?

Copy link
Contributor

@imabdulbasit imabdulbasit Dec 10, 2024

Choose a reason for hiding this comment

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

so all the deltas of a node will have removed events first and then added? What happens if it is added and then removed? I am trying to understand the order of events in Vec<StakersUpdatedFilter>

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, the removed events are processed first.

So you can remove a node and in the same transaction add it again (to update the keys or DA status of that node).

Adding and removing is possible but not inside the same Ethereum transaction because the removals are processed first.

Copy link
Contributor

Choose a reason for hiding this comment

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

so Vec<StakersUpdatedFilter> is all the events from the start till the current block right? so we may do that in different transactions but always process the removed one first?

Copy link
Collaborator

@sveitser sveitser Dec 10, 2024

Choose a reason for hiding this comment

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

A transaction sent to the permissioned stake table contract will emit one event which will give us one StakersUpdatedFilter. That type has two Vecs of NodeInfo for removing and adding nodes respectively.

When doing the query with ethers one can set the "from block" and the "to block" to fetch a subset of events. Currenly here we would assume that we set "from block" to zero but "to block" we need to set correctly. So that we exclude changes during the current epoch until the next epoch.

@sveitser sveitser changed the title Fetch Stake Table Fetch Stake Table from L1 Dec 10, 2024
@sveitser sveitser changed the title Fetch Stake Table from L1 Fetch Permissioned Stake Table from L1 Dec 10, 2024
Base automatically changed from ma/simple-stake-table to main December 10, 2024 17:32
@tbro tbro marked this pull request as ready for review December 10, 2024 22:30
@tbro tbro mentioned this pull request Dec 13, 2024
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.

5 participants