-
Notifications
You must be signed in to change notification settings - Fork 0
(1) Add Whitelist program #45
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
base: solana/settler
Are you sure you want to change the base?
Conversation
PedroAraoz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The program should be renamed to match it's EVM counterpart
| [package] | ||
| name = "whitelist" | ||
| version = "0.1.0" | ||
| description = "Created with Anchor" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would update the description and also add the missing license
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let me know which license we should use here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added license = GPL-3.0-only as GPL-3.0 is not present as an identifier in this list. Let me know if that is fine.
packages/svm/programs/whitelist/src/instructions/propose_admin.rs
Outdated
Show resolved
Hide resolved
packages/svm/programs/whitelist/src/instructions/set_proposed_admin.rs
Outdated
Show resolved
Hide resolved
packages/svm/programs/whitelist/src/instructions/set_entity_whitelist_status.rs
Outdated
Show resolved
Hide resolved
packages/svm/programs/whitelist/src/instructions/set_entity_whitelist_status.rs
Outdated
Show resolved
Hide resolved
| pub entity_type: EntityType, | ||
| pub entity_pubkey: Pubkey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT:
| pub entity_type: EntityType, | |
| pub entity_pubkey: Pubkey, | |
| pub type: EntityType, | |
| pub pubkey: Pubkey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to helpers.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this file used in future PRs?
| otherAdminSdk = new ControllerSDK(otherAdminProvider) | ||
| maliciousSdk = new ControllerSDK(maliciousProvider) | ||
|
|
||
| deployerProvider.client.airdrop(deployer.publicKey, BigInt(100_000_000_000)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT:
add Sol to Lamports helper function?
toLamports(10)
| }) | ||
| }) | ||
|
|
||
| describe('set_admin', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT
| describe('set_admin', () => { | |
| describe('set admin', () => { |
| // Reset admin to original for subsequent tests | ||
| const resetIx = await otherAdminSdk.setAdmin(admin.publicKey) | ||
| await makeTxSignAndSend(otherAdminProvider, resetIx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this to an after()
| let solver2: web3.PublicKey | ||
|
|
||
| before(() => { | ||
| validator = web3.Keypair.generate().publicKey |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
web3.Keypair.generate().publicKey I would create a helper function for this
| instructions::set_admin(ctx, new_admin) | ||
| } | ||
|
|
||
| pub fn create_entity_registry( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to set_allowed_entity? To make it more clear on what it does
| expect(entityRegistry.entityPubkey.toString()).to.be.eq(solver.toString()) | ||
| }) | ||
|
|
||
| it('should change admin for next tests', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
Adds Whitelist program, analogous to the
Controller.sol.Naming could change to align with EVM contracts.
Rust program and Typescript SDK were added, along with Typescript tests.
Instructions
This program manages entity permission, being able to whitelist and blacklist Validators, Solvers, and Axia addresses.
It is governed by an admin that can be changed with a cooldown period.
initializeInitializes program global state, configuring the admin and cooldown period.
propose_adminProposes a new admin.
set_proposed_adminProposed admin can become admin, if cooldown period has elapsed.
set_entity_whitelist_statusAdmin whitelists or blacklists an entity.
State
GlobalSettingsHolds global state of the program.
EntityRegistryServes as on-chain proof that a given address is whitelisted or blacklisted as a given entity type.
This proof is used on the Settler program (or any other program) to model permissions.
NOTE: Some files might have content from future PRs given this series of PRs come from a larger PR that was split (#41). I have tried to keep this to a minimum but bear this in mind.