Skip to content

Conversation

@kulikthebird
Copy link
Contributor

No description provided.

@kulikthebird kulikthebird self-assigned this Jul 28, 2025
@kulikthebird kulikthebird force-pushed the feat/coordinator_script branch from 970d8c6 to e412cf4 Compare July 29, 2025 13:53
@kulikthebird kulikthebird changed the title feat: Coordinator deployment scripts update feat: Coordinator deployment script Jul 29, 2025
@kulikthebird kulikthebird changed the title feat: Coordinator deployment script feat: deployment script - Coordinator Jul 29, 2025
@kulikthebird kulikthebird force-pushed the feat/coordinator_script branch 4 times, most recently from 3e04ed5 to 44ac5e9 Compare August 4, 2025 12:28
@kulikthebird kulikthebird force-pushed the feat/coordinator_script branch 3 times, most recently from 6c68578 to aca176d Compare August 5, 2025 19:44
@kulikthebird kulikthebird force-pushed the feat/coordinator_script branch 6 times, most recently from 6e19277 to 782384f Compare August 6, 2025 21:57
@kulikthebird kulikthebird changed the title feat: deployment script - Coordinator feat(cosmwasm): deployment script - Coordinator Aug 7, 2025
@kulikthebird kulikthebird changed the title feat(cosmwasm): deployment script - Coordinator feat(axelar): deployment script - Coordinator Aug 7, 2025
@kulikthebird kulikthebird force-pushed the feat/coordinator_script branch 5 times, most recently from 010fcc5 to e01748c Compare August 7, 2025 11:54
@kulikthebird kulikthebird marked this pull request as ready for review August 7, 2025 11:58
@kulikthebird kulikthebird requested a review from a team as a code owner August 7, 2025 11:58
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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()"
Loading

12 files reviewed, 14 comments

Edit Code Review Bot Settings | Greptile

cursor[bot]

This comment was marked as outdated.

Comment on lines +107 to +112
## 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.
Copy link
Collaborator

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

Copy link
Contributor Author

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}`,
Copy link
Collaborator

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

Copy link
Contributor Author

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

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@nbayindirli nbayindirli changed the title feat(axelar): deployment script - Coordinator feat(cosmwasm): coordinator deployment script Aug 22, 2025
@nbayindirli nbayindirli changed the title feat(cosmwasm): coordinator deployment script feat(cosmwasm): TS coordinator deployment script Aug 22, 2025
@nbayindirli nbayindirli changed the title feat(cosmwasm): TS coordinator deployment script feat(cosmwasm): TS coordinator v2 deployment script Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants