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

feat: add stake table interfaces contract #743

Merged
merged 4 commits into from
Nov 14, 2023

Conversation

alxiong
Copy link
Contributor

@alxiong alxiong commented Nov 13, 2023

Closes #673

note: I'm currently targeting plonk-verifier branch for easier git diff for the reviewers, and will change to main once #722 is merged

@alxiong alxiong self-assigned this Nov 13, 2023
@alxiong alxiong requested a review from ImJeremyHe as a code owner November 13, 2023 04:41
@alxiong alxiong requested review from fkrell and removed request for ImJeremyHe November 13, 2023 04:41
function register(
BN254.G1Point calldata blsVK,
EdOnBN254.EdOnBN254Point calldata schnorrVK,
uint64 amount,

Choose a reason for hiding this comment

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

Is uint64 type sufficient for amount?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm following our doc here by @jbearer

64 bits should be enough?

/// @param balance The amount of token staked.
/// @param registerEpoch The starting epoch for the validator.
/// @param exitEpoch The ending epoch for the validator.
struct Node {
Copy link
Contributor

Choose a reason for hiding this comment

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

This struct should contain the BLS and Schnorr public keys right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Half correct, should contains Schnorr key (and other auxiliary info)
there would be a mapping in storage keeping track of mapping(BlsVerKey => Node), so no need to store BLS key again in the Node struct.

function frozenStakeTableCommitment() external view returns (bytes32);

/// @notice Get the total stake of the registered keys in the latest stake table (Head)
function totalStake() external view returns (uint256);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we differentiate between native and restake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

very interesting point! I see these options:

  1. keep as it is, let instantiations specify its own conversion, the output is neither native nor restaked total stake, but an interpreted/exchange-rate-weighted total stake
  2. returns (uint256, uint256), first one for native, second one for restaked
  3. returns (StakeType[] memory, uint256[] memory)

Option 3 is the most flexible and future-proof API, since it allows StakeType to be extended to more types (e.g. EthRestaked, BtcRestaked, ..., but Option 2 is most straightforward if the assumption that we only support ETH and native token is valid for the foreseeable future.

WDYT?

/// @notice Advance to the next epoch, the new `votingStakeTableCommitment` will be
/// `frozenStakeTableCommitment` and the new `frozenStakeTableCommitment` will be
/// `curEpochComm`,
function advanceEpoch(bytes32 curEpochComm) external returns (bool);
Copy link
Contributor

Choose a reason for hiding this comment

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

Who calls this function and why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think of this API as the "setter for stake commitments" (as we have getter as votingStakeTableCommitment() and frozenStakeTableCommitment())

So light client prover will submit new states and call this function to update the new finalized stake table commitments.

@alxiong alxiong merged commit fc1484e into plonk-verifier Nov 14, 2023
@alxiong alxiong deleted the stake-table-interface branch November 14, 2023 07:57
@alxiong
Copy link
Contributor Author

alxiong commented Nov 14, 2023

I'm sorry I messed up and push to the wrong remote branch, somehow when I revert changes, Github recognize it as "merged" ...

I will try to open a different PR to address comments above

😱 this is such weird behavior, I cannot submit a PR on this branch anymore. not sure why...


⚠️ Please move to #748 and continue reviewing!

sveitser pushed a commit that referenced this pull request Feb 4, 2025
* Bump HotShot

---------

Co-authored-by: imabdulbasit <[email protected]>
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.

3 participants