Commit Graph

13 Commits

Author SHA1 Message Date
Christian Kamm 40708e80ef Fix underflow in voting computation
The vote power computation was broken for lockups that start very far
in the future.

- Fix the underflow itself
- Disallow lockups that start more than 100 years in the future
- Error if the lockup-scaled voting power is bigger than the maximum
  lockup voting power
2022-01-25 13:00:45 +01:00
microwavedcola1 6ba0788e48 comment
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-18 14:06:08 +01:00
Christian Kamm afa1e30269 Tests for starting time in deposit/grant
Including a bugfix to the Grant instruction
2021-12-17 10:44:11 +01:00
microwavedcola1 9d72320bdd
make vault per voter+mint instead of global per registrar+mint (#14) 2021-12-17 08:02:14 +01:00
Christian Kamm 9c8dd35ba6 Grant/CreateDeposit: Allow control of start timestamp 2021-12-17 07:51:06 +01:00
Christian Kamm ae7dea95eb Create voter requires authority signature
and can only be called once for each voter_authority.

Now that there's a separate "Grant" instruction, there's no longer a
need for CreateVoter to be idempotent and be callable on foreign
accounts.

Calling create voter manually on a PDA account could have allowed
automation.
2021-12-17 07:51:06 +01:00
Christian Kamm a5659f6666 Use specific size of VoterWeightRecord in initialization 2021-12-17 07:51:06 +01:00
Christian Kamm b41dfae916 Grant instruction: Add separate "payer" signer
The governance PDAs can't pay.
2021-12-10 18:06:52 +01:00
Christian Kamm 9a5182d317 Fix a bug where start_ts could become > end_ts
Previously period_current() could exceed periods_total().
2021-12-10 16:22:43 +01:00
Christian Kamm decdd1230c Address unaligned references, add padding
- Make Registrar zero-copy. While it was using borsh for serialization,
  the array of voting mint configs couldn't be serialized without
  unaligned references.
- Reorganize all zero_copy fields such that switching to repr(C) would
  not make a difference. (just for safety in case that happens)
- Add static asserts on the sizes of all account structs, so any changes
  are visible very early.
- Add padding to structs that didn't have it yet.
2021-12-09 11:59:14 +01:00
microwavedcola1 317b7168eb Remove instruction name logs since they would be redundant with next anchor release
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-07 19:12:56 +01:00
microwavedcola1 f777a43ed6 basic logging
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-05 21:10:32 +01:00
Christian Kamm 119bdffcec Add grant instruction 2021-12-05 20:36:01 +01:00