-
Notifications
You must be signed in to change notification settings - Fork 390
Open
Description
Error parsing ExecuteMsg in deployed contract: "Invalid type" error
🐛 Problem Description
I'm encountering a persistent message parsing error. When I try to call ExecuteMsg
on a deployed contract, I consistently receive this error:
Error: rpc error: code = Unknown desc = rpc error: code = Unknown desc = failed to execute message; message index: 0: Error parsing into type cw_saas::msg::ExecuteMsg: Invalid type: execute wasm contract failed [!cosm!wasm/[email protected]/x/wasm/keeper/keeper.go:395] With gas wanted: '600000000' and gas used: '99058' : unknown request
🔧 Environment
- CosmWasm Version: wasmd v0.43.0
- Chain: Dora testnet (vota-testnet)
- Rust Version: 1.75+
- cosmwasm-std Version: 1.5.0
📝 Contract Details
I have a SaaS contract that depends on an oracle-maci contract. The contract tests pass locally, but fail when executed after deployment on-chain.
Dependencies in Cargo.toml:
[dependencies]
cosmwasm-schema = "1.5.0"
cosmwasm-std = { version = "1.5.0", features = ["staking"] }
cw-storage-plus = "1.1.0"
cw2 = "1.1.0"
cw-utils = "1.0.1"
thiserror = { version = "1.0.31" }
schemars = "0.8.10"
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
serde_json = "1.0"
bech32 = "0.9.1"
cw-oracle-maci = { path = "../oracle-maci", features = ["library"] }
ExecuteMsg Definition:
#[cw_serde]
pub enum ExecuteMsg {
// ... other variants
CreateOracleMaciRound {
oracle_maci_code_id: u64,
coordinator: PubKey,
max_voters: u128,
vote_option_map: Vec<String>,
round_info: RoundInfo,
start_time: cosmwasm_std::Timestamp,
end_time: cosmwasm_std::Timestamp,
circuit_type: Uint256,
certification_system: Uint256,
whitelist_backend_pubkey: String,
},
// ... other variants
}
#[cw_serde]
pub struct PubKey {
pub x: Uint256,
pub y: Uint256,
}
🔄 Steps to Reproduce
- Deploy the contract to chain
- Execute the following transaction:
dorad tx wasm execute dora1e04gtrahu9tqhe7yy45vx8w30ufcn6j0aljxsp74933ntezpuqcqphd2mh \
'{ "create_oracle_maci_round": {
"oracle_maci_code_id": 140,
"coordinator": {
"x": "5424741844275630152950028819860276183538330999940395309613975245790840672621",
"y": "6821363586466624930174394695023126212730779300840339744873622125361194404156"
},
"max_voters": 2,
"vote_option_map": ["Option 1", "Option 2", "Option 3"],
"round_info": {
"title": "Oracle MACI Test Round",
"description": "Test round for Oracle MACI",
"link": "https://example.com"
},
"start_time": "1753920000000000000",
"end_time": "1754006400000000000",
"circuit_type": "0",
"certification_system": "0",
"whitelist_backend_pubkey": "AoYo/zENN/JquagPdG0/NMbWBBYxOM8BVN677mBXJKJQ"
} }' \
--from saas-operator-1 --chain-id "vota-testnet" --gas-prices 100000000000peaka --gas auto --gas-adjustment 1.5 --node https://vota-testnet-rpc.dorafactory.org:443 -y
✅ Expected Behavior
The transaction should succeed and create an Oracle MACI round.
❌ Actual Behavior
Error parsing into type cw_saas::msg::ExecuteMsg: Invalid type
🔍 What I've Tried
- Verified JSON Schema: Generated schema shows the message format is correct
- Local Testing: All unit tests pass, including the exact same message structure
- Version Alignment: Upgraded all dependencies to use cosmwasm-std 1.5.0
- Message Validation: Added pre-serialization validation in contract code
- Multiple Deployments: Recompiled and redeployed the contract multiple times
- Schema Regeneration: Generated fresh schema files after dependency updates
Generated Schema Excerpt:
{
"type": "object",
"required": ["create_oracle_maci_round"],
"properties": {
"create_oracle_maci_round": {
"type": "object",
"required": [
"certification_system", "circuit_type", "coordinator",
"end_time", "max_voters", "oracle_maci_code_id",
"round_info", "start_time", "vote_option_map",
"whitelist_backend_pubkey"
],
"properties": {
"certification_system": { "$ref": "#/definitions/Uint256" },
"circuit_type": { "$ref": "#/definitions/Uint256" },
// ... other fields
}
}
}
}
Working Test Case:
#[test]
fn test_create_oracle_maci_round_success() {
// This exact same message structure works in tests
let create_msg = ExecuteMsg::CreateOracleMaciRound {
oracle_maci_code_id,
coordinator: PubKey {
x: Uint256::from(1u32),
y: Uint256::from(2u32),
},
max_voters: 5,
vote_option_map: vec!["Option 1".to_string()],
round_info: cw_amaci::state::RoundInfo {
title: "Test Round".to_string(),
description: "Test Description".to_string(),
link: "https://test.com".to_string(),
},
start_time: cosmwasm_std::Timestamp::from_seconds(1640995200),
end_time: cosmwasm_std::Timestamp::from_seconds(1641081600),
circuit_type: Uint256::zero(),
certification_system: Uint256::zero(),
whitelist_backend_pubkey: "dGVzdA==".to_string(),
};
let result = app.execute_contract(operator1(), contract.addr(), &create_msg, &[]);
assert!(result.is_ok()); // ✅ This passes
}
🤔 Possible Causes
- Version Mismatch: The deployed contract might be using a different cosmwasm-std version than expected
- Serialization Issue: There might be a subtle difference in how the message is being serialized/deserialized
- Schema Mismatch: The chain might be using a different schema than what I generated
- Migration Issue: Previous contract versions might be interfering
❓ Questions
- How can I debug what exact message format the deployed contract expects?
- Is there a way to check which cosmwasm-std version a deployed contract was compiled with?
- Could there be differences in JSON parsing between test environment and chain execution?
- Are there any known issues with cosmwasm-std 1.5.0 on wasmd v0.43.0?
- Should I downgrade to an earlier cosmwasm-std version that matches the wasmd version?
- Is there a way to get more detailed error information from the contract execution?
📋 Additional Context
- A similar registry contract works fine on the same chain
- This saas contract is more complex and has dependencies on oracle-maci contract
- The error specifically mentions "Invalid type" which suggests a type parsing issue rather than a missing field
- The error occurs consistently - it's not intermittent
- Gas usage is very low (99058) suggesting the error happens early in execution
- The contract was initially built with cosmwasm-std 1.1.3, recently upgraded to 1.5.0
Any insights would be greatly appreciated! I've been stuck on this for quite some time and local testing doesn't reveal the issue.
🔗 Related Information
- Contract deployment was successful - only execution fails
- Other simpler ExecuteMsg variants work (if applicable)
- Willing to provide additional debugging information upon request
Metadata
Metadata
Assignees
Labels
No labels