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

feat(minor-ampd): stellar verifier set verifier #617

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ampd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ serde_json = { workspace = true }
serde_with = "3.2.0"
service-registry = { workspace = true }
sha3 = { workspace = true }
stellar = { workspace = true }
stellar-rs = "0.3.2"
stellar-xdr = { workspace = true, features = ["serde_json"] }
sui-gateway = { workspace = true }
Expand Down
14 changes: 13 additions & 1 deletion ampd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ mod tests {
type = 'StellarMsgVerifier'
cosmwasm_contract = '{}'
http_url = 'http://localhost:8000'
[[handlers]]
type = 'StellarVerifierSetVerifier'
cosmwasm_contract = '{}'
http_url = 'http://localhost:8000'
",
TMAddress::random(PREFIX),
TMAddress::random(PREFIX),
Expand All @@ -135,10 +140,11 @@ mod tests {
TMAddress::random(PREFIX),
TMAddress::random(PREFIX),
TMAddress::random(PREFIX),
TMAddress::random(PREFIX),
);

let cfg: Config = toml::from_str(config_str.as_str()).unwrap();
assert_eq!(cfg.handlers.len(), 9);
assert_eq!(cfg.handlers.len(), 10);
}

#[test]
Expand Down Expand Up @@ -336,6 +342,12 @@ mod tests {
),
http_url: Url::from_str("http://127.0.0.1").unwrap(),
},
HandlerConfig::StellarVerifierSetVerifier {
cosmwasm_contract: TMAddress::from(
AccountId::new("axelar", &[0u8; 32]).unwrap(),
),
http_url: Url::from_str("http://127.0.0.1").unwrap(),
},
],
..Config::default()
}
Expand Down
21 changes: 21 additions & 0 deletions ampd/src/handlers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
cosmwasm_contract: TMAddress,
http_url: Url,
},
StellarVerifierSetVerifier {
cosmwasm_contract: TMAddress,
http_url: Url,
},
}

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

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

Check warning on line 220 in ampd/src/handlers/config.rs

View check run for this annotation

Codecov / codecov/patch

ampd/src/handlers/config.rs#L219-L220

Added lines #L219 - L220 were not covered by tests
_ => Ok(()),
}
}
haiyizxx marked this conversation as resolved.
Show resolved Hide resolved

pub fn deserialize_handler_configs<'de, D>(deserializer: D) -> Result<Vec<Config>, D::Error>
where
D: Deserializer<'de>,
Expand All @@ -216,6 +236,7 @@
validate_mvx_msg_verifier_config::<D>(&configs)?;
validate_mvx_worker_set_verifier_config::<D>(&configs)?;
validate_stellar_msg_verifier_config::<D>(&configs)?;
validate_stellar_verifier_set_verifier_config::<D>(&configs)?;

Ok(configs)
}
Expand Down
1 change: 1 addition & 0 deletions ampd/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod multisig;
pub mod mvx_verify_msg;
pub mod mvx_verify_verifier_set;
pub(crate) mod stellar_verify_msg;
pub(crate) mod stellar_verify_verifier_set;
pub mod sui_verify_msg;
pub mod sui_verify_verifier_set;

Expand Down
Loading
Loading