Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

fix: resolving additional bugs and some refactors #78

Merged
merged 13 commits into from
Dec 18, 2023
Merged

Conversation

0xrajath
Copy link
Contributor

@0xrajath 0xrajath commented Dec 17, 2023

Motivation:

Small codebase changes

Modifications:

Bugs:

  • Vote weight adding similar to how we do _newCastCount in LlamaCore which has an upper bound condition. This will handle cases when someone has quantity greater than type(uint96).max) - currentCount. They get to vote too. (This is mostly applicable to ERC20s who can mint huge numbers). Added test_CanCastWhenCountisMax tests.
  • Due to the way solidity works, we had no way to get the mappings inside the CastData struct from an external contract. So added a hasTokenHolderCast to TokenHolderCaster that gets the values for votes and vetoes. Also added tests.
  • Cast Vote and Cast Veto should check if the ActionCaster has the defined role at ActionCreation time. Currently the tokenholders will be able to Vote even if the underlying TokenHolderCaster no longer has the role. It'll only fail at Submission time which can be annoying.

Refactors:

  • Removed the checkIf(Dis)ApprovalEnabled check in submit functions since they're checked in the underlying cast functions in the Llama Framework. Also removed the tests since there is no reasonable way to test this since the castVote and castVeto functions does have the checkIf(Dis)ApprovalEnabled check and it would have failed there. And we know for a fact that the cast(Dis)approval being called in the submit functions have the checkIf(Dis)ApprovalEnabled check and we have tests for that in the Llama Framework.

  • Note: We also don't need an Action state check on the submit functions since they're checked in the underlying cast functions in the Llama Framework. There is no reasonable way to test this since the castVote and castVeto functions does have the Action state check and it would have failed there. And we know for a fact that the cast(Dis)approval being called in the submit functions have the Action state check and we have tests for that in the Llama Framework.

  • Removed the approvalSubmitted and disapprovalSubmitted bool and respective AlreadySubmittedApproval and AlreadySubmittedDisapproval() checks. This is since the underlying LlamaFramework handles it through LlamaCore.DuplicateCast() error in the worst case. But more likely is that it triggers the LlamaCore.InvalidActionState since the state has already transitioned. And we know for a fact that the cast(Dis)approval being called in the submit functions have the above checks and we have tests for that in the Llama Framework.

  • Combined AlreadyCastVote() and AlreadyCastVeto() errors into a single DuplicateCast() error that matches the error style in Llama Framework and reduces the number of defined errors.

  • Combined ActionNotActive() and ActionNotQueued() errors into a single InvalidActionState(ActionState current) error that matches the error style in Llama Framework and reduces the number of defined errors. Moved this into the common _preCastAssertions function to match Llama style.

  • Changed VotingDelayNotOver() error to DelayPeriodNotOver() error to match the other Period errors.

  • Changed CannotSubmitYet() error to CastingPeriodNotOver() error to match the other Period errors.

Result:

Better and bug free code.

@0xrajath 0xrajath self-assigned this Dec 17, 2023
@0xrajath 0xrajath marked this pull request as ready for review December 17, 2023 21:50
@0xrajath 0xrajath changed the title refactor: codebase changes fix: resolving additional bugs and some refactors Dec 18, 2023
Copy link

Coverage after merging rajath/final-fixes into main will be

90.79%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src/token-voting
   LlamaTokenActionCreator.sol96%83.33%100%100%130–131, 270
   LlamaTokenCaster.sol86.36%86.84%82.14%86.88%204–205, 430, 435, 440, 440, 440–442, 442, 442, 444–447, 449, 458, 467, 472, 481, 481, 481–483, 483, 483, 485–488, 490
   LlamaTokenVotingFactory.sol85%50%100%100%94–96
src/token-voting/token-adapters
   LlamaTokenAdapterVotesTimestamp.sol95.65%50%100%100%74

@0xrajath 0xrajath merged commit d999ecd into main Dec 18, 2023
5 checks passed
@0xrajath 0xrajath deleted the rajath/final-fixes branch December 18, 2023 03:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants