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: starknet GMP #731

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
559a9ea
feat(ampd): starknet gmp implementation
ctoyan Dec 14, 2024
25f5ed1
fixes and refactors
ctoyan Dec 16, 2024
05791d1
remove event type check when parsing events
ctoyan Dec 16, 2024
ec362e7
add CheckedFelt type
ctoyan Dec 31, 2024
e525c29
Merge branch 'main' into feat/starknet-gmp
ctoyan Jan 9, 2025
e66a4d4
Merge branch 'main' into feat/starknet-gmp
ctoyan Jan 9, 2025
35712fe
fixes after merge
ctoyan Jan 9, 2025
451f625
README changes for starknet
ctoyan Jan 10, 2025
28d0add
remove crypto bigint
ctoyan Jan 10, 2025
686ec98
add verifier set missing boilerplate
ctoyan Jan 10, 2025
c7515a7
add to config_template.toml
ctoyan Jan 10, 2025
55b49c0
remove dead code allowance; remove futures dependency
ctoyan Jan 10, 2025
2807dd0
add verifier set tests; various fixes and refactors
ctoyan Jan 10, 2025
2fb6ce0
implement multicall, handling multiple msgs in one tx
ctoyan Jan 12, 2025
c43524e
small refactors
ctoyan Jan 12, 2025
33ef7b8
Merge branch 'main' into feat/starknet-gmp
ctoyan Jan 12, 2025
c811313
remove unwrap
ctoyan Jan 17, 2025
8c14dc2
fix the event index iteration
ctoyan Jan 17, 2025
f46f33a
rename starknet-types and move part of the modules to ampd
ctoyan Jan 17, 2025
4068eb5
PartialEq implementetation for SignersRotatedEvent, returns false if …
puhtaytow Jan 21, 2025
a06cec2
remove zero nonce check from verify_verifier_set
puhtaytow Jan 21, 2025
356c990
remove obsolete test for non-zero nonce / functionality at check isn'…
puhtaytow Jan 21, 2025
7ac3558
Merge branch 'main' into feat/starknet-gmp
ctoyan Jan 27, 2025
d56b276
move starknet-messages to eiger's fork
ctoyan Jan 28, 2025
d03f764
use event_index to fetch only needed events
ctoyan Jan 28, 2025
9e44abe
Merge branch 'main' into feat/starknet-gmp
ctoyan Jan 29, 2025
3aee888
remove uneccessary iteration
ctoyan Jan 29, 2025
95622bd
smaller fixes
ctoyan Jan 29, 2025
dcbb6d1
fix: takes into account index when checking for events in verify veri…
puhtaytow Jan 31, 2025
1bd5737
Merge branch 'main' into feat/starknet-gmp
ctoyan Jan 31, 2025
2499f46
Merge branch 'main' into feat/starknet-gmp
ctoyan Feb 3, 2025
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
104 changes: 53 additions & 51 deletions ampd/src/handlers/starknet_verify_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use axelar_wasm_std::voting::{PollId, Vote};
use cosmrs::cosmwasm::MsgExecuteContract;
use cosmrs::tx::Msg;
use cosmrs::Any;
use error_stack::{FutureExt, ResultExt};
use error_stack::ResultExt;
use events::Error::EventTypeMismatch;
use events_derive::try_from;
use futures::future::try_join_all;
use futures::future::join_all;
use itertools::Itertools;
use router_api::ChainName;
use serde::Deserialize;
Expand Down Expand Up @@ -133,12 +133,11 @@ where

// key is the message_id of the tx holding the event
let mut events: HashMap<FieldElementAndEventIndex, ContractCallEvent> =
try_join_all(unique_msgs.iter().map(|msg| {
join_all(unique_msgs.iter().map(|msg| {
self.rpc_client
.get_events_by_hash_contract_call(msg.message_id.tx_hash.clone())
.get_events_by_hash_contract_call(msg.message_id.clone())
}))
.change_context(Error::TxReceipts)
.await?
.await
.into_iter()
.flatten()
.collect();
Expand Down Expand Up @@ -193,42 +192,42 @@ mod tests {
rpc_client
.expect_get_events_by_hash_contract_call()
.returning(|_| {
Ok(vec![
(
FieldElementAndEventIndex::from_str(
"0x035410be6f4bf3f67f7c1bb4a93119d9d410b2f981bfafbf5dbbf5d37ae7439e-0",
)
.unwrap(),
ContractCallEvent {
from_contract_addr: String::from("source-gw-addr"),
destination_address: String::from("destination-address"),
destination_chain: "ethereum".parse().unwrap(),
source_address: Felt::ONE,
payload_hash: H256::from_slice(&[
28u8, 138, 255, 149, 6, 133, 194, 237, 75, 195, 23, 79, 52, 114,
40, 123, 86, 217, 81, 123, 156, 148, 129, 39, 49, 154, 9, 167, 163,
109, 234, 200,
]),
},
),
(
FieldElementAndEventIndex::from_str(
"0x035410be6f4bf3f67f7c1bb4a93119d9d410b2f981bfafbf5dbbf5d37ae7439e-1",
)
.unwrap(),
ContractCallEvent {
from_contract_addr: String::from("source-gw-addr"),
destination_address: String::from("destination-address-1"),
destination_chain: "ethereum-1".parse().unwrap(),
source_address: Felt::TWO,
payload_hash: H256::from_slice(&[
28u8, 138, 255, 149, 6, 133, 194, 237, 75, 195, 23, 79, 52, 114,
40, 123, 86, 217, 81, 123, 156, 148, 129, 39, 49, 154, 9, 167, 163,
109, 234, 200,
]),
},
),
])
Some((
FieldElementAndEventIndex::from_str(
"0x035410be6f4bf3f67f7c1bb4a93119d9d410b2f981bfafbf5dbbf5d37ae7439e-0",
)
.unwrap(),
ContractCallEvent {
from_contract_addr: String::from("source-gw-addr"),
destination_address: String::from("destination-address"),
destination_chain: "ethereum".parse().unwrap(),
source_address: Felt::ONE,
payload_hash: H256::from_slice(&[
28u8, 138, 255, 149, 6, 133, 194, 237, 75, 195, 23, 79, 52, 114, 40,
123, 86, 217, 81, 123, 156, 148, 129, 39, 49, 154, 9, 167, 163, 109,
234, 200,
]),
},
))
})
.returning(|_| {
Some((
FieldElementAndEventIndex::from_str(
"0x035410be6f4bf3f67f7c1bb4a93119d9d410b2f981bfafbf5dbbf5d37ae7439e-1",
)
.unwrap(),
ContractCallEvent {
from_contract_addr: String::from("source-gw-addr"),
destination_address: String::from("destination-address-1"),
destination_chain: "ethereum-1".parse().unwrap(),
source_address: Felt::TWO,
payload_hash: H256::from_slice(&[
28u8, 138, 255, 149, 6, 133, 194, 237, 75, 195, 23, 79, 52, 114, 40,
123, 86, 217, 81, 123, 156, 148, 129, 39, 49, 154, 9, 167, 163, 109,
234, 200,
]),
},
))
});

let event: Event = get_event(
Expand Down Expand Up @@ -259,7 +258,7 @@ mod tests {
rpc_client
.expect_get_events_by_hash_contract_call()
.returning(|_| {
Ok(vec![(
Some((
FieldElementAndEventIndex::from_str(
"0x035410be6f4bf3f67f7c1bb4a93119d9d410b2f981bfafbf5dbbf5d37ae7439e-0",
)
Expand All @@ -275,7 +274,7 @@ mod tests {
234, 200,
]),
},
)])
))
});

let event: Event = get_event(
Expand Down Expand Up @@ -303,14 +302,17 @@ mod tests {
rpc_client
.expect_get_events_by_hash_contract_call()
.once()
.with(eq(CheckedFelt::from_str(
"0x045410be6f4bf3f67f7c1bb4a93119d9d410b2f981bfafbf5dbbf5d37ae7439f",
)
.unwrap()))
.with(eq(FieldElementAndEventIndex {
tx_hash: CheckedFelt::from_str(
"0x045410be6f4bf3f67f7c1bb4a93119d9d410b2f981bfafbf5dbbf5d37ae7439f",
)
.unwrap(),
event_index: 1,
}))
.returning(|_| {
Ok(vec![(
Some((
FieldElementAndEventIndex::from_str(
"0x045410be6f4bf3f67f7c1bb4a93119d9d410b2f981bfafbf5dbbf5d37ae7439f-0",
"0x045410be6f4bf3f67f7c1bb4a93119d9d410b2f981bfafbf5dbbf5d37ae7439f-1",
)
.unwrap(),
ContractCallEvent {
Expand All @@ -324,7 +326,7 @@ mod tests {
234, 200,
]),
},
)])
))
});

let event: Event = get_event(
Expand Down
Loading