Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
fix relayer and add asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
obatirou committed Nov 14, 2024
1 parent 7947cbb commit 78e4ab3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
3 changes: 1 addition & 2 deletions kakarot_scripts/utils/kakarot.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,7 @@ async def eth_send_transaction(
typed_transaction = TypedTransaction.from_dict(payload)

evm_tx = EvmAccount.sign_transaction(
typed_transaction.as_dict(),
hex(evm_account.signer.private_key),
typed_transaction.as_dict(), f"{evm_account.signer.private_key:064x}"
)

if WEB3.is_connected():
Expand Down
40 changes: 24 additions & 16 deletions tests/end_to_end/Security/test_dual_vm_token_hack.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ async def test_malicious_approve_address_should_fail_nodelegatecall(
self, dual_vm_token, hack_vm_token, owner
):
result = await hack_vm_token.functions["tryApproveEvm()"](gas_limit=1000000)
call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert call_succeeded == 0
assert result["success"] == 1
underlying_call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert underlying_call_succeeded == 0

allowance = await dual_vm_token.functions["allowance(address,address)"](
owner.address, hack_vm_token.address
Expand All @@ -83,8 +84,9 @@ async def test_malicious_approve_starknet_should_fail_nodelegatecall(
self, dual_vm_token, hack_vm_token, owner
):
result = await hack_vm_token.functions["tryApproveStarknet()"]()
call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert call_succeeded == 0
assert result["success"] == 1
underlying_call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert underlying_call_succeeded == 0

allowance = await dual_vm_token.functions["allowance(address,uint256)"](
owner.address, int(hack_vm_token.address, 16)
Expand All @@ -95,8 +97,9 @@ async def test_malicious_transfer_address_should_fail_nodelegatecall(
self, dual_vm_token, hack_vm_token
):
result = await hack_vm_token.functions["tryTransferEvm()"]()
call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert call_succeeded == 0
assert result["success"] == 1
underlying_call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert underlying_call_succeeded == 0

balance = await dual_vm_token.functions["balanceOf(address)"](
hack_vm_token.address
Expand All @@ -107,8 +110,9 @@ async def test_malicious_transfer_starknet_should_fail_nodelegatecall(
self, dual_vm_token, hack_vm_token
):
result = await hack_vm_token.functions["tryTransferStarknet()"]()
call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert call_succeeded == 0
assert result["success"] == 1
underlying_call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert underlying_call_succeeded == 0

balance = await dual_vm_token.functions["balanceOf(uint256)"](
int(hack_vm_token.address, 16)
Expand All @@ -119,8 +123,9 @@ async def test_malicious_transfer_from_address_address_should_fail_nodelegatecal
self, dual_vm_token, hack_vm_token
):
result = await hack_vm_token.functions["tryTransferFromEvmEvm()"]()
call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert call_succeeded == 0
assert result["success"] == 1
underlying_call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert underlying_call_succeeded == 0

balance = await dual_vm_token.functions["balanceOf(address)"](
hack_vm_token.address
Expand All @@ -131,8 +136,9 @@ async def test_malicious_transfer_from_starknet_address_should_fail_nodelegateca
self, dual_vm_token, hack_vm_token
):
result = await hack_vm_token.functions["tryTransferFromStarknetEvm()"]()
call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert call_succeeded == 0
assert result["success"] == 1
underlying_call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert underlying_call_succeeded == 0

balance = await dual_vm_token.functions["balanceOf(address)"](
hack_vm_token.address
Expand All @@ -143,8 +149,9 @@ async def test_malicious_transfer_from_address_starknet_should_fail_nodelegateca
self, dual_vm_token, hack_vm_token
):
result = await hack_vm_token.functions["tryTransferFromEvmStarknet()"]()
call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert call_succeeded == 0
assert result["success"] == 1
underlying_call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert underlying_call_succeeded == 0

balance = await dual_vm_token.functions["balanceOf(uint256)"](
int(hack_vm_token.address, 16)
Expand All @@ -157,8 +164,9 @@ async def test_malicious_transfer_from_starknet_starknet_should_fail_nodelegatec
result = await hack_vm_token.functions[
"tryTransferFromStarknetStarknet()"
]()
call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert call_succeeded == 0
assert result["success"] == 1
underlying_call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert underlying_call_succeeded == 0

balance = await dual_vm_token.functions["balanceOf(uint256)"](
int(hack_vm_token.address, 16)
Expand Down
5 changes: 3 additions & 2 deletions tests/end_to_end/Security/test_l2_messaging_hack.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ async def test_malicious_message_should_fail_nodelegatecall(
result = await messaging_hack_contract.functions[
"trySendMessageToL1(address,bytes)"
](malicious_target, malicious_data)
call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert call_succeeded == 0
assert result["success"] == 1
underlying_call_succeeded = int.from_bytes(bytes(result["response"]), "big")
assert underlying_call_succeeded == 0

0 comments on commit 78e4ab3

Please sign in to comment.