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

Set gasPrice to 0 for view/pure calls of l1 utils #1560

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"address": "0xc9c677a629aae7a149f5f0e7546394f2630e8e9e",
"starknet_address": "0x4fc85a8f1dd13464031e996dec1aeb1734eac3141413577638e0529487137df"
}
}
}
2 changes: 1 addition & 1 deletion deployments/starknet-sepolia-staging/l1_addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"StarknetCore": "0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057",
"StarknetVerifier": "0x07ec0D28e50322Eb0C159B9090ecF3aeA8346DFe",
"L1KakarotMessaging": "0x095Eb56Fe5E66D8AEbf20a3412c40a0d6537C059"
}
}
12 changes: 8 additions & 4 deletions kakarot_scripts/utils/l1.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@ def prepare_l1_transaction(
"""Execute the data at the EVM contract on an L1 node."""
evm_account = caller_eoa or EvmAccount.from_key(EVM_PRIVATE_KEY)
transaction: TxParams = {
"chainId": L1_RPC_PROVIDER.eth.chain_id,
"nonce": L1_RPC_PROVIDER.eth.get_transaction_count(evm_account.address),
"to": to_checksum_address(to) if to else "",
"gasPrice": L1_RPC_PROVIDER.eth.gas_price,
"value": value or Wei(0),
"data": data,
"from": evm_account.address,
}
transaction["gas"] = L1_RPC_PROVIDER.eth.estimate_gas(transaction)
transaction["gasPrice"] = L1_RPC_PROVIDER.eth.gas_price
transaction["chainId"] = L1_RPC_PROVIDER.eth.chain_id
transaction["nonce"] = L1_RPC_PROVIDER.eth.get_transaction_count(
evm_account.address
)

return transaction


Expand Down Expand Up @@ -171,7 +174,8 @@ def _wrapper(self, *args, **kwargs):
)

if abi["stateMutability"] in ["pure", "view"]:
result = L1_RPC_PROVIDER.eth.call(transaction)
# Setting gasPrice to 0 to avoid error due to sender balance to low
result = L1_RPC_PROVIDER.eth.call({**transaction, "gasPrice": 0})
types = get_abi_output_types(abi)
decoded = decode(types, bytes(result))
normalized = map_abi_data(BASE_RETURN_NORMALIZERS, types, decoded)
Expand Down
Loading