Skip to content
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

Add first POC for starknet msg_verifier #3

Closed
wants to merge 11 commits into from
2,222 changes: 1,192 additions & 1,030 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion ampd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ serde_json = "1.0.89"
serde_with = "3.2.0"
service-registry = { workspace = true }
sha3 = { workspace = true }
starknet-core = "0.10.0"
starknet-providers = "0.10.0"
# starknet-verifier = { path = "../../starknet/giza-axelar-starknet/crates/starknet-verifier" } ## todo, properly import this via repo url.
sui-json-rpc-types = { git = "https://github.com/mystenlabs/sui", tag = "mainnet-v1.14.2" }
sui-types = { git = "https://github.com/mystenlabs/sui", features = ["test-utils"], tag = "mainnet-v1.14.2" }
sui-types = { git = "https://github.com/mystenlabs/sui", features = [
"test-utils",
], tag = "mainnet-v1.14.2" }
# Need to switch to our own fork of tendermint and tendermint-rpc due to event attribute value being nullable.
# Can switch back once https://github.com/informalsystems/tendermint-rs/issues/1216 is resolved.
# The fix for the issue is at https://github.com/axelarnetwork/tendermint-rs/commit/e97033e20e660a7e707ea86db174ec047bbba50d.
Expand Down
22 changes: 22 additions & 0 deletions ampd/src/handlers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ pub enum Config {
rpc_url: Url,
rpc_timeout: Option<Duration>,
},
StarknetMsgVerifier {
cosmwasm_contract: TMAddress,
rpc_url: Url,
rpc_timeout: Option<Duration>,
},
}

fn validate_multisig_signer_config<'de, D>(configs: &[Config]) -> Result<(), D::Error>
Expand Down Expand Up @@ -139,6 +144,22 @@ where
}
}

fn validate_starknet_msg_verifier_config<'de, D>(configs: &[Config]) -> Result<(), D::Error>
where
D: Deserializer<'de>,
{
match configs
.iter()
.filter(|config| matches!(config, Config::StarknetMsgVerifier { .. }))
.count()
{
count if count > 1 => Err(de::Error::custom(
"only one Starknet msg verifier config is allowed",
)),
_ => Ok(()),
}
}

pub fn deserialize_handler_configs<'de, D>(deserializer: D) -> Result<Vec<Config>, D::Error>
where
D: Deserializer<'de>,
Expand All @@ -150,6 +171,7 @@ where
validate_multisig_signer_config::<D>(&configs)?;
validate_sui_msg_verifier_config::<D>(&configs)?;
validate_sui_worker_set_verifier_config::<D>(&configs)?;
validate_starknet_msg_verifier_config::<D>(&configs)?;

Ok(configs)
}
1 change: 1 addition & 0 deletions ampd/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod evm_verify_worker_set;
pub mod multisig;
pub mod sui_verify_msg;
pub mod sui_verify_worker_set;
pub mod starknet_verify_msg;

#[cfg(test)]
mod tests {
Expand Down
Loading