Skip to content

Hristo/accounting oracle setup PR#11

Draft
hristo-grigorov wants to merge 1265 commits intomasterfrom
hristo/accounting-oracle
Draft

Hristo/accounting oracle setup PR#11
hristo-grigorov wants to merge 1265 commits intomasterfrom
hristo/accounting-oracle

Conversation

@hristo-grigorov
Copy link
Copy Markdown

No description provided.

TheDZhon and others added 30 commits February 7, 2023 22:01
…upgrade-tests-access-control

test: hash consensus: add access control tests
Removed inline-assembly, MemUtils tests
Updated applyHarness
Fixed Beacon chain depositor munged
uint256 slotsPerEpoch; uint256 secondsPerSlot; uint256 genesisTime;
slotsPerEpoch, secondsPerSlot, genesisTime = getChainConfig(e);

assert (epochsPerFrame2 >= epochsPerFrame1) =>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Better using the actual implementation of the slot calculation rather than copying it here.

env e; calldataarg args; env e2; env e3;

submitReportData(e,args);
submitReportExtraDataEmpty(e2);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Correct me If I'm wrong, but this rule can be generalized for any method in-between: no matter what happens between the two submissions, one cannot submit the same report twice (since it represents the same ref slot).

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.

Yes, you are correct. I am adding a parametric rule to check the "any method called" case, which is more general than the current rule. Thanks.

env e; calldataarg args; env e2; calldataarg args2; env e3;

submitReportData(e,args);
submitReportExtraDataList(e2,args2);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same here, for cannotSubmitSameReportAfterSubmitExtraDataEmpty().

// }

definition UINT64_MAX() returns uint64 = 0xFFFFFFFFFFFFFFFF;
definition UINT256_MAX() returns uint256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

FYI, this is defined in CVL as 'max_uint'.

* Methods Declaration *
**************************************************/
methods {
submitConsensusReport(bytes32 report, uint256 refSlot, uint256 deadline) => NONDET
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That's a state changing method, why not dispatch?

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.

The only state variable changed by this call is in the called contract, i.e., BaseOracle.
Also, HashConsensus is not using this state variable.
So from the HashConsensus.sol point of view, it doesn't matter.

// definition MANAGE_CONSENSUS_CONTRACT_ROLE() returns bytes32 = 0x04a0afbbd09d5ad397fc858789da4f8edd59f5ca5098d70faa490babee945c3b; //keccak256("MANAGE_CONSENSUS_CONTRACT_ROLE");
// definition MANAGE_CONSENSUS_VERSION_ROLE() returns bytes32 = 0xc31b1e4b732c5173dc51d519dfa432bad95550ecc4b0f9a61c2a558a2a8e4341; //keccak256("MANAGE_CONSENSUS_VERSION_ROLE");
// definition SUBMIT_DATA_ROLE() returns bytes32 = 0x65fa0c17458517c727737e4153dd477fa3e328cf706640b0f68b1a285c5990da; //keccak256("SUBMIT_DATA_ROLE");
definition UNREACHABLE_QUORUM() returns uint256 = max_uint256; // type(uint256).max
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

And here you're using it :)

require epochsPerFrame < 31536000; // assuming less than 1 year per frame

// assuming correct configuration of the frame, otherwise revert
require initialEpoch < (e.block.timestamp - genesisTime) / (secondsPerSlot * slotsPerEpoch);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can it be proved as an invariant, given that every call is at timestamp > genesis?

/**************************************************
* CVL FUNCS & DEFS *
**************************************************/
function saneTimeConfig() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why do you declare the env variable inside the function, and not use it as an input variable?

uint256 slotsPerEpoch; uint256 secondsPerSlot; uint256 genesisTime;
slotsPerEpoch, secondsPerSlot, genesisTime = getChainConfig(e0);

require slotsPerEpoch == 32; // simplification, must be required at constructor
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While this is a reasonable assumption, you must add it to the report.


uint256 initialEpoch; uint256 epochsPerFrame; uint256 fastLaneLengthSlots;
initialEpoch, epochsPerFrame, fastLaneLengthSlots = getFrameConfig(e0);
require epochsPerFrame > 0; // constructor already ensures this
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we write an invariant that verifies their non-zero value?

require epochsPerFrame < 31536000; // assuming less than 1 year per frame

// assuming correct configuration of the frame, otherwise revert
require initialEpoch < (e0.block.timestamp - genesisTime) / (secondsPerSlot * slotsPerEpoch);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same here. I guess it relies on the constructor?
Might it be changed during the contract's lifecycle?

// especially getCurrentFrame() as it is used by LegacyOracle and BaseOracle
// Status: Fail
// https://vaas-stg.certora.com/output/80942/985192ce8baf4725a8b6d29c1d0dc2af/?anonymousKey=f2574e5803ece9f5b8d734ecd68b1d9ac714c1d5
rule viewFunctionsDoNotRevert(method f)
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 suppose that if you intend verifying this rule, you want to include the sane assumptions block you've created?

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.