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 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
34 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
abe7301
Merge branch 'main' into feat/starknet-gmp
ctoyan Feb 5, 2025
be059ef
update Cargo.lock
ctoyan Feb 6, 2025
f9b0353
sort Cargo.toml and update Cargo.lock
ctoyan Feb 6, 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
848 changes: 485 additions & 363 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions ampd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ error-stack = { workspace = true }
ethers-contract = { workspace = true }
ethers-core = { workspace = true }
ethers-providers = { version = "2.0.13", default-features = false, features = [
"rustls",
"rustls",
] }
events = { workspace = true }
events-derive = { workspace = true }
Expand All @@ -39,7 +39,9 @@ move-core-types = { git = "https://github.com/mystenlabs/sui", tag = "testnet-v1
multisig = { workspace = true, features = ["library"] }
multiversx-sdk = "0.6.1"
num-traits = { workspace = true }
openssl = { version = "0.10.35", features = ["vendored"] } # Needed to make arm compilation work by forcing vendoring
openssl = { version = "0.10.35", features = [
"vendored",
] } # Needed to make arm compilation work by forcing vendoring
prost = "0.11.9"
prost-types = "0.11.9"
report = { workspace = true }
Expand All @@ -58,7 +60,7 @@ sui-gateway = { workspace = true }
sui-json-rpc-types = { git = "https://github.com/mystenlabs/sui", tag = "testnet-v1.39.1" }
sui-types = { git = "https://github.com/mystenlabs/sui", tag = "testnet-v1.39.1" }
tendermint = "0.35.0"
tendermint-rpc = { version = "0.35.0", features = [ "http-client" ] }
tendermint-rpc = { version = "0.35.0", features = ["http-client"] }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["signal"] }
tokio-stream = { workspace = true, features = ["sync"] }
Expand All @@ -67,13 +69,21 @@ toml = "0.5.9"
tonic = "0.9.2"
tracing = { version = "0.1.37", features = ["valuable", "log"] }
tracing-core = { version = "0.1.30", features = ["valuable"] }
tracing-subscriber = { version = "0.3.16", features = ["json", "valuable", "env-filter"] }
tracing-subscriber = { version = "0.3.16", features = [
"json",
"valuable",
"env-filter",
] }
typed-builder = "0.18.2"
url = "2.3.1"
valuable = { version = "0.1.0", features = ["derive"] }
valuable-serde = { version = "0.1.0", features = ["std"] }
voting-verifier = { workspace = true }

starknet-core = { workspace = true }
starknet-providers = { workspace = true }
starknet-checked-felt = { workspace = true }

[dev-dependencies]
assert_ok = { workspace = true }
ed25519-dalek = { workspace = true, features = ["rand_core"] }
Expand Down
10 changes: 7 additions & 3 deletions ampd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ type="MultisigSigner"
chain_name=[chain name. Not necessary in the Sui case]
chain_rpc_url=[URL of JSON-RPC endpoint for external chain]
cosmwasm_contract=[verifier contract address]
type=[handler type. Could be EvmMsgVerifier | SuiMsgVerifier]
type=[handler type. Could be EvmMsgVerifier | SuiMsgVerifier | StarknetMsgVerifier]

# handler to verify verifier set rotations. One per supported chain
[[handlers]]
chain_name=[chain name. Not necessary in the Sui case]
chain_rpc_url=[URL of JSON-RPC endpoint for external chain]
cosmwasm_contract=[verifier contract address]
type=[handler type. Could be EvmVerifierSetVerifier | SuiVerifierSetVerifier]
type=[handler type. Could be EvmVerifierSetVerifier | SuiVerifierSetVerifier | StarknetVerifierSetVerifier]
```

Below is an example config for connecting to a local axelard node and local tofnd process, and verifying transactions
Expand Down Expand Up @@ -101,13 +101,17 @@ cosmwasm_contract = 'axelar14lh98gp06zdqh5r9qj3874hdmfzs4sh5tkfzg3cyty4xeqsufdjq
chain_name = 'avalanche'
chain_rpc_url = "https://api.avax-test.network/ext/bc/C/rpc"

[[handlers]]
type = 'StarknetMsgVerifier'
cosmwasm_contract = 'axelar1f7qqgp0zk8489s69xxszut07kxse7y5j6j5tune36x75dc9ftfsssdkf2u'
chain = 'starknet-devnet-v1'
rpc_url = "https://starknet-sepolia.public.blastapi.io/rpc/v0_7"

[[handlers]]
type = 'EvmVerifierSetVerifier'
cosmwasm_contract = 'axelar14lh98gp06zdqh5r9qj3874hdmfzs4sh5tkfzg3cyty4xeqsufdjqedt3q8'
chain_name = 'avalanche'
chain_rpc_url = "https://api.avax-test.network/ext/bc/C/rpc"

```

By default, ampd loads the config file from `~/.ampd/config.toml` when running any command.
Expand Down
27 changes: 26 additions & 1 deletion ampd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ mod tests {
type = 'StellarVerifierSetVerifier'
cosmwasm_contract = '{}'
rpc_url = 'http://localhost:7545'

[[handlers]]
type = 'StarknetMsgVerifier'
cosmwasm_contract = '{}'
rpc_url = 'http://localhost:7545'

[[handlers]]
type = 'StarknetVerifierSetVerifier'
cosmwasm_contract = '{}'
rpc_url = 'http://localhost:7545'

",
TMAddress::random(PREFIX),
TMAddress::random(PREFIX),
Expand All @@ -143,10 +154,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 +363,18 @@ mod tests {
),
rpc_url: Url::from_str("http://127.0.0.1").unwrap(),
},
HandlerConfig::StarknetMsgVerifier {
cosmwasm_contract: TMAddress::from(
AccountId::new("axelar", &[0u8; 32]).unwrap(),
),
rpc_url: Url::from_str("http://127.0.0.1").unwrap(),
},
HandlerConfig::StarknetVerifierSetVerifier {
cosmwasm_contract: TMAddress::from(
AccountId::new("axelar", &[0u8; 32]).unwrap(),
),
rpc_url: Url::from_str("http://127.0.0.1").unwrap(),
},
],
..Config::default()
}
Expand Down
25 changes: 25 additions & 0 deletions ampd/src/handlers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,30 @@ pub enum Config {
cosmwasm_contract: TMAddress,
rpc_url: Url,
},
StarknetMsgVerifier {
cosmwasm_contract: TMAddress,
rpc_url: Url,
},
StarknetVerifierSetVerifier {
cosmwasm_contract: TMAddress,
rpc_url: Url,
},
}

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(()),
}
}

fn validate_evm_verifier_set_verifier_configs<'de, D>(configs: &[Config]) -> Result<(), D::Error>
Expand Down Expand Up @@ -133,6 +157,7 @@ where
{
let configs: Vec<Config> = Deserialize::deserialize(deserializer)?;

validate_starknet_msg_verifier_config::<D>(&configs)?;
validate_evm_msg_verifier_configs::<D>(&configs)?;
validate_evm_verifier_set_verifier_configs::<D>(&configs)?;

Expand Down
2 changes: 2 additions & 0 deletions ampd/src/handlers/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ pub enum Error {
Sign,
#[error("failed to get transaction receipts")]
TxReceipts,
#[error("starknet client failed")]
StarknetClient,
}
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 starknet_verify_msg;
pub mod starknet_verify_verifier_set;
pub(crate) mod stellar_verify_msg;
pub(crate) mod stellar_verify_verifier_set;
pub mod sui_verify_msg;
Expand Down
Loading