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: Epoch change to Light Client contract and prover service #2706

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

Conversation

alxiong
Copy link
Contributor

@alxiong alxiong commented Mar 3, 2025

Closes #2684

This PR:

Apologize for such a large PR, but many components are so interconnected that I have to fix them all to even compile, let alone pass all the tests.

locally just just sol-test and cargo test -p hotshot-state-prover should show all tests passing.

This PR is best reviewed commit by commit -- I have tried my best to make each one self-contained and limited in scope.

This PR does not:

Fetch the actual Stake table for the next block from Sequencer's URL, which is handled in #2702

in future follow-up, We need to utilize this API return to parse out the input to newFinalizedState()

Key places to review:

Contracts: LightClient.sol, PlonkVerifier.sol, deployer.rs
Prover: cirucit.rs, service.rs


// === System Parameters ===
//
/// @notice number of blocks per epoch
uint64 public BLOCKS_PER_EPOCH;

// === Storage ===
//
/// @notice genesis stake commitment
StakeTableState public genesisStakeTableState;
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we still keeping the genesis state?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's because we can't remove any members due to this being an upgradable contract: https://docs.openzeppelin.com/upgrades-plugins/writing-upgradeable#modifying-your-contracts

@alxiong from that PoV shouldn't BLOCKS_PER_EPOCH be added at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yah, that's a good point. maybe I need to relocate this.
I should have add a "fork test" to make sure we can upgrade existing LC contract to this one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we definitely need some kind of test to show that the contract still works as expected after upgrading.

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 decide to use a child contract to contain all the diff instead. @sveitser thanks for pointing out the concern.

Copy link
Contributor

@mrain mrain left a comment

Choose a reason for hiding this comment

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

LGTM with a minor comment

Copy link
Collaborator

@sveitser sveitser left a comment

Choose a reason for hiding this comment

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

Just putting request for changes here based on the discussion so we don't accidentally merge early because there's already an approval.

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.

[Light Client] Update light client contract to support epoch
3 participants