-
Notifications
You must be signed in to change notification settings - Fork 29
feat(cosmwasm): script that gives coordinator instantiation permissions #1087
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: main
Are you sure you want to change the base?
Conversation
…ordinator-migration-check
…ordinator-migration-check
…ordinator-migration-check
…ordinator-migration-check
This reverts commit 85fdda3.
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.
Greptile Overview
Summary
This PR adds a new command coordinator-instantiate-permissions
that creates governance proposals to grant the Coordinator v2 contract permission to instantiate Gateway, Verifier, and Prover contracts.
Key changes:
- New
instantiatePermissions
function incoordinator.ts
that builds and submits anUpdateInstantiateConfigProposal
- New CLI command that validates current permissions and prevents duplicate grants
- Added
encodeUpdateInstantiateConfigProposal
helper inutils.js
to encode the proposal - Updated documentation with step-by-step instructions for granting instantiate permissions
- Minor bug fix in
multisig.ts
error message
Issues found:
- Typo:
premissions
instead ofpermissions
in parameter names (3 occurrences) - Hardcoded magic number
4
instead of usingAccessType.ACCESS_TYPE_ANY_OF_ADDRESSES
constant - Uses
console.log
instead ofprintInfo
in one location
Confidence Score: 4/5
- This PR is safe to merge with minor spelling fixes needed
- The implementation is solid with good validation logic and error handling. The typos in parameter names and style issues don't affect functionality. The core logic correctly validates permissions before creating proposals, preventing duplicate grants. Successfully tested on devnet (proposal ID 1223).
- cosmwasm/migrate/migrate.ts needs spelling corrections for parameter names
Important Files Changed
File Analysis
Filename | Score | Overview |
---|---|---|
cosmwasm/migrate/coordinator.ts | 4/5 | Added instantiatePermissions function to grant coordinator permission to instantiate contracts. Uses hardcoded magic number instead of AccessType constant. |
cosmwasm/migrate/migrate.ts | 3/5 | Added coordinator-instantiate-permissions command with validation logic. Has typo in parameter names (premissions instead of permissions ). |
cosmwasm/utils.js | 4/5 | Added encodeUpdateInstantiateConfigProposal function to support updating instantiate permissions. Uses console.log instead of printInfo . |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as migrate.ts
participant Validator as coordinatorInstantiatePermissions
participant Helper as instantiatePermissions
participant Utils as utils.js
participant Chain as CosmWasm Chain
User->>CLI: coordinator-instantiate-permissions <code_id> <current_permissions>
CLI->>Validator: Parse arguments and options
Validator->>Validator: Validate code_id is a number
Validator->>Validator: Parse current_permissions JSON
Validator->>Validator: Check if permission == 'Everybody'
Validator->>Validator: Check if coordinator already in addresses[]
Validator->>Helper: instantiatePermissions(...)
Helper->>Helper: Add coordinator to permitted addresses
Helper->>Helper: Build updateMsg with permission: 4
Helper->>Utils: encodeUpdateInstantiateConfigProposal(options)
Utils->>Utils: Create UpdateInstantiateConfigProposal
Utils-->>Helper: Return encoded proposal
alt not dry run
Helper->>Utils: submitProposal(proposal)
Utils->>Chain: Submit governance proposal
Chain-->>Utils: Proposal ID
Utils-->>Helper: Success
Helper-->>User: Migration proposal successfully submitted
else dry run
Helper-->>User: Display proposal message only
end
6 files reviewed, 5 comments
1 Job Failed: Rust Linting / rust-lints failed on "Run cargo clippy (devnet-amplifier)"
Summary: 7 successful workflows, 1 failed workflow
Last updated: 2025-10-16 15:30:03 UTC |
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.
We'll need the command that modifies instantiatePermission
- especially when migrating to Coordinator v2. The nice thing is that we can use this script in other contexts, too. I left some comments, Thanks! 🚀
|
||
addAmplifierOptions( | ||
program | ||
.command('coordinator-instantiate-permissions') |
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.
Let's move this command to the submit-proposal.js
as it can be used outside of the migration context, too.
We have provided a script that submits a proposal to append the coordinator's address to the list of allowed addresses for a given code id. A proposal will not be created if the coordinator is already allowed to instantiate that contract. To execute that script, run: | ||
```bash | ||
ts-node cosmwasm/migrate/migrate.ts coordinator-instantiate-permissions <code id> "'$(axelard q wasm code-info <code id> --node <node rpc> --output json | jq -c .instantiate_permission)'" --deposit 100000000 -e devnet-amplifier -t $TITLE -d $DESCRIPTION -m $MNEMONIC |
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.
When the script is moved, pls update that code too
|
||
CLUSTER="devnet"; | ||
COMMIT_HASH="a26968488efd41c979d6aa3d56ce85bc1c1556d4"; # https://github.com/axelarnetwork/axelar-amplifier-solana/commit/a26968488efd41c979d6aa3d56ce85bc1c1556d4 | ||
COMMIT_HASH="a26968488efd41c979d6aa3d56ce85bc1c1556d4"; # https://github.com/axelarnetwork/axelar-amplifier-solana/commit/a26968488efd41c979d6aa3d56ce85bc1c1556d4 # skip-check |
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.
Remove solana related updates from this PR
program | ||
.command('coordinator-instantiate-permissions') | ||
.argument('<code_id>', 'coordinator will have instantiate permissions for this code id') | ||
.argument('<current_permissions>', 'current instantiate permissions for given contract') |
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.
Get the current permisions within the script via query
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 agree that it is better to query this from within the script. I was looking extensively however, and I don't think the stargate api allows this. I will look again tomorrow to see if there is a way around this
Description
The wasm module needs to give the coordinator v2 permission to instantiate gateways, verifiers and provers. This script submits a proposal to add the coordinator address to the allowed list of instantiators for a particular code id.
Usage
Please refer to step 5 in the
Deployment
section of2025-09-Coordinator-v2.1.1.md
Testing
This script has been successfully tested on devnet-amplifier. (proposal ID 1223)
Note
Adds a new CLI command and proposal encoder to append the Coordinator to allowed instantiators for a given code ID.
encodeUpdateInstantiateConfigProposal
incosmwasm/utils.js
(withUpdateInstantiateConfigProposal
) to update instantiate permissions.instantiatePermissions
incosmwasm/migrate/coordinator.ts
to build and submit the update-instantiate-config proposal.coordinator-instantiate-permissions
command incosmwasm/migrate/migrate.ts
to grant the Coordinator instantiate rights for a givencode_id
using current permissions JSON; bump tool version to1.1.0
.MigrationOptions
with optionaltitle
/description
; addInstantiatePermission
interface.releases/cosmwasm/2025-09-Coordinator-v2.1.1.md
with an optional step and command to give the Coordinator instantiate permissions and minor wording fixes.cosmwasm/migrate/multisig.ts
; minor comment tweak insolana/template.env
.Written by Cursor Bugbot for commit 09cd735. This will update automatically on new commits. Configure here.