From f3642149fcc74975568f4aef99f0d95a0c356482 Mon Sep 17 00:00:00 2001
From: Mathieu <60658558+enitrat@users.noreply.github.com>
Date: Tue, 24 Sep 2024 18:30:03 +0200
Subject: [PATCH] refactor: remove coinbase constructor arg (#1438)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Time spent on this PR:
## Pull request type
Please check the type of change your PR introduces:
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [ ] Other (please describe):
## What is the current behavior?
Resolves #1391
## What is the new behavior?
- Removes the COINBASE constructor argument. If not set later, fees will
be burnt.
-
-
- - -
This change is [](https://reviewable.io/reviews/kkrt-labs/kakarot/1438)
---------
Co-authored-by: Clément Walter
---
kakarot_scripts/constants.py | 2 +-
kakarot_scripts/deploy_kakarot.py | 16 +++++++++++++---
src/kakarot/kakarot.cairo | 2 --
src/kakarot/library.cairo | 3 ---
tests/fixtures/EVM.cairo | 1 +
tests/utils/constants.py | 5 -----
6 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/kakarot_scripts/constants.py b/kakarot_scripts/constants.py
index c2a65152e..79195b300 100644
--- a/kakarot_scripts/constants.py
+++ b/kakarot_scripts/constants.py
@@ -223,7 +223,7 @@ class ChainId(IntEnum):
ETH_TOKEN_ADDRESS = 0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7
COINBASE = int(
os.getenv("KAKAROT_COINBASE_RECIPIENT")
- or "0x20eB005C0b9c906691F885eca5895338E15c36De",
+ or "0x20eB005C0b9c906691F885eca5895338E15c36De", # Defaults to faucet on appchain sepolia
16,
)
CAIRO_ZERO_DIR = Path("src")
diff --git a/kakarot_scripts/deploy_kakarot.py b/kakarot_scripts/deploy_kakarot.py
index 3ebffeb45..d87b9060e 100644
--- a/kakarot_scripts/deploy_kakarot.py
+++ b/kakarot_scripts/deploy_kakarot.py
@@ -26,7 +26,7 @@
)
from kakarot_scripts.utils.kakarot import dump_deployments as dump_evm_deployments
from kakarot_scripts.utils.kakarot import get_deployments as get_evm_deployments
-from kakarot_scripts.utils.starknet import declare
+from kakarot_scripts.utils.starknet import call, declare
from kakarot_scripts.utils.starknet import deploy as deploy_starknet
from kakarot_scripts.utils.starknet import (
dump_declarations,
@@ -63,9 +63,14 @@ async def main():
class_hash["account_contract"], # account_contract_class_hash_
class_hash["uninitialized_account"], # uninitialized_account_class_hash_
class_hash["Cairo1Helpers"],
- COINBASE,
BLOCK_GAS_LIMIT,
)
+ await invoke(
+ "EVM",
+ "set_coinbase",
+ COINBASE,
+ address=starknet_deployments["EVM"]["address"],
+ )
starknet_deployments["Counter"] = await deploy_starknet("Counter")
starknet_deployments["MockPragmaOracle"] = await deploy_starknet(
"MockPragmaOracle"
@@ -105,7 +110,6 @@ async def main():
class_hash["account_contract"], # account_contract_class_hash_
class_hash["uninitialized_account"], # uninitialized_account_class_hash_
class_hash["Cairo1Helpers"],
- COINBASE,
BLOCK_GAS_LIMIT,
)
await invoke(
@@ -149,6 +153,12 @@ async def main():
)
await invoke("kakarot", "set_coinbase", int(bridge.address, 16))
+ coinbase = (await call("kakarot", "get_coinbase")).coinbase
+ if coinbase == 0:
+ logger.error("❌ Coinbase is set to 0, all transaction fees will be lost")
+ else:
+ logger.info(f"✅ Coinbase set to: 0x{coinbase:040x}")
+
weth = await deploy_evm("WETH", "WETH9")
evm_deployments["WETH"] = {
"address": int(weth.address, 16),
diff --git a/src/kakarot/kakarot.cairo b/src/kakarot/kakarot.cairo
index ddcc71c1b..07a8558a5 100644
--- a/src/kakarot/kakarot.cairo
+++ b/src/kakarot/kakarot.cairo
@@ -78,7 +78,6 @@ func constructor{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr
account_contract_class_hash: felt,
uninitialized_account_class_hash: felt,
cairo1_helpers_class_hash: felt,
- coinbase: felt,
block_gas_limit: felt,
) {
return Kakarot.constructor(
@@ -87,7 +86,6 @@ func constructor{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr
account_contract_class_hash,
uninitialized_account_class_hash,
cairo1_helpers_class_hash,
- coinbase,
block_gas_limit,
);
}
diff --git a/src/kakarot/library.cairo b/src/kakarot/library.cairo
index 5a4af623d..4b48922eb 100644
--- a/src/kakarot/library.cairo
+++ b/src/kakarot/library.cairo
@@ -43,14 +43,12 @@ namespace Kakarot {
// @param account_contract_class_hash The clash hash of the contract account.
// @param uninitialized_account_class_hash The class hash of the uninitialized account used for deterministic address calculation.
// @param cairo1_helpers_class_hash The precompiles class hash for precompiles not implemented in Kakarot.
- // @param coinbase The EOA whose key is owned by the deployer (or known to be owned by Coinbase)
func constructor{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}(
owner: felt,
native_token_address,
account_contract_class_hash,
uninitialized_account_class_hash,
cairo1_helpers_class_hash,
- coinbase,
block_gas_limit,
) {
Ownable.initializer(owner);
@@ -58,7 +56,6 @@ namespace Kakarot {
Kakarot_account_contract_class_hash.write(account_contract_class_hash);
Kakarot_uninitialized_account_class_hash.write(uninitialized_account_class_hash);
Kakarot_cairo1_helpers_class_hash.write(cairo1_helpers_class_hash);
- Kakarot_coinbase.write(coinbase);
Kakarot_block_gas_limit.write(block_gas_limit);
return ();
}
diff --git a/tests/fixtures/EVM.cairo b/tests/fixtures/EVM.cairo
index 63576efa9..169db874e 100644
--- a/tests/fixtures/EVM.cairo
+++ b/tests/fixtures/EVM.cairo
@@ -33,6 +33,7 @@ from kakarot.kakarot import (
get_account_contract_class_hash,
get_cairo1_helpers_class_hash,
get_native_token,
+ set_coinbase,
)
from backend.starknet import Starknet, Internals as StarknetInternals
from utils.dict import dict_keys, dict_values
diff --git a/tests/utils/constants.py b/tests/utils/constants.py
index 55a0ab7b3..fcf8c4bf5 100644
--- a/tests/utils/constants.py
+++ b/tests/utils/constants.py
@@ -19,11 +19,6 @@
# Account balance is the amount of funds that the account has after being deployed
ACCOUNT_BALANCE = PRE_FUND_AMOUNT
-# Coinbase address is the address of the sequencer
-MOCK_COINBASE_ADDRESS = (
- 0x388CA486B82E20CC81965D056B4CDCAACDFFE0CF08E20ED8BA10EA97A487004
-)
-
# STACK
STACK_MAX_DEPTH = 1024