Skip to content

review start#9

Draft
nd-certora wants to merge 1 commit intoRoy/staking-routerfrom
nurit/reviewForRoy
Draft

review start#9
nd-certora wants to merge 1 commit intoRoy/staking-routerfrom
nurit/reviewForRoy

Conversation

@nd-certora
Copy link
Copy Markdown

No description provided.


invariant StakingModuleIndexIsIdMinus1(uint256 moduleId)
getStakingModuleIndexById(moduleId)+1 == getStakingModuleIdById(moduleId)
//ND : what about moduleIds that are not in the system? Is there some array reference here? looks like a limited-scope rule
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's valid for every staking module that is registered in the system. Otherwise, the index of the moduleId is just zero.


invariant StakingModuleId(uint256 moduleId)
getStakingModuleIdById(moduleId) == moduleId
//same comment - is rule sanity passing on the insertion function ?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Again, this is only valid for modules that are registered.
I can maybe change the invariant that says ("or moduleId > count => getId == 0")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

that's a much better approach, invariants should not cause vacuity. One should assume that it is also safe to do requireinvariant. in this case it is not

function safeAssumptions(uint256 moduleId) {
requireInvariant modulesCountIsLastIndex();
if(moduleId > 0) {
if(moduleId > 0) { //this is strange if you invariants are prove - you can safely assume them
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

One of the invariants here leads to vacuity if the entry is zero.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Exactly, need to fix this

env e;

require getStakingModulesCount() == 0;
//ND: so is this rule checking first call to addStakingModule ?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Right

storage initState = lastStorage;

addStakingModule(e, name1, Address1, targetShare1, ModuleFee1, TreasuryFee1);
// ND: why do you need adding name1 ?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I should assume any different set of arbitrary arguments, no?

assert !lastReverted;
getStakingModuleIdById@withrevert(id);
assert !lastReverted;
// ND: so this rule only check that the last added one can be fetched, right?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes: once a module is added, the system cannot be "stuck".

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