-
Couldn't load subscription status.
- Fork 29
feat(cosmwasm): TS coordinator v2 deployment script #901
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
970d8c6 to
e412cf4
Compare
3e04ed5 to
44ac5e9
Compare
6c68578 to
aca176d
Compare
6e19277 to
782384f
Compare
010fcc5 to
e01748c
Compare
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 Summary
This PR introduces a comprehensive TypeScript-based Coordinator deployment script system for managing Axelar Amplifier contracts on Cosmos chains. The Coordinator feature adds a higher-level abstraction over the existing JavaScript deployment utilities, providing a unified CLI interface for deploying and managing interconnected contracts (Gateway, VotingVerifier, MultisigProver).
The implementation follows a modular architecture with dedicated manager classes:
- ConfigManager handles configuration loading/saving and contract state management
- DeploymentManager orchestrates contract deployments through both governance proposals and direct deployment
- InstantiationManager manages contract instantiation with proper parameter validation and event parsing
- GovernanceManager handles governance proposal submission and management
- CodeIdUtils abstracts code ID fetching from blockchain proposals using code hashes
- RetryManager provides resilience against transient failures
- OptionProcessor validates and processes CLI options
The system supports both development (direct deployment) and production (governance proposal-based) workflows, with comprehensive error handling, retry mechanisms, and user confirmation prompts. A new CLI tool (coordinator.ts) provides five main commands: deploy, register-protocol, register-deployment, instantiate, and update-instantiate-config. The architecture replaces manual multi-step deployment processes with an automated coordinator that ensures proper initialization order and parameter consistency across interdependent contracts.
Important Files Changed
Click to expand file changes
| Filename | Score | Overview |
|---|---|---|
| cosmwasm/coordinator/governance.ts | 2/5 | Introduces GovernanceManager class with prompt logic issues and incomplete TODO implementation |
| cosmwasm/coordinator/instantiation.ts | 2/5 | Implements InstantiationManager with inverted prompt logic and unsafe type casting |
| cosmwasm/coordinator/deployment.ts | 2/5 | Adds DeploymentManager class with inverted prompt confirmation logic and type safety issues |
| cosmwasm/coordinator/types.ts | 4/5 | Comprehensive type definitions for coordinator system with proper interface design |
| cosmwasm/coordinator/config.ts | 4/5 | ConfigManager class for deployment configuration management with minor type annotation issues |
| cosmwasm/coordinator/option-processor.ts | 4/5 | OptionProcessor class for CLI option validation with solid implementation |
| cosmwasm/coordinator/code-id-utils.ts | 4/5 | CodeIdUtils class for managing code ID fetching with proper error handling |
| cosmwasm/coordinator/retry.ts | 4/5 | RetryManager class providing resilient async operation handling |
| cosmwasm/coordinator/constants.ts | 4/5 | Well-structured constants for coordinator deployment system |
| cosmwasm/COORDINATOR.md | 4/5 | Comprehensive documentation with minor typo in troubleshooting section |
| cosmwasm/coordinator.ts | 4/5 | Main CLI script with proper error handling and modular architecture |
| cosmwasm/coordinator/index.ts | 5/5 | Standard barrel export file with no issues |
Confidence score: 2/5
- This PR introduces significant logic issues that could prevent proper deployment operations and cause runtime errors
- Score lowered due to critical prompt confirmation logic being inverted in multiple manager classes and unsafe type casting patterns
- Pay close attention to governance.ts, instantiation.ts, and deployment.ts files which contain the most problematic logic issues
Sequence Diagram
sequenceDiagram
participant User
participant CLI as "coordinator.ts (CLI)"
participant OM as "OptionProcessor"
participant CM as "ConfigManager"
participant DM as "DeploymentManager"
participant GM as "GovernanceManager"
participant IM as "InstantiationManager"
participant CIU as "CodeIdUtils"
participant RM as "RetryManager"
participant Wallet as "Wallet/Client"
participant Blockchain as "Cosmos Chain"
User->>CLI: "npx ts-node coordinator.ts deploy"
CLI->>OM: "processOptions(options)"
OM->>OM: "validate thresholds, addresses"
OM-->>CLI: "processed options"
CLI->>CM: "new ConfigManager(env)"
CM->>CM: "loadConfig() from JSON"
CM-->>CLI: "config manager"
CLI->>DM: "new DeploymentManager(configManager)"
CLI->>DM: "deployContracts(options)"
loop "for each contract (Gateway, VotingVerifier, MultisigProver)"
DM->>CM: "processOptions(options)"
DM->>Wallet: "prepareWallet() & prepareClient()"
Wallet-->>DM: "wallet & client"
DM->>DM: "getContractCodePath()"
DM->>User: "prompt for confirmation"
User-->>DM: "proceed confirmation"
DM->>RM: "withRetry(() => submitProposal())"
RM->>Blockchain: "submit governance proposal"
Blockchain-->>RM: "proposal ID"
RM-->>DM: "proposal ID"
DM->>CM: "storeDeploymentInfo()"
DM->>CM: "saveConfig()"
end
User->>CLI: "npx ts-node coordinator.ts update-instantiate-config"
CLI->>GM: "updateInstantiateConfig(options)"
GM->>CIU: "fetchAndUpdateCodeIdsFromProposals()"
CIU->>Blockchain: "fetch code IDs from chain"
Blockchain-->>CIU: "code IDs"
CIU->>CM: "updateContractCodeId()"
loop "for each contract"
GM->>GM: "encodeUpdateInstantiateConfigProposal()"
GM->>User: "prompt for confirmation"
User-->>GM: "proceed confirmation"
GM->>RM: "withRetry(() => submitProposal())"
RM->>Blockchain: "submit governance proposal"
Blockchain-->>RM: "proposal ID"
end
User->>CLI: "npx ts-node coordinator.ts instantiate -n chain-name"
CLI->>IM: "instantiateChainContracts(chainName, options)"
IM->>CIU: "fetchAndUpdateCodeIdsFromProposals()"
IM->>Wallet: "prepareWalletAndClient()"
alt "direct execution (--direct flag)"
IM->>IM: "constructExecuteMessage()"
IM->>User: "prompt for confirmation"
User-->>IM: "proceed confirmation"
IM->>RM: "withRetry(() => client.execute())"
RM->>Blockchain: "execute contract message"
Blockchain-->>RM: "transaction result with events"
RM-->>IM: "transaction result"
IM->>IM: "extractContractInfoFromEvents()"
else "governance proposal"
IM->>IM: "constructExecuteMessage()"
IM->>IM: "encodeExecuteContractProposal()"
IM->>User: "prompt for confirmation"
User-->>IM: "proceed confirmation"
IM->>RM: "withRetry(() => submitProposal())"
RM->>Blockchain: "submit governance proposal"
Blockchain-->>RM: "proposal ID"
end
IM->>CM: "storeChainSpecificParams()"
IM->>CM: "saveConfig()"
User->>CLI: "npx ts-node coordinator.ts register-deployment -n chain-name"
CLI->>GM: "registerDeployment(options, chainName)"
GM->>CM: "getDeploymentNameFromConfig()"
GM->>GM: "construct register_deployment message"
GM->>User: "prompt for confirmation"
User-->>GM: "proceed confirmation"
GM->>RM: "withRetry(() => submitProposal())"
RM->>Blockchain: "submit governance proposal"
Blockchain-->>RM: "proposal ID"
GM->>CM: "saveConfig()"
12 files reviewed, 14 comments
| ## Security Considerations | ||
|
|
||
| 1. **Mnemonic Security**: Never hardcode mnemonics in scripts. Use environment variables or secure input methods. | ||
| 2. **Environment Variables**: Set the `MNEMONIC` environment variable for automated deployments. | ||
| 3. **Governance Proposals**: All deployments require governance approval, ensuring proper oversight. | ||
| 4. **Confirmation Prompts**: Use `-y` flag to skip confirmation prompts in automated environments. |
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.
to much LLM output. this is not needed
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.
What's wrong with this section?
| manual: { | ||
| gateway: { | ||
| code_id: gatewayCodeId, | ||
| label: `Gateway-${chainName}`, |
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.
how is the label field used in the contracts? Is it just tracking. Since its already inside the "gateway" object the extra declaraction of Gateway in the label is not needed, but not sure how it ends up being stored in the 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.
It's a human-readable label for the instantiated contract. It's not accessible in the current version of CosmJS, which is why the JS scripts don't set it up. Not sure how it's used in the Axelar network though
…at/coordinator_script
No description provided.