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(ampd): add Stacks handlers with custom ITS logic & verify logic for contract deployments #676

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b619d3f
Start working on stacks verify message handler.
raress96 Oct 7, 2024
1c08d96
Start work on decoding Stacks events.
raress96 Oct 8, 2024
87eb02f
Working tests for stacks verifier.
raress96 Oct 9, 2024
3a4d705
Tests for stacks verify message handler.
raress96 Oct 10, 2024
72a41e5
Remove default features from clarity package.
raress96 Oct 11, 2024
dc86122
Merge branch 'main' into stacks_ampd
raress96 Oct 16, 2024
b2dda21
Formatting for stacks verify msg handler.
raress96 Oct 16, 2024
2182806
Implement verify verifier set handler for stacks.
raress96 Oct 16, 2024
757cd46
Add tests for stacks verify verifier set.
raress96 Oct 17, 2024
6263755
Start working on stacks its verifier.
raress96 Oct 18, 2024
78e18a0
Add basic decode for its hub data.
raress96 Oct 18, 2024
03e3ed3
Implement conversion of its hub interchain transfer payload for stacks.
raress96 Oct 21, 2024
3faa95e
Add abi encoding for all message types.
raress96 Oct 21, 2024
b0b361c
Start working on verifying its contract deployments.
raress96 Oct 21, 2024
32f339d
Implement its verify contract for stacks.
raress96 Oct 22, 2024
07eaadc
Implement all its logic for stacks ampd module.
raress96 Oct 22, 2024
74f95d5
Fix wrong tx hash for stacks.
raress96 Oct 28, 2024
4fe3c69
Updates to stacks type sizes.
raress96 Oct 28, 2024
ff58961
Update token limits.
raress96 Oct 28, 2024
18d8a71
Merge pull request #3 from Trust-Machines/stacks_ampd_its
raress96 Oct 29, 2024
371da05
Merge branch 'main' into stacks_ampd
raress96 Oct 29, 2024
1ef87f0
Merge branch 'main' into stacks_ampd
raress96 Nov 4, 2024
66f2d90
Merge branch 'main' into stacks_ampd
raress96 Nov 8, 2024
ba5d24b
Update stacks integration to use the new message_id from events.
raress96 Nov 8, 2024
b6964cd
Merge branch 'main' into stacks_ampd
raress96 Nov 20, 2024
8755655
Remove deploy token manager support for its hub for stacks.
raress96 Nov 20, 2024
e79e93a
Merge branch 'main' into stacks_ampd
raress96 Nov 25, 2024
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
607 changes: 561 additions & 46 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ampd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ axum = "0.7.5"
base64 = "0.21.2"
bcs = { workspace = true }
clap = { version = "4.2.7", features = ["derive", "cargo"] }
clarity = { git = "https://github.com/stacks-network/stacks-core", tag = "2.5.0.0.7", default-features = false, features = ["slog_json"] }
config = "0.13.2"
cosmrs = { version = "0.14.0", features = ["cosmwasm", "grpc"] }
cosmwasm-std = { workspace = true, features = ["stargate"] }
Expand Down
33 changes: 32 additions & 1 deletion ampd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ mod tests {
type = 'StellarVerifierSetVerifier'
cosmwasm_contract = '{}'
http_url = 'http://localhost:8000'

[[handlers]]
type = 'StacksMsgVerifier'
cosmwasm_contract = '{}'
http_url = 'http://localhost:8000'
its_address = 'its_address'
reference_native_interchain_token_address = 'interchain_token_address'
reference_token_manager_address = 'token_manager_address'

[[handlers]]
type = 'StacksVerifierSetVerifier'
cosmwasm_contract = '{}'
http_url = 'http://localhost:8000'
",
TMAddress::random(PREFIX),
TMAddress::random(PREFIX),
Expand All @@ -143,10 +156,12 @@ mod tests {
TMAddress::random(PREFIX),
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(), 10);
assert_eq!(cfg.handlers.len(), 12);
}

#[test]
Expand Down Expand Up @@ -350,6 +365,22 @@ mod tests {
),
http_url: Url::from_str("http://127.0.0.1").unwrap(),
},
HandlerConfig::StacksMsgVerifier {
cosmwasm_contract: TMAddress::from(
AccountId::new("axelar", &[0u8; 32]).unwrap(),
),
http_url: Url::from_str("http://127.0.0.1").unwrap(),
its_address: "its_address".to_string(),
reference_native_interchain_token_address: "interchain_token_address"
.to_string(),
reference_token_manager_address: "token_manager_address".to_string(),
},
HandlerConfig::StacksVerifierSetVerifier {
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
61 changes: 61 additions & 0 deletions ampd/src/handlers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ pub enum Config {
cosmwasm_contract: TMAddress,
http_url: Url,
},
StacksMsgVerifier {
cosmwasm_contract: TMAddress,
http_url: Url,
its_address: String,
reference_native_interchain_token_address: String,
reference_token_manager_address: String,
},
StacksVerifierSetVerifier {
cosmwasm_contract: TMAddress,
http_url: Url,
},
}

fn validate_evm_verifier_set_verifier_configs<'de, D>(configs: &[Config]) -> Result<(), D::Error>
Expand Down Expand Up @@ -159,6 +170,16 @@ where
Config::StellarVerifierSetVerifier,
"Stellar verifier set verifier"
)?;
ensure_unique_config!(
&configs,
Config::StacksMsgVerifier,
"Stacks message verifier"
)?;
ensure_unique_config!(
&configs,
Config::StacksVerifierSetVerifier,
"Stacks verifier set verifier"
)?;

Ok(configs)
}
Expand Down Expand Up @@ -305,5 +326,45 @@ mod tests {
Err(e) if e.to_string().contains("only one Stellar verifier set verifier config is allowed")
)
);

let configs = vec![
Config::StacksMsgVerifier {
cosmwasm_contract: TMAddress::random(PREFIX),
http_url: "http://localhost:8080/".parse().unwrap(),
its_address: "its_address".to_string(),
reference_native_interchain_token_address: "interchain_token_address".to_string(),
reference_token_manager_address: "token_manager_address".to_string(),
},
Config::StacksMsgVerifier {
cosmwasm_contract: TMAddress::random(PREFIX),
http_url: "http://localhost:8080/".parse().unwrap(),
its_address: "its_address".to_string(),
reference_native_interchain_token_address: "interchain_token_address".to_string(),
reference_token_manager_address: "token_manager_address".to_string(),
},
];

assert!(
matches!(deserialize_handler_configs(to_value(configs).unwrap()),
Err(e) if e.to_string().contains("only one Stacks message verifier config is allowed")
)
);

let configs = vec![
Config::StacksVerifierSetVerifier {
cosmwasm_contract: TMAddress::random(PREFIX),
http_url: "http://localhost:8080/".parse().unwrap(),
},
Config::StacksVerifierSetVerifier {
cosmwasm_contract: TMAddress::random(PREFIX),
http_url: "http://localhost:8080/".parse().unwrap(),
},
];

assert!(
matches!(deserialize_handler_configs(to_value(configs).unwrap()),
Err(e) if e.to_string().contains("only one Stacks verifier set verifier config is allowed")
)
);
}
}
2 changes: 2 additions & 0 deletions ampd/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ pub mod evm_verify_verifier_set;
pub mod multisig;
pub mod mvx_verify_msg;
pub mod mvx_verify_verifier_set;
pub mod stacks_verify_msg;
pub mod stacks_verify_verifier_set;
pub(crate) mod stellar_verify_msg;
pub(crate) mod stellar_verify_verifier_set;
pub mod sui_verify_msg;
Expand Down
Loading