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

Record next challenge epoch. Extract CID to library. #38

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

anorth
Copy link
Collaborator

@anorth anorth commented Sep 23, 2024

This is a prefactor extracted from my work implementing provePosession. In addition to adding the challenge epoch, I realised there is insufficient testing for the basic logic around adding and removing pieces, and resolving all this was going to balloon the PR adding proving (for which the testing will be quite involved).

I haven't added all the necessary tests here, but it would be great @ZenGround0 if you could follow on from this and fill out those workflow tests.

@anorth anorth requested a review from ZenGround0 September 23, 2024 22:45
}

// TODO: test bad inputs to addRoot
// TODO: test removing roots, good and bad inputs
Copy link
Contributor

@ZenGround0 ZenGround0 Sep 23, 2024

Choose a reason for hiding this comment

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

There already exist tests removing roots. Though I agree we don't have as much testing as I'd like I thought that this fell more under fuzzing than unit tests. What else are you specifically looking for here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I get it, you'd like a more thorough check of all state variable changed by adding / removing. Can do

contracts/src/Cids.sol Outdated Show resolved Hide resolved
contracts/src/PDPService.sol Outdated Show resolved Hide resolved
contracts/src/PDPService.sol Show resolved Hide resolved
@@ -184,6 +197,11 @@ contract PDPService {
totalDelta += removeOneRoot(setId, rootIds[i]);
}
proofSetLeafCount[setId] -= totalDelta;
// Clear next challenge epoch if the set is now empty.
// It will be re-set when new data is added.
if (proofSetLeafCount[setId] == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should keep a counter of live roots and consult that both for the needsChallengeEpoch bool above and for this one. I think it makes sense to do here. But if you'd rather defer that that's ok.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not convinced yet, so will defer.

@anorth anorth force-pushed the anorth/challenge-epoch branch from 59513a8 to 26ca0c3 Compare September 24, 2024 01:44
@anorth anorth force-pushed the anorth/challenge-epoch branch from 26ca0c3 to 37bb48b Compare September 24, 2024 01:46
@anorth anorth merged commit 0c6916d into main Sep 24, 2024
1 check passed
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.

2 participants