Skip to content

Commit

Permalink
[PVM] Add validator admin role, reduce root admin permissions (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
evlekht authored Aug 7, 2024
1 parent e00d359 commit b14ad74
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 193 deletions.
88 changes: 56 additions & 32 deletions vms/platformvm/addrstate/camino_address_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,74 @@ type (
const (
// Bits

AddressStateBitRoleAdmin AddressStateBit = 0 // super role

AddressStateBitRoleKYCAdmin AddressStateBit = 1 // allows to set KYCVerified and KYCExpired
AddressStateBitRoleOffersAdmin AddressStateBit = 2 // allows to set OffersCreator
AddressStateBitRoleConsortiumAdminProposer AddressStateBit = 3 // allows to create admin add/exclude member proposals

AddressStateBitKYCVerified AddressStateBit = 32
AddressStateBitKYCExpired AddressStateBit = 33
AddressStateBitConsortium AddressStateBit = 38
AddressStateBitNodeDeferred AddressStateBit = 39
AddressStateBitOffersCreator AddressStateBit = 50
AddressStateBitCaminoProposer AddressStateBit = 51
// Allow to set role bits
AddressStateBitRoleAdmin AddressStateBit = 0
// Allows to set KYC and KYB bits
AddressStateBitRoleKYCAdmin AddressStateBit = 1
// Allows to set OffersCreator bit
AddressStateBitRoleOffersAdmin AddressStateBit = 2
// Allows to create addMember and excludeMember admin-proposals
AddressStateBitRoleConsortiumSecretary AddressStateBit = 3
// Allows to set node deferred bit
AddressStateBitRoleValidatorAdmin AddressStateBit = 4

// Indicates that address passed KYC verification
AddressStateBitKYCVerified AddressStateBit = 32
// Indicates that address KYC verification is expired. (not yet implemented)
AddressStateBitKYCExpired AddressStateBit = 33
// Indicates that address is member of consortium
AddressStateBitConsortium AddressStateBit = 38
// Indicates that a node owned by this address (as consortium member) is deferred
AddressStateBitNodeDeferred AddressStateBit = 39
// Allows to create deposit offers
AddressStateBitOffersCreator AddressStateBit = 50
// Allows to create baseFee and feeDistribution proposals
AddressStateBitFoundationAdmin AddressStateBit = 51

AddressStateBitMax AddressStateBit = 63

// States

// 0b0000000000000000000000000000000000000000000000000000000000000000
AddressStateEmpty AddressState = 0

AddressStateRoleAdmin = AddressState(1) << AddressStateBitRoleAdmin // 0b1
AddressStateRoleKYCAdmin = AddressState(1) << AddressStateBitRoleKYCAdmin // 0b10
AddressStateRoleOffersAdmin = AddressState(1) << AddressStateBitRoleOffersAdmin // 0b100
AddressStateRoleConsortiumAdminProposer = AddressState(1) << AddressStateBitRoleConsortiumAdminProposer // 0b1000

AddressStateKYCVerified = AddressState(1) << AddressStateBitKYCVerified // 0b0100000000000000000000000000000000
AddressStateKYCExpired = AddressState(1) << AddressStateBitKYCExpired // 0b1000000000000000000000000000000000

AddressStateConsortium = AddressState(1) << AddressStateBitConsortium // 0b0100000000000000000000000000000000000000
AddressStateNodeDeferred = AddressState(1) << AddressStateBitNodeDeferred // 0b1000000000000000000000000000000000000000

AddressStateOffersCreator = AddressState(1) << AddressStateBitOffersCreator // 0b0100000000000000000000000000000000000000000000000000
AddressStateCaminoProposer = AddressState(1) << AddressStateBitCaminoProposer // 0b1000000000000000000000000000000000000000000000000000
// 0b0000000000000000000000000000000000000000000000000000000000000001
AddressStateRoleAdmin = AddressState(1) << AddressStateBitRoleAdmin
// 0b0000000000000000000000000000000000000000000000000000000000000010
AddressStateRoleKYCAdmin = AddressState(1) << AddressStateBitRoleKYCAdmin
// 0b0000000000000000000000000000000000000000000000000000000000000100
AddressStateRoleOffersAdmin = AddressState(1) << AddressStateBitRoleOffersAdmin
// 0b0000000000000000000000000000000000000000000000000000000000001000
AddressStateRoleConsortiumSecretary = AddressState(1) << AddressStateBitRoleConsortiumSecretary
// 0b0000000000000000000000000000000000000000000000000000000000010000
AddressStateRoleValidatorAdmin = AddressState(1) << AddressStateBitRoleValidatorAdmin

// 0b0000000000000000000000000000000100000000000000000000000000000000
AddressStateKYCVerified = AddressState(1) << AddressStateBitKYCVerified
// 0b0000000000000000000000000000001000000000000000000000000000000000
AddressStateKYCExpired = AddressState(1) << AddressStateBitKYCExpired
// 0b0000000000000000000000000100000000000000000000000000000000000000
AddressStateConsortium = AddressState(1) << AddressStateBitConsortium
// 0b0000000000000000000000001000000000000000000000000000000000000000
AddressStateNodeDeferred = AddressState(1) << AddressStateBitNodeDeferred
// 0b0000000000000100000000000000000000000000000000000000000000000000
AddressStateOffersCreator = AddressState(1) << AddressStateBitOffersCreator
// 0b0000000000001000000000000000000000000000000000000000000000000000
AddressStateFoundationAdmin = AddressState(1) << AddressStateBitFoundationAdmin

// Bit groups (as AddressState)

AddressStateSunrisePhaseBits = AddressStateRoleAdmin | AddressStateRoleKYCAdmin | // 0b1100001100000000000000000000000000000011
// 0b0000000000000000000000001100001100000000000000000000000000000011
AddressStateSunrisePhaseBits = AddressStateRoleAdmin | AddressStateRoleKYCAdmin |
AddressStateKYCVerified | AddressStateKYCExpired | AddressStateConsortium |
AddressStateNodeDeferred

AddressStateAthensPhaseBits = AddressStateRoleOffersAdmin | AddressStateOffersCreator // 0b0100000000000000000000000000000000000000000000000100

AddressStateBerlinPhaseBits = AddressStateCaminoProposer | AddressStateRoleConsortiumAdminProposer // 0b1000000000000000000000000000000000000000000000001000

AddressStateValidBits = AddressStateSunrisePhaseBits | // 0b1100000000001100001100000000000000000000000000001111
// 0b0000000000000100000000000000000000000000000000000000000000000100
AddressStateAthensPhaseBits = AddressStateRoleOffersAdmin | AddressStateOffersCreator
// 0b0000000000001000000000000000000000000000000000000000000000001000
AddressStateBerlinPhaseBits = AddressStateFoundationAdmin | AddressStateRoleConsortiumSecretary |
AddressStateRoleValidatorAdmin
// 0b0000000000001100000000001100001100000000000000000000000000011111
AddressStateValidBits = AddressStateSunrisePhaseBits |
AddressStateAthensPhaseBits |
AddressStateBerlinPhaseBits
)
Expand Down
Loading

0 comments on commit b14ad74

Please sign in to comment.