From e06a253c04568e92ce8663201698662a9daa6656 Mon Sep 17 00:00:00 2001 From: Guilherme Felipe da Silva Date: Thu, 12 Dec 2024 16:49:09 +0100 Subject: [PATCH] feat(task-processor): add ITS message handling ITS messages, just like governance ones are somewhat special and need separate logic to handle them. Signed-off-by: Guilherme Felipe da Silva --- Cargo.lock | 58 ++++++++++++++----- Cargo.toml | 15 ++--- .../solana-gateway-task-processor/Cargo.toml | 1 + .../src/component.rs | 12 +++- 4 files changed, 63 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d44d905..4d2a0b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -586,6 +586,17 @@ dependencies = [ "event-listener", ] +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2 1.0.92", + "quote 1.0.37", + "syn 2.0.90", +] + [[package]] name = "async-stream" version = "0.3.6" @@ -656,7 +667,7 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axelar-executable" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "alloy-sol-types", "axelar-solana-encoding", @@ -672,7 +683,7 @@ dependencies = [ [[package]] name = "axelar-executable-old" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "axelar-message-primitives", "axelar-rkyv-encoding", @@ -684,7 +695,7 @@ dependencies = [ [[package]] name = "axelar-message-primitives" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -700,7 +711,7 @@ dependencies = [ [[package]] name = "axelar-rkyv-encoding" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "arrayref", "bitflags 2.6.0", @@ -720,7 +731,7 @@ dependencies = [ [[package]] name = "axelar-solana-encoding" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "arrayref", "borsh 1.5.3", @@ -737,7 +748,7 @@ dependencies = [ [[package]] name = "axelar-solana-gateway" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "axelar-message-primitives", "axelar-solana-encoding", @@ -759,7 +770,7 @@ dependencies = [ [[package]] name = "axelar-solana-governance" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "alloy-sol-types", "axelar-executable-old", @@ -775,7 +786,7 @@ dependencies = [ [[package]] name = "axelar-solana-its" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -2308,7 +2319,7 @@ dependencies = [ [[package]] name = "gateway-event-stack" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "axelar-solana-gateway", "base64 0.21.7", @@ -2392,7 +2403,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "gmp-gateway" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "arrayref", "axelar-message-primitives", @@ -2427,7 +2438,7 @@ dependencies = [ [[package]] name = "governance-gmp" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -3044,7 +3055,7 @@ dependencies = [ [[package]] name = "interchain-token-transfer-gmp" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -3096,6 +3107,24 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +[[package]] +name = "its-instruction-builder" +version = "0.1.0" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" +dependencies = [ + "async-recursion", + "axelar-executable", + "axelar-solana-encoding", + "axelar-solana-gateway", + "axelar-solana-its", + "bincode", + "borsh 1.5.3", + "interchain-token-transfer-gmp", + "solana-client", + "solana-sdk", + "spl-token-2022 5.0.2", +] + [[package]] name = "jobserver" version = "0.1.32" @@ -4092,7 +4121,7 @@ dependencies = [ [[package]] name = "program-utils" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "borsh 1.5.3", "rkyv", @@ -4788,7 +4817,7 @@ dependencies = [ [[package]] name = "role-management" version = "0.1.0" -source = "git+https://github.com/eigerco/solana-axelar.git?rev=e212e33#e212e33de8a877e46bd5d0d74bed7597dbf3e76d" +source = "git+ssh://git@github.com/eigerco/solana-axelar-internal.git?branch=fix%2Fits-ix-builder#344b78e24101863a1094919805fd025626f1eabe" dependencies = [ "bincode", "bitflags 2.6.0", @@ -5646,6 +5675,7 @@ dependencies = [ "effective-tx-sender", "eyre", "futures", + "its-instruction-builder", "mockall", "num-traits", "relayer-amplifier-api-integration", diff --git a/Cargo.toml b/Cargo.toml index 4feeb64..c169b11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,13 +80,14 @@ relayer-amplifier-state = { git = "https://github.com/eigerco/axelar-relayer-cor core-common-serde-utils = { git = "https://github.com/eigerco/axelar-relayer-core.git", package = "common-serde-utils", branch = "main" } # Solana Gateway -axelar-solana-gateway = { git = "https://github.com/eigerco/solana-axelar.git", rev = "e212e33", features = ["no-entrypoint"] } -axelar-solana-its = { git = "https://github.com/eigerco/solana-axelar.git", rev = "e212e33", features = ["no-entrypoint"] } -axelar-solana-governance = { git = "https://github.com/eigerco/solana-axelar.git", rev = "e212e33", features = ["no-entrypoint"] } -gateway-event-stack = { git = "https://github.com/eigerco/solana-axelar.git", rev = "e212e33" } -axelar-solana-encoding = { git = "https://github.com/eigerco/solana-axelar.git", rev = "e212e33" } -axelar-message-primitives = { git = "https://github.com/eigerco/solana-axelar.git", rev = "e212e33" } -axelar-executable = { git = "https://github.com/eigerco/solana-axelar.git", rev = "e212e33" } +axelar-solana-gateway = { git = "ssh://git@github.com/eigerco/solana-axelar-internal.git", branch = "fix/its-ix-builder", features = ["no-entrypoint"] } +axelar-solana-its = { git = "ssh://git@github.com/eigerco/solana-axelar-internal.git", branch = "fix/its-ix-builder", features = ["no-entrypoint"] } +axelar-solana-governance = { git = "ssh://git@github.com/eigerco/solana-axelar-internal.git", branch = "fix/its-ix-builder", features = ["no-entrypoint"] } +gateway-event-stack = { git = "ssh://git@github.com/eigerco/solana-axelar-internal.git", branch = "fix/its-ix-builder"} +axelar-solana-encoding = { git = "ssh://git@github.com/eigerco/solana-axelar-internal.git", branch = "fix/its-ix-builder"} +axelar-message-primitives = { git = "ssh://git@github.com/eigerco/solana-axelar-internal.git", branch = "fix/its-ix-builder"} +axelar-executable = { git = "ssh://git@github.com/eigerco/solana-axelar-internal.git", branch = "fix/its-ix-builder"} +its-instruction-builder = { git = "ssh://git@github.com/eigerco/solana-axelar-internal.git", branch = "fix/its-ix-builder"} # CLI clap = { version = "4", features = ["derive"] } diff --git a/crates/solana-gateway-task-processor/Cargo.toml b/crates/solana-gateway-task-processor/Cargo.toml index 3c4445c..31f818c 100644 --- a/crates/solana-gateway-task-processor/Cargo.toml +++ b/crates/solana-gateway-task-processor/Cargo.toml @@ -28,6 +28,7 @@ effective-tx-sender.workspace = true axelar-executable.workspace = true num-traits.workspace = true relayer-amplifier-state.workspace = true +its-instruction-builder.workspace = true [dev-dependencies] serde_json.workspace = true diff --git a/crates/solana-gateway-task-processor/src/component.rs b/crates/solana-gateway-task-processor/src/component.rs index 64bb63b..52751f7 100644 --- a/crates/solana-gateway-task-processor/src/component.rs +++ b/crates/solana-gateway-task-processor/src/component.rs @@ -202,8 +202,16 @@ async fn execute_task( let destination_address = message.destination_address.parse::()?; match destination_address { axelar_solana_its::ID => { - // todo ITS specific handling - tracing::error!("ITS program not yet supported"); + let ix = its_instruction_builder::build_its_gmp_instruction( + signer, + gateway_incoming_message_pda, + message, + payload, + solana_rpc_client, + ) + .await?; + + send_tx(solana_rpc_client, keypair, ix).await?; } axelar_solana_governance::ID => { // todo Governance specific handling