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

remove epoch related code from light client contract #1934

Merged

Conversation

alysiahuggins
Copy link
Contributor

@alysiahuggins alysiahuggins commented Aug 28, 2024

Closes #1928

This PR:

Simplifies the Light Client contract by removing any functionality related to epochs since epochs have not been implemented yet. Code Changes:

  • Removes the following from the LightClient contract and related code
    • the blocksPerEpoch variable
    • removes currentEpoch variable
  • Removes the following from the StakeTable contract
    • currentEpoch()
    • removes the tests as the stake table isn't used and the current version heavily depends on epochs which have not been implemented yet
  • Update the diff-test code

This PR does not:

  • remove epoch the StakeTable contracts as they are not used, instead the relevant tests are ignored when running just sol-test

Key places to review:

  • Updated Tests
  • Implementation Code
  • Deployment Scripts
  • Modified Rust Scripts

@alysiahuggins alysiahuggins linked an issue Aug 28, 2024 that may be closed by this pull request
@alysiahuggins alysiahuggins changed the title remove blocksPerEpoch from LC remove epoch related code from light client contract Aug 28, 2024
@alysiahuggins alysiahuggins marked this pull request as ready for review August 28, 2024 22:58
/// @dev Fetches the current epoch from the light client contract.
/// @return current epoch (computed from the current block)
function currentEpoch() public view returns (uint64) {
return lightClient.currentEpoch();
function currentEpoch() public pure returns (uint64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to keep the function currentEpoch()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

at the time i made the change, i wanted to keep the related tests with as little breaking changes as possible - but now that i removed the stateTable tests, i can remove that function

Copy link
Contributor

Choose a reason for hiding this comment

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

i also agree to keep this, a dummy logic is perfect here. Plus we are not using or auditing this contract anyway.

@@ -21,7 +21,7 @@ contract LightClientCommonTest is Test {
uint32 public constant BLOCKS_PER_EPOCH_TEST = 3;
uint32 public constant DELAY_THRESHOLD = 6;
uint32 public constant MAX_HISTORY_SECONDS = 1 days;
uint32 initialEpoch = 1 days;
uint32 public initialEpoch = 1 days;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to keep this variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah this epoch isn't used for testing the block per epoch functionality but for testing the retention period for storing the state history on the contract

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, should we change the name to avoid confusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done here 5acfd94

Copy link
Contributor

@alxiong alxiong left a comment

Choose a reason for hiding this comment

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

Thanks for the work! 👍

/// @dev Fetches the current epoch from the light client contract.
/// @return current epoch (computed from the current block)
function currentEpoch() public view returns (uint64) {
return lightClient.currentEpoch();
function currentEpoch() public pure returns (uint64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i also agree to keep this, a dummy logic is perfect here. Plus we are not using or auditing this contract anyway.

contracts/test/LightClient.t.sol Outdated Show resolved Hide resolved
contracts/test/LightClient.t.sol Outdated Show resolved Hide resolved
Comment on lines +51 to +53
/// Number of blocks per epoch for testing
pub const BLOCKS_PER_EPOCH: u32 = 3;

Copy link
Contributor

Choose a reason for hiding this comment

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

can we set to u32::MAX for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since the blocks_per_epoch is used to determine how many states to generate, which is then used in the tests, I would say we need to choose a small number. I would opt for 5 though

Copy link
Contributor

Choose a reason for hiding this comment

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

okay, sounds good.

contracts/test/StakeTable.t.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@alxiong alxiong left a comment

Choose a reason for hiding this comment

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

LGTM, one comment is: instead of forge test --no-match-contract, can we edit foundry.toml to ignore?
Because locally I won't have to remember to add that flag to forge commands all the time.

Thanks!

@alysiahuggins
Copy link
Contributor Author

alysiahuggins commented Aug 29, 2024

LGTM, one comment is: instead of forge test --no-match-contract, can we edit foundry.toml to ignore? Because locally I won't have to remember to add that flag to forge commands all the time.

Thanks!

@alxiong I agree, however, ignored_warnings_from in the foundry.toml didn't work. foundry-rs/foundry#4414

…st sol-test and proceed with changes to the diff-test
Copy link
Contributor

@philippecamacho philippecamacho left a comment

Choose a reason for hiding this comment

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

LGTM

@alysiahuggins alysiahuggins merged commit 1587f4a into main Aug 29, 2024
13 checks passed
@alysiahuggins alysiahuggins deleted the 1928-simplify-light-client-contract-remove-epoch-related-code branch August 29, 2024 17:23
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.

simplify light client contract: remove epoch related code
3 participants