Skip to content

Commit e13657b

Browse files
committed
refactor: ♻️ Remove remote proof fetching
1 parent 35a28c0 commit e13657b

File tree

10 files changed

+130
-166
lines changed

10 files changed

+130
-166
lines changed

examples/08_evm_cctp_roundtrip.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ def main() -> None:
5959

6060
amount = float(os.getenv("BRIDGE_AMOUNT_USDC", str(DEFAULT_AMOUNT)))
6161

62-
proof_blob_path = Path(__file__).with_name("example_verification_blob.json")
63-
with proof_blob_path.open("r", encoding="utf-8") as proof_file:
64-
verification_blob = json.load(proof_file)
62+
blobs_dir = Path(__file__).parent / "blobs"
63+
64+
blob_path_1 = blobs_dir / "example_verification_blob.json"
65+
with blob_path_1.open("r", encoding="utf-8") as f:
66+
verification_blob_1 = json.load(f)
67+
68+
blob_path_2 = blobs_dir / "example_verification_blob2.json"
69+
with blob_path_2.open("r", encoding="utf-8") as f:
70+
verification_blob_2 = json.load(f)
6571

6672
client = HLProtocolEVM(
6773
private_key=private_key,
@@ -70,7 +76,7 @@ def main() -> None:
7076
hl_strategy_address=hl_strategy_address,
7177
bridge_strategy_address=bridge_strategy_address,
7278
testnet=testnet,
73-
flexible_vault_proof_blob=verification_blob,
79+
flexible_vault_proof_blob=[verification_blob_1, verification_blob_2],
7480
)
7581

7682
client.connect()
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"title": "mainnet:tqETH:subvault0",
3+
"merkle_root": "0x8cacec5a1f3021c50d6e4f4ac80121df88f6fb6f636f981bcbd169eefaed3da3",
4+
"merkle_proofs": [
5+
{
6+
"verificationType": 3,
7+
"description": "CoreWriter.sendRawAction{action: limit_order}(anyBytes)",
8+
"verificationData": "0x0000000000000000000000000000000263fb29c3d6b0c5837883519ef05ea20a04d1b33472333c382f6830bd3e61bf513e62ad79b5f3441f8ff182fb929fcae000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000",
9+
"proof": [
10+
"0x309b822df17cf8c5bc2494ec60d9d2b59a75b6b698a6c86a51fcf37a7f7da974",
11+
"0x4ca29eeb08d7c9b554ee3baff79abf1060d56c2fbcd2eb4f879018b4c6737ebf",
12+
"0x3c1feb2292bf6df1ecbcd268a9bdb51445d095acfdf61e0a397870deeed573a8"
13+
]
14+
},
15+
{
16+
"verificationType": 3,
17+
"description": "CoreWriter.sendRawAction{action: cancel_oid}(anyBytes)",
18+
"verificationData": "0x0000000000000000000000000000000263fb29c3d6b0c5837883519ef05ea20a04d1b33472333c382f6830bd3e61bf513e62ad79b5f3441f8ff182fb929fcae000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000",
19+
"proof": [
20+
"0x309b822df17cf8c5bc2494ec60d9d2b59a75b6b698a6c86a51fcf37a7f7da974",
21+
"0x4ca29eeb08d7c9b554ee3baff79abf1060d56c2fbcd2eb4f879018b4c6737ebf",
22+
"0x3c1feb2292bf6df1ecbcd268a9bdb51445d095acfdf61e0a397870deeed573a8"
23+
]
24+
},
25+
{
26+
"verificationType": 3,
27+
"description": "CoreWriter.sendRawAction{action: cancel_cloid}(anyBytes)",
28+
"verificationData": "0x0000000000000000000000000000000263fb29c3d6b0c5837883519ef05ea20a04d1b33472333c382f6830bd3e61bf513e62ad79b5f3441f8ff182fb929fcae000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000",
29+
"proof": [
30+
"0x309b822df17cf8c5bc2494ec60d9d2b59a75b6b698a6c86a51fcf37a7f7da974",
31+
"0x4ca29eeb08d7c9b554ee3baff79abf1060d56c2fbcd2eb4f879018b4c6737ebf",
32+
"0x3c1feb2292bf6df1ecbcd268a9bdb51445d095acfdf61e0a397870deeed573a8"
33+
]
34+
},
35+
{
36+
"verificationType": 3,
37+
"description": "CoreWriter.sendRawAction{action: spot_send}(anyBytes)",
38+
"verificationData": "0x0000000000000000000000000000000263fb29c3d6b0c5837883519ef05ea20a04d1b33472333c382f6830bd3e61bf513e62ad79b5f3441f8ff182fb929fcae000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000",
39+
"proof": [
40+
"0x309b822df17cf8c5bc2494ec60d9d2b59a75b6b698a6c86a51fcf37a7f7da974",
41+
"0x4ca29eeb08d7c9b554ee3baff79abf1060d56c2fbcd2eb4f879018b4c6737ebf",
42+
"0x3c1feb2292bf6df1ecbcd268a9bdb51445d095acfdf61e0a397870deeed573a8"
43+
]
44+
},
45+
{
46+
"verificationType": 3,
47+
"description": "CoreWriter.sendRawAction{action: usd_transfer}(anyBytes)",
48+
"verificationData": "0x0000000000000000000000000000000263fb29c3d6b0c5837883519ef05ea20a04d1b33472333c382f6830bd3e61bf513e62ad79b5f3441f8ff182fb929fcae000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000",
49+
"proof": [
50+
"0x309b822df17cf8c5bc2494ec60d9d2b59a75b6b698a6c86a51fcf37a7f7da974",
51+
"0x4ca29eeb08d7c9b554ee3baff79abf1060d56c2fbcd2eb4f879018b4c6737ebf",
52+
"0x3c1feb2292bf6df1ecbcd268a9bdb51445d095acfdf61e0a397870deeed573a8"
53+
]
54+
},
55+
{
56+
"verificationType": 3,
57+
"description": "USDC.approve(TokenMessenger, anyInt)",
58+
"verificationData": "0x0000000000000000000000000000000263fb29c3d6b0c5837883519ef05ea20a04d1b33472333c382f6830bd3e61bf513e62ad79b5f3441f8ff182fb929fcae000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000",
59+
"proof": [
60+
"0x309b822df17cf8c5bc2494ec60d9d2b59a75b6b698a6c86a51fcf37a7f7da974",
61+
"0x4ca29eeb08d7c9b554ee3baff79abf1060d56c2fbcd2eb4f879018b4c6737ebf",
62+
"0x3c1feb2292bf6df1ecbcd268a9bdb51445d095acfdf61e0a397870deeed573a8"
63+
]
64+
},
65+
{
66+
"verificationType": 3,
67+
"description": "TokenMessenger.depositForBurn(anyInt)",
68+
"verificationData": "0x0000000000000000000000000000000263fb29c3d6b0c5837883519ef05ea20a04d1b33472333c382f6830bd3e61bf513e62ad79b5f3441f8ff182fb929fcae000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000",
69+
"proof": [
70+
"0x309b822df17cf8c5bc2494ec60d9d2b59a75b6b698a6c86a51fcf37a7f7da974",
71+
"0x4ca29eeb08d7c9b554ee3baff79abf1060d56c2fbcd2eb4f879018b4c6737ebf",
72+
"0x3c1feb2292bf6df1ecbcd268a9bdb51445d095acfdf61e0a397870deeed573a8"
73+
]
74+
}
75+
]
76+
}
File renamed without changes.

src/hl_api/evm/bridge.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ def __init__(
3838
*,
3939
verification_resolver: FlexibleVaultProofResolver | None = None,
4040
disable_call_verification: bool = False,
41-
mainnet_json_name: str | None = None,
42-
hyperliquid_json_name: str | None = None,
4341
) -> None:
4442
self._config = config
4543
self._connections = connections
@@ -56,8 +54,6 @@ def __init__(
5654
self._cctp_finality_threshold = config.cctp_finality_threshold
5755
self._verification_resolver = verification_resolver
5856
self._call_verification_disabled = disable_call_verification
59-
self._mainnet_json_name = mainnet_json_name
60-
self._hyperliquid_json_name = hyperliquid_json_name
6157

6258
# ------------------------------------------------------------------
6359
# Public entry points
@@ -421,29 +417,29 @@ def _resolve_cctp_verification_payloads(
421417
]
422418

423419
context = {"direction": direction.value, "amount_units": amount_units}
424-
if direction == BridgeDirection.MAINNET_TO_HYPER:
425-
json_name = self._mainnet_json_name
426-
if not json_name and hasattr(resolver, "_datasets"):
420+
421+
json_name = None
422+
if hasattr(resolver, "_datasets"):
423+
if direction == BridgeDirection.MAINNET_TO_HYPER:
427424
for title in resolver._datasets.keys():
428425
if "mainnet" in title.lower() or "ethereum" in title.lower():
429426
json_name = title
430427
break
431-
elif direction == BridgeDirection.HYPER_TO_MAINNET:
432-
json_name = self._hyperliquid_json_name
433-
if not json_name and hasattr(resolver, "_datasets"):
428+
elif direction == BridgeDirection.HYPER_TO_MAINNET:
434429
for title in resolver._datasets.keys():
435430
if "hyperevm" in title.lower() or "hyperliquid" in title.lower():
436431
json_name = title
437432
break
438-
else:
439-
raise ValidationError(
440-
"Unknown bridge direction",
441-
field="direction",
442-
value=direction,
443-
)
433+
else:
434+
raise ValidationError(
435+
"Unknown bridge direction",
436+
field="direction",
437+
value=direction,
438+
)
444439

445-
if not json_name and hasattr(resolver, "_datasets") and resolver._datasets:
446-
json_name = next(iter(resolver._datasets.keys()))
440+
# If no specific match found, use the first available dataset
441+
if not json_name and resolver._datasets:
442+
json_name = next(iter(resolver._datasets.keys()))
447443

448444
if not json_name:
449445
json_name = "default"

src/hl_api/evm/client.py

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ def __init__(
7777
hyperliquid_domain: int | None = None,
7878
mainnet_domain: int | None = None,
7979
cctp_finality_threshold: int = DEFAULT_CCTP_FINALITY_THRESHOLD,
80-
flexible_vault_proof_blob: Mapping[str, Any] | None = None,
80+
flexible_vault_proof_blob: Mapping[str, Any] | Sequence[Mapping[str, Any]] | None = None,
8181
disable_call_verification: bool = False,
82-
hl_strategy_json_name: str | None = None,
83-
bridge_strategy_json_name: str | None = None,
8482
) -> None:
8583
hl_address = Web3.to_checksum_address(hl_strategy_address)
8684
bridge_address = Web3.to_checksum_address(bridge_strategy_address)
@@ -130,17 +128,13 @@ def __init__(
130128
self._session,
131129
verification_resolver=self._flexible_proof_resolver,
132130
disable_call_verification=self._call_verification_disabled,
133-
mainnet_json_name=bridge_strategy_json_name, # For operations originating on mainnet
134-
hyperliquid_json_name=hl_strategy_json_name, # For operations originating on HyperEVM
135131
)
136132

137133
self._asset_by_symbol = self._metadata.asset_by_symbol
138134
self._token_index_by_symbol = self._metadata.token_index_by_symbol
139135
self._metadata_loaded = self._metadata.metadata_loaded
140136
self._hype_token_index: int | None = None
141137
self._connected = False
142-
self._hl_strategy_json_name = hl_strategy_json_name
143-
self._bridge_strategy_json_name = bridge_strategy_json_name
144138

145139
# ------------------------------------------------------------------
146140
# Connection management
@@ -372,7 +366,6 @@ def limit_order(
372366
"tif": tif_uint,
373367
"cloid": cloid_uint,
374368
}
375-
# All these operations happen on HyperEVM chain
376369
json_name = self._get_json_name_for_chain("hyperliquid")
377370
payload = self._resolve_verification_payload(
378371
"CoreWriter.sendRawAction{action: limit_order}(anyBytes)", json_name, context
@@ -402,7 +395,7 @@ def cancel_order_by_oid(self, asset: str, order_id: int) -> Response:
402395
asset_id = self._resolve_asset_id(asset)
403396
oid = int(order_id)
404397
context = {"asset": asset_id, "oid": oid}
405-
# All these operations happen on HyperEVM chain
398+
406399
json_name = self._get_json_name_for_chain("hyperliquid")
407400
payload = self._resolve_verification_payload(
408401
"CoreWriter.sendRawAction{action: cancel_oid}(anyBytes)", json_name, context
@@ -423,7 +416,6 @@ def cancel_order_by_cloid(self, asset: str, cloid: str) -> Response:
423416
asset_id = self._resolve_asset_id(asset)
424417
cloid_uint = cloid_to_uint128(cloid)
425418
context = {"asset": asset_id, "cloid": cloid_uint}
426-
# All these operations happen on HyperEVM chain
427419
json_name = self._get_json_name_for_chain("hyperliquid")
428420
payload = self._resolve_verification_payload(
429421
"CoreWriter.sendRawAction{action: cancel_cloid}(anyBytes)", json_name, context
@@ -451,7 +443,7 @@ def vault_transfer(self, vault: str, is_deposit: bool, usd: float) -> Response:
451443
def spot_send(self, recipient: str, token: str, amount: float, destination: str) -> Response:
452444
amount_uint = to_uint64(amount, 8)
453445
context = {"token": token, "amount": amount_uint, "recipient": recipient}
454-
# All these operations happen on HyperEVM chain
446+
455447
json_name = self._get_json_name_for_chain("hyperliquid")
456448
payload = self._resolve_verification_payload(
457449
"CoreWriter.sendRawAction{action: spot_send}(anyBytes)", json_name, context
@@ -510,7 +502,7 @@ def bridge_hyperliquid_to_mainnet(
510502
def usd_class_transfer_to_perp(self, amount: float) -> Response:
511503
amount_uint = to_uint64(amount, 6)
512504
context = {"amount": amount_uint}
513-
# All these operations happen on HyperEVM chain
505+
514506
json_name = self._get_json_name_for_chain("hyperliquid")
515507
payload = self._resolve_verification_payload(
516508
"CoreWriter.sendRawAction{action: usd_transfer}(anyBytes)", json_name, context
@@ -530,7 +522,7 @@ def usd_class_transfer_to_perp(self, amount: float) -> Response:
530522
def usd_class_transfer_to_spot(self, amount: float) -> Response:
531523
amount_uint = to_uint64(amount, 6)
532524
context = {"amount": amount_uint}
533-
# All these operations happen on HyperEVM chain
525+
534526
json_name = self._get_json_name_for_chain("hyperliquid")
535527
payload = self._resolve_verification_payload(
536528
"CoreWriter.sendRawAction{action: usd_transfer}(anyBytes)", json_name, context
@@ -662,31 +654,22 @@ def _get_json_name_for_chain(self, chain: str = "hyperliquid") -> str:
662654
Args:
663655
chain: Either "hyperliquid" for operations on HyperEVM or "mainnet" for operations on mainnet
664656
"""
665-
if chain == "mainnet":
666-
if self._bridge_strategy_json_name:
667-
return self._bridge_strategy_json_name
668-
# Try to auto-detect from available datasets if resolver exists
669-
if self._flexible_proof_resolver and hasattr(
670-
self._flexible_proof_resolver, "_datasets"
671-
):
672-
# Look for a dataset for mainnet operations
657+
if self._flexible_proof_resolver and hasattr(self._flexible_proof_resolver, "_datasets"):
658+
if chain == "mainnet":
673659
for title in self._flexible_proof_resolver._datasets.keys():
674660
if "mainnet" in title.lower() or "ethereum" in title.lower():
675661
return title
676-
else: # hyperliquid chain operations
677-
if self._hl_strategy_json_name:
678-
return self._hl_strategy_json_name
679-
# Try to auto-detect from available datasets
680-
if self._flexible_proof_resolver and hasattr(
681-
self._flexible_proof_resolver, "_datasets"
682-
):
683-
# Look for a dataset for HyperEVM operations
662+
elif chain == "hyperliquid": # hyperliquid chain operations
684663
for title in self._flexible_proof_resolver._datasets.keys():
685664
if "hyperevm" in title.lower() or "hyperliquid" in title.lower():
686665
return title
666+
else:
667+
raise ValidationError(
668+
"Chain must be either 'hyperliquid' or 'mainnet'",
669+
field="chain",
670+
value=chain,
671+
)
687672

688-
# If no specific json_name found, try to use the first available
689-
if self._flexible_proof_resolver and hasattr(self._flexible_proof_resolver, "_datasets"):
690673
datasets = self._flexible_proof_resolver._datasets
691674
if datasets:
692675
return next(iter(datasets.keys()))

src/hl_api/evm/config.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
DEFAULT_IRIS_POLL_INTERVAL = 2.0
1414
DEFAULT_IRIS_MAX_POLLS = 100
1515
DEFAULT_CCTP_FINALITY_THRESHOLD = 1000
16-
DEFAULT_FLEXIBLE_VAULT_PROOF_URL = (
17-
"https://raw.githubusercontent.com/mellow-finance/flexible-vaults/"
18-
"test-deployments/scripts/jsons/ethereum%3AtqETH%3Asubvault0.json"
19-
)
2016
IRIS_API_SANDBOX = "https://iris-api-sandbox.circle.com"
2117
IRIS_API_PROD = "https://iris-api.circle.com"
2218

@@ -42,7 +38,6 @@ class EVMClientConfig:
4238
mainnet_domain: int | None = None
4339
cctp_finality_threshold: int = DEFAULT_CCTP_FINALITY_THRESHOLD
4440

45-
flexible_vault_proof_url: str | Sequence[str] = DEFAULT_FLEXIBLE_VAULT_PROOF_URL
4641
flexible_vault_verifier_address: str | None = None
4742
flexible_vault_verifier_network: str = "hyper"
4843
flexible_vault_check_merkle_root: bool = False

0 commit comments

Comments
 (0)