Skip to content

Conversation

@0xChin
Copy link
Member

@0xChin 0xChin commented Jun 26, 2025

Closes OPT-826, OPT-827, OPT-880

0xChin added 30 commits June 9, 2025 13:52
@0xChin 0xChin requested a review from 0xOneTony June 26, 2025 09:49
@0xChin 0xChin self-assigned this Jun 26, 2025
@0xChin 0xChin changed the title feat: add upgrade proposal feat: add submit upgrade proposal Jun 26, 2025
Copy link
Member

@0xOneTony 0xOneTony left a comment

Choose a reason for hiding this comment

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

Looks good so far! a few small comments, there are also some conflicts that need to be addressed

proposalDescription = "Protocol Upgrade Proposal";
}

function testFuzz_submitUpgradeProposal_succeeds(
Copy link
Member

Choose a reason for hiding this comment

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

I think the logic of this function gets too complex for a unit tests, lets have 2 different tests 1 for maintenance upgrade and 1 for protocol or governor upgrade

Copy link
Member Author

Choose a reason for hiding this comment

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

function testFuzz_submitUpgradeProposal_invalidProposalType_reverts(uint8 proposalTypeValue) public {
// Bound to proposal types that are NOT upgrade proposals (2, 3, 4)
// Valid upgrade proposal types are ProtocolOrGovernorUpgrade (0) and MaintenanceUpgrade (1)
proposalTypeValue = uint8(bound(proposalTypeValue, 2, 4));
Copy link
Member

Choose a reason for hiding this comment

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

to cover more cases I would change this to assume != 0 && != 1

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

fix: broken tests out of enum bounds had to change it bc tests were breaking when going out of bounds. will limit to test all the proposal types that are not the valid ones

Copy link
Member

Choose a reason for hiding this comment

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

can you explain a bit more why they fail? if we keep it 2-4 then we dont tests the case where type is >4 which is also an invalid proposal type

_validateAttestation(_attestationUid, _proposalType);

// Validate againstThreshold is non-zero and within bounds for percentage-based thresholds
if (_againstThreshold == 0 || _againstThreshold > 10000) {
Copy link
Member

Choose a reason for hiding this comment

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

would be good to explain a bit what the 10000 represents in a comment

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

why is this not fixed in the current PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

cursor[bot]

This comment was marked as outdated.

0xChin and others added 2 commits June 27, 2025 13:40
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

contract ProposalValidator_SubmitUpgradeProposal_Test is ProposalValidator_Init {
string proposalDescription;

event ProposalVotingModuleData(bytes32 indexed proposalHash, bytes encodedVotingModuleData);
Copy link
Member

Choose a reason for hiding this comment

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

We should declare this in the init with the other events

Copy link
Member Author

Choose a reason for hiding this comment

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

function testFuzz_submitUpgradeProposal_invalidProposalType_reverts(uint8 proposalTypeValue) public {
// Bound to proposal types that are NOT upgrade proposals (2, 3, 4)
// Valid upgrade proposal types are ProtocolOrGovernorUpgrade (0) and MaintenanceUpgrade (1)
proposalTypeValue = uint8(bound(proposalTypeValue, 2, 4));
Copy link
Member

Choose a reason for hiding this comment

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

can you explain a bit more why they fail? if we keep it 2-4 then we dont tests the case where type is >4 which is also an invalid proposal type

@0xChin 0xChin merged commit a87e8cc into sc-feat/permissionless-proposals Jun 30, 2025
3 checks passed
0xOneTony added a commit that referenced this pull request Jul 29, 2025
* feat: add submitFundingProposal function

* fix: compiler errors

* test: add submitFundingProposal tests

* chore: run pre-pr

* chore: add comments for submitFundingProposal

* docs: improve natspec

* feat: add validation for options length in ProposalValidator

* feat: get votingModuleAddress from ProposalTypeConfigurator

* feat: check for proposal existance on submission

* test: add InvalidOptionsLength tests

* chore: run pre-pr

* feat: add submitCouncilMemberElectionsProposal function

* chore: run pre-pr

* fix: remove duplicated tests

* test(fuzz): use fuzz testing for happy paths

* feat: add check for criteria value < optionslength

* perf: optimiza for loops usage

* test: fuzz invalid attestationUid

* test: fuzz invalid proposer

* fix: lack of attestation existance validation

* test: fuzz exceeded max options test

* test: fuzz unapproved attester

* test: reduce upper bound for array size

* test: remove duplicated test

* fix: update criteria value validation logic in ProposalValidator

* refactor(test): use helper functions for duplicated logic

* refactor: declare approvalVotingModule variable

* test: increment the assertions in council memeber election tests

* refactor(test): improve tests legibility

* test: use fuzzing instead of individual tests for edge cases

* test: improve submitFundingProposal assertions

* test: fuzz proposer

* chore(test): remove unused setup variables

* test: use fuzzing for sad submitFundingProposal paths

* chore: remove redundant tests

* test: use fuzzing for exceeded amount

* chore: run pre-pr

* refactor: normalize funding proposal voting modules in global variable

* test: fuzz proposal types for revert cases

* refactor: use minimal values for funding proposal revert cases tests

* refactor: use more descriptive variables for testing

* chore: run pre-pr

* refactor: use variables instead of hardcoded values

* chore: rename voting module depending on configurator instead of internal proposal type

* chore: improve tests naming

* test: expect proposal type configurator calls

* feat: add submitUpgradeProposal function

* refactor: improve variable names consistency

* test: add submitUpgradeProposal tests

* chore: run pre-pr

* refactpr(test): separate submitUpgradePropowal tests depending on proposal type

* test: improve coverage on InvalidProposalType tests

* chore: improve code legibility

* chore: improve comments

Co-authored-by: 0xOneTony <[email protected]>
Signed-off-by: Chiin <[email protected]>

* fix: merge conflicts

* fix: broken compile for missing variable

* fix: broken tests out of enum bounds

* fix: pre-pr

* fix: correct order for event emission

* refactor(test): declare events in Init contract

* refactor: use constants for code legibility

---------

Signed-off-by: Chiin <[email protected]>
Co-authored-by: 0xOneTony <[email protected]>
0xOneTony added a commit that referenced this pull request Jul 29, 2025
* feat: add submitFundingProposal function

* fix: compiler errors

* test: add submitFundingProposal tests

* chore: run pre-pr

* chore: add comments for submitFundingProposal

* docs: improve natspec

* feat: add validation for options length in ProposalValidator

* feat: get votingModuleAddress from ProposalTypeConfigurator

* feat: check for proposal existance on submission

* test: add InvalidOptionsLength tests

* chore: run pre-pr

* feat: add submitCouncilMemberElectionsProposal function

* chore: run pre-pr

* fix: remove duplicated tests

* test(fuzz): use fuzz testing for happy paths

* feat: add check for criteria value < optionslength

* perf: optimiza for loops usage

* test: fuzz invalid attestationUid

* test: fuzz invalid proposer

* fix: lack of attestation existance validation

* test: fuzz exceeded max options test

* test: fuzz unapproved attester

* test: reduce upper bound for array size

* test: remove duplicated test

* fix: update criteria value validation logic in ProposalValidator

* refactor(test): use helper functions for duplicated logic

* refactor: declare approvalVotingModule variable

* test: increment the assertions in council memeber election tests

* refactor(test): improve tests legibility

* test: use fuzzing instead of individual tests for edge cases

* test: improve submitFundingProposal assertions

* test: fuzz proposer

* chore(test): remove unused setup variables

* test: use fuzzing for sad submitFundingProposal paths

* chore: remove redundant tests

* test: use fuzzing for exceeded amount

* chore: run pre-pr

* refactor: normalize funding proposal voting modules in global variable

* test: fuzz proposal types for revert cases

* refactor: use minimal values for funding proposal revert cases tests

* refactor: use more descriptive variables for testing

* chore: run pre-pr

* refactor: use variables instead of hardcoded values

* chore: rename voting module depending on configurator instead of internal proposal type

* chore: improve tests naming

* test: expect proposal type configurator calls

* feat: add submitUpgradeProposal function

* refactor: improve variable names consistency

* test: add submitUpgradeProposal tests

* chore: run pre-pr

* refactpr(test): separate submitUpgradePropowal tests depending on proposal type

* test: improve coverage on InvalidProposalType tests

* chore: improve code legibility

* chore: improve comments

Co-authored-by: 0xOneTony <[email protected]>
Signed-off-by: Chiin <[email protected]>

* fix: merge conflicts

* fix: broken compile for missing variable

* fix: broken tests out of enum bounds

* fix: pre-pr

* fix: correct order for event emission

* refactor(test): declare events in Init contract

* refactor: use constants for code legibility

---------

Signed-off-by: Chiin <[email protected]>
Co-authored-by: 0xOneTony <[email protected]>
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.

3 participants