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

Fix spec and add spec for supra governance #63

Open
wants to merge 20 commits into
base: dev
Choose a base branch
from
Open

Conversation

axiongsupra
Copy link

No description provided.

@axiongsupra axiongsupra marked this pull request as ready for review September 11, 2024 03:29
aborts_if !table::spec_contains(voting_forum.proposals, proposal_id);
aborts_if is_voting_period_over(proposal);
aborts_if proposal.is_resolved;
aborts_if !exists<timestamp::CurrentTimeMicroseconds>(@supra_framework);

Choose a reason for hiding this comment

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

@axiongsupra not sure why this aborts_if is required and what purpose does it serve.

// };
let timestamp_secs_bytes = std::bcs::serialize(timestamp::spec_now_seconds());
let key = std::string::spec_utf8(RESOLVABLE_TIME_METADATA_KEY);
ensures simple_map::spec_get(post_proposal.metadata, key) == timestamp_secs_bytes;

Choose a reason for hiding this comment

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

This property only ensures that time is recorded. Other properties we should aim at adding are

  • vote by the voter is recorded (if not already voted)
  • vote by the voter is recorded (if vote is flipped)
  • total yes/no votes should tally (increase/decrease appropriately)

requires chain_status::is_operating();
//TODO: Remove pragma aborts_if_is_partial;
pragma aborts_if_is_partial = true;
// include IsProposalResolvableAbortsIf<ProposalType>;

Choose a reason for hiding this comment

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

No properties?

Comment on lines +143 to +144
aborts_if has_multi_step_key && !from_bcs::deserializable<bool>(simple_map::spec_get(proposal.metadata, multi_step_key));
aborts_if has_multi_step_key && from_bcs::deserialize<bool>(simple_map::spec_get(proposal.metadata, multi_step_key));

Choose a reason for hiding this comment

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

Not sure I understand the role of these. @axiongsupra


let post post_voting_forum = global<VotingForum<ProposalType>>(voting_forum_address);
let post post_proposal = table::spec_get(post_voting_forum.proposals, proposal_id);
aborts_if !exists<timestamp::CurrentTimeMicroseconds>(@supra_framework);

Choose a reason for hiding this comment

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

What is the role of this?

from_bcs::deserialize(simple_map::spec_get(proposal.metadata, multi_step_key));
aborts_if !is_multi_step && len(next_execution_hash) != 0;

aborts_if len(next_execution_hash) == 0 && !exists<timestamp::CurrentTimeMicroseconds>(@supra_framework);

Choose a reason for hiding this comment

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

Again, not sure at this point why !exist<timestamp::CurrentTimeMicroseconds>(@supra_framework) is needed. I do not see this in the source code.

requires chain_status::is_operating();
//TODO: Remove pragma aborts_if_is_partial;
pragma aborts_if_is_partial = true;
include AbortsIfNotContainProposalID<ProposalType>;

Choose a reason for hiding this comment

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

There is no ensures here, it seems commented out, why?

pragma aborts_if_is_partial = true;
include AbortsIfNotContainProposalID<ProposalType>;

let voting_forum = global<VotingForum<ProposalType>>(voting_forum_address);

Choose a reason for hiding this comment

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

No property here either, it's commented out, why?

let proposal = table::spec_get(voting_forum.proposals, proposal_id);
let voting_closed = spec_is_voting_closed<ProposalType>(voting_forum_address, proposal_id);
// Avoid Overflow
aborts_if voting_closed && (proposal.yes_votes <= proposal.no_votes || proposal.yes_votes + proposal.no_votes < proposal.min_vote_threshold);

Choose a reason for hiding this comment

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

It doesn't seem it reflects our logic wrt yes and no votes. We would abort if voting_closed && !(proposal.yes_votes >= proposal.min_vote_threshold) isn't it?

voting_forum_address: address,
proposal_id: u64,
): u64 {
let voting_forum = global<VotingForum<ProposalType>>(voting_forum_address);

Choose a reason for hiding this comment

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

Don't we need aborts_if if proposal_id doesn't exist? Perhaps some earlier schema that has been used can be reused here?

proposal_id: u64,
voting_forum: VotingForum<ProposalType>
): u64 {
let proposal = table::spec_get(voting_forum.proposals, proposal_id);

Choose a reason for hiding this comment

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

Same here, aborts_if is missing.

}

spec fun spec_is_voting_closed<ProposalType: store>(voting_forum_address: address, proposal_id: u64): bool {
let voting_forum = global<VotingForum<ProposalType>>(voting_forum_address);

Choose a reason for hiding this comment

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

aborts_if is missing?

@@ -113,7 +113,8 @@ spec supra_framework::reconfiguration {
/// Should equal to 0
spec emit_genesis_reconfiguration_event {
use supra_framework::reconfiguration::{Configuration};

// TODO remove aborts_if_is_partial after the property proved
pragma aborts_if_is_partial;

Choose a reason for hiding this comment

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

AbortsIfNotAptosFramework earlier need to be renamed to AbortsIfNotSupraFramework

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