Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
93a5217
Revert "feat(l2): custom native token (#4622)"
tomip01 Oct 17, 2025
9c23130
add custom fee token tx
tomip01 Oct 21, 2025
e6890f9
first approach l2 hook
tomip01 Oct 21, 2025
c146fdb
basic custom fee token test, missing correctness
tomip01 Oct 21, 2025
934be30
some advances on test
tomip01 Oct 21, 2025
21b9f35
fix tx type check
tomip01 Oct 22, 2025
6ac9b51
change custom fee tx to 0xfd
tomip01 Oct 22, 2025
2e937ce
prevent recursion
tomip01 Oct 22, 2025
fce3ffc
some advances, exeuctin sol function, failing on acc updates
tomip01 Oct 22, 2025
36139db
succeeding internal hook txs
tomip01 Oct 23, 2025
d3f6ebd
working fees, failing eth value
tomip01 Oct 23, 2025
d7bd248
fix pks and sks
tomip01 Oct 23, 2025
6c8f05c
test passing with fee vault
tomip01 Oct 23, 2025
5a27a64
all working, missing LOTS of refactors
tomip01 Oct 23, 2025
3c230d7
correct based and native tokens changes
tomip01 Oct 23, 2025
2a778f9
more changes to workflow
tomip01 Oct 23, 2025
2d0fb42
restore contracts
tomip01 Oct 23, 2025
42b2f42
update address contract
tomip01 Oct 23, 2025
0392b9e
Merge branch 'main' into fee_token_2
tomip01 Oct 23, 2025
ac9f885
remove dbgs
tomip01 Oct 23, 2025
d2c5f97
Merge branch 'fee_token_2' into fee_token_3
tomip01 Oct 23, 2025
95cc43b
fix merge main on tests
tomip01 Oct 23, 2025
e4e5d14
some refactors, working
tomip01 Oct 23, 2025
923e6cc
fix coinbase diminish fee
tomip01 Oct 23, 2025
a215f25
l2 hook refactors
tomip01 Oct 24, 2025
d896d25
more refactors
tomip01 Oct 24, 2025
5c67a8d
refactor contracts
tomip01 Oct 24, 2025
51cd21e
refactor tests
tomip01 Oct 24, 2025
2db97e6
fix runner compile
tomip01 Oct 24, 2025
e8410af
add more pk
tomip01 Oct 24, 2025
dbbd0d8
update pk tests
tomip01 Oct 24, 2025
21da403
fix srialization
tomip01 Oct 24, 2025
71eb92d
fix runner compile again
tomip01 Oct 24, 2025
3232b7c
fix fees config update
tomip01 Oct 24, 2025
049d054
restore testing files
tomip01 Oct 24, 2025
9034b54
restore testing files again
tomip01 Oct 24, 2025
45fa41a
Merge branch 'main' into fee_token_2
tomip01 Oct 24, 2025
2048445
Merge branch 'fee_token_2' into fee_token_3
tomip01 Oct 24, 2025
119914b
Merge branch 'main' into fee_token_2
tomip01 Oct 27, 2025
a2050fa
Merge branch 'fee_token_2' into fee_token_3
tomip01 Oct 27, 2025
24603cd
refactor: le_hook
tomip01 Oct 27, 2025
7a42d76
fix compile test
tomip01 Oct 27, 2025
3034711
remove redundant if
tomip01 Oct 27, 2025
5be27cf
rename custom fee -> fee token
tomip01 Oct 27, 2025
2362379
fix renaming issue
tomip01 Oct 27, 2025
9814be2
remove empty hook
tomip01 Oct 27, 2025
89dcf58
merge and handle option types
tomip01 Oct 27, 2025
b743601
doc transfer fee_token
tomip01 Oct 27, 2025
be039ac
doc l2_hook
tomip01 Oct 27, 2025
749f2b1
add log and use var instead of hardcoded
tomip01 Oct 27, 2025
240f4b9
add log and use var instead of hardcoded fix
tomip01 Oct 27, 2025
6844c64
add vault checks
tomip01 Oct 27, 2025
ce6dfe1
fix vault checks
tomip01 Oct 28, 2025
f3811b4
use default hook explicit functions
tomip01 Oct 28, 2025
4441cfb
use IFeeToken and fix l2 dev job
tomip01 Oct 28, 2025
231ca50
add fee token docs
tomip01 Oct 28, 2025
61b616b
restore makefile
tomip01 Oct 28, 2025
9984753
remove step docs
tomip01 Oct 28, 2025
e304253
Merge branch 'main' into fee_token_2
tomip01 Oct 28, 2025
a217eff
review suggestions
tomip01 Oct 28, 2025
8f6f416
Merge branch 'fee_token_2' into fee_token_3
tomip01 Oct 28, 2025
f93245a
fix deployer
tomip01 Oct 28, 2025
9138917
Merge branch 'fee_token_2' into fee_token_3
tomip01 Oct 28, 2025
e45b0fe
fix default bridge address
tomip01 Oct 28, 2025
c2cb4c8
Merge branch 'fee_token_2' into fee_token_3
tomip01 Oct 28, 2025
a3d2f54
iclude fee token tx in p2p
tomip01 Oct 28, 2025
9fa147c
try fix based integration test
tomip01 Oct 28, 2025
b525115
Merge branch 'main' into fee_token_2
tomip01 Oct 28, 2025
e3e0a31
Merge branch 'fee_token_2' into fee_token_3
tomip01 Oct 28, 2025
2cb1c86
Merge branch 'main' into fee_token_2
tomip01 Oct 28, 2025
4410cc1
Merge branch 'fee_token_2' into fee_token_3
tomip01 Oct 28, 2025
a6b20e3
more detail docs
tomip01 Oct 29, 2025
a43e5c5
first approach on fee registry
tomip01 Oct 30, 2025
c888453
use restrict allowance for token registry
tomip01 Oct 30, 2025
85620b5
Update crates/vm/levm/src/hooks/l2_hook.rs
tomip01 Oct 30, 2025
4c67d94
make only base fee vault check optionals
tomip01 Oct 30, 2025
e4c0412
restore makefile
tomip01 Oct 30, 2025
38e6d03
Merge branch 'main' into fee_token_2
tomip01 Oct 31, 2025
7f50595
fix deafult address
tomip01 Oct 31, 2025
7b67f43
Merge branch 'fee_token_2' into fee_token_3
tomip01 Oct 31, 2025
b3e5696
add cargo lock
tomip01 Oct 31, 2025
37c6e7d
Merge branch 'main' into fee_token_2
tomip01 Oct 31, 2025
8e6ab6f
Merge branch 'fee_token_2' into fee_token_3
tomip01 Oct 31, 2025
960054b
Merge branch 'main' into fee_token_2
tomip01 Nov 3, 2025
4d0fcf2
fix: update default address
tomip01 Nov 3, 2025
885a0a7
Merge branch 'fee_token_2' into fee_token_3
tomip01 Nov 3, 2025
28f5d6f
fix merge main
tomip01 Nov 3, 2025
2be365d
refactor: use fixed address
tomip01 Nov 3, 2025
13ec266
refactor: remove old code
tomip01 Nov 3, 2025
452a134
restore genesis
tomip01 Nov 3, 2025
477927e
Revert "restore genesis"
tomip01 Nov 3, 2025
5d63a29
some advances, removing modifier on bridge works
tomip01 Nov 6, 2025
7e19fd6
missing working but fix some error
tomip01 Nov 6, 2025
ef3239b
working, removed debug stuff
tomip01 Nov 7, 2025
cac2f2d
add missing func
tomip01 Nov 7, 2025
406c59a
add step in deployer
tomip01 Nov 7, 2025
c7991b0
some advances, missing underprice
tomip01 Nov 7, 2025
59aa4bd
add secure check
tomip01 Nov 7, 2025
8e43c56
add fee token to default
tomip01 Nov 7, 2025
e7193fe
fix address
tomip01 Nov 7, 2025
8ccb56d
fix tests
tomip01 Nov 7, 2025
89ad9f2
update bridge owner
tomip01 Nov 7, 2025
278db2d
fix rule makefile
tomip01 Nov 7, 2025
611763d
fix address again
tomip01 Nov 7, 2025
ee1b353
revert wrong address
tomip01 Nov 7, 2025
34357eb
fix clippy
tomip01 Nov 7, 2025
1c26ae7
update fees accordingly
tomip01 Nov 7, 2025
b1d23e2
try test
tomip01 Nov 7, 2025
5a9d938
fix import
tomip01 Nov 7, 2025
0b94fbd
add await
tomip01 Nov 7, 2025
75a8c36
Merge branch 'main' into fee_token_2
tomip01 Nov 9, 2025
5aff987
Merge branch 'fee_token_2' of github.com:lambdaclass/ethrex into fee_…
tomip01 Nov 9, 2025
fd465af
Merge branch 'fee_token_2' into fee_token_3
tomip01 Nov 9, 2025
72abebb
fix compilation
tomip01 Nov 9, 2025
f536c57
fix lint
tomip01 Nov 9, 2025
0591d7c
increase wait time
tomip01 Nov 9, 2025
074333b
add dbg to show registry
tomip01 Nov 9, 2025
c57c8ab
fix compile
tomip01 Nov 9, 2025
6f8261d
fix
tomip01 Nov 9, 2025
76a38b5
more dbgs
tomip01 Nov 9, 2025
543d5a2
try option
tomip01 Nov 9, 2025
34055a2
try debugging waiting
tomip01 Nov 10, 2025
44391e8
add one more dbg print
tomip01 Nov 10, 2025
f113425
update genesis?
tomip01 Nov 10, 2025
a55b417
update test gas limit
tomip01 Nov 10, 2025
54392ea
try fix contract
tomip01 Nov 10, 2025
fe9e647
increase gas limit
tomip01 Nov 10, 2025
d019fe6
try removing modifier
tomip01 Nov 10, 2025
6895ca9
print receipt
tomip01 Nov 10, 2025
a9eb350
run all tests
tomip01 Nov 10, 2025
d9c5868
refactor test
tomip01 Nov 10, 2025
14f3b70
update ethrex version
tomip01 Nov 10, 2025
838879f
refactors and delete debug stuff
tomip01 Nov 10, 2025
88a2707
fix clippy
tomip01 Nov 10, 2025
486093d
add deprecated variable
tomip01 Nov 10, 2025
5f2e856
add contracts suggestions
tomip01 Nov 10, 2025
0937f21
correct contract formatting
tomip01 Nov 10, 2025
b44f39b
update: token docs
tomip01 Nov 10, 2025
f08c6bb
update again fee_token.md
tomip01 Nov 10, 2025
d91c68e
changes docs again
tomip01 Nov 10, 2025
54122db
fix default address
tomip01 Nov 10, 2025
2b64283
Merge branch 'fee_token_2' into fee_token_3
tomip01 Nov 10, 2025
ecb7b66
do initial registry inside deposits
tomip01 Nov 11, 2025
b1b27f6
fix docs
tomip01 Nov 11, 2025
f48cc88
Revert "do initial registry inside deposits"
tomip01 Nov 11, 2025
8de6da4
await for receipt inside deposits
tomip01 Nov 11, 2025
699c2df
add comment on expected value
tomip01 Nov 11, 2025
6c485b8
fix lint deployer
tomip01 Nov 11, 2025
07fff12
use correct function for waiting
tomip01 Nov 11, 2025
c20a999
fix lints
tomip01 Nov 11, 2025
74754de
add comment explaining
tomip01 Nov 11, 2025
9be4cbd
fix clippy
tomip01 Nov 11, 2025
1843454
fix clippy
tomip01 Nov 11, 2025
8cebd79
fix indentation
tomip01 Nov 11, 2025
d49b063
Update crates/l2/contracts/src/l2/FeeTokenRegistry.sol
tomip01 Nov 11, 2025
601f2b6
fix indent and add correct error msg
tomip01 Nov 11, 2025
cdfbce0
fix again sol contract indent
tomip01 Nov 11, 2025
5525beb
fix edge case
tomip01 Nov 11, 2025
421a94c
comment and remove old variable
tomip01 Nov 11, 2025
b58b602
apply suggestion
tomip01 Nov 11, 2025
fdbb270
fix deploy
tomip01 Nov 11, 2025
608916a
fix deployer again
tomip01 Nov 12, 2025
ec383f9
Merge branch 'main' into fee_token_3
tomip01 Nov 12, 2025
b474688
Update crates/l2/contracts/src/l2/FeeTokenRegistry.sol
tomip01 Nov 12, 2025
8b2cffc
remove old comment
tomip01 Nov 12, 2025
460f7fb
Update cmd/ethrex/l2/deployer.rs
tomip01 Nov 12, 2025
d9cea78
Update cmd/ethrex/l2/deployer.rs
tomip01 Nov 12, 2025
437dbde
fix lint
tomip01 Nov 12, 2025
fa4766b
Merge branch 'main' into fee_token_3
tomip01 Nov 12, 2025
25eebc2
Merge branch 'main' into fee_token_3
ilitteri Nov 12, 2025
9453206
Merge branch 'main' into fee_token_3
tomip01 Nov 13, 2025
951f8e1
update blobs for reconstruct
tomip01 Nov 13, 2025
973d43b
fix test again
tomip01 Nov 13, 2025
ccfd67e
fix type
tomip01 Nov 13, 2025
3bfe660
fix compilation
tomip01 Nov 13, 2025
d4cb74d
update again the blobs
tomip01 Nov 13, 2025
5fc7b15
fix latest block of the batch reconstruction
tomip01 Nov 13, 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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 20 additions & 2 deletions cmd/ethrex/build_l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ pub fn download_script() {
&Path::new("../../crates/l2/contracts/src/l2/L2Upgradeable.sol"),
"UpgradeableSystemContract",
),
(
&Path::new("../../crates/l2/contracts/src/l2/FeeTokenRegistry.sol"),
"FeeTokenRegistry",
),
];
for (path, name) in l2_contracts {
compile_contract_to_bytecode(
Expand Down Expand Up @@ -273,7 +277,8 @@ fn decode_to_bytecode(input_file_path: &Path, output_file_path: &Path) {

use ethrex_l2_sdk::{
COMMON_BRIDGE_L2_ADDRESS, CREATE2DEPLOYER_ADDRESS, DETERMINISTIC_DEPLOYMENT_PROXY_ADDRESS,
L2_TO_L1_MESSENGER_ADDRESS, SAFE_SINGLETON_FACTORY_ADDRESS, address_to_word, get_erc1967_slot,
FEE_TOKEN_REGISTRY_ADDRESS, L2_TO_L1_MESSENGER_ADDRESS, SAFE_SINGLETON_FACTORY_ADDRESS,
address_to_word, get_erc1967_slot,
};

#[allow(clippy::enum_variant_names)]
Expand Down Expand Up @@ -330,6 +335,12 @@ fn l2_to_l1_messenger_runtime(out_dir: &Path) -> Vec<u8> {
fs::read(path).expect("Failed to read bytecode file")
}

/// Bytecode of the FeeTokenRegistry contract.
fn fee_token_registry_runtime(out_dir: &Path) -> Vec<u8> {
let path = out_dir.join("contracts/solc_out/FeeTokenRegistry.bytecode");
fs::read(path).expect("Failed to read bytecode file")
}

/// Bytecode of the Create2Deployer contract.
fn create2deployer_runtime(out_dir: &Path) -> Vec<u8> {
let path = out_dir.join("contracts/solc_out/Create2Deployer.bytecode");
Expand Down Expand Up @@ -433,7 +444,14 @@ pub fn update_genesis_file(
out_dir,
)?;

for address in 0xff00..0xfffd {
add_with_proxy(
&mut genesis,
FEE_TOKEN_REGISTRY_ADDRESS,
fee_token_registry_runtime(out_dir),
out_dir,
)?;

for address in 0xff00..0xfffc {
add_placeholder_proxy(&mut genesis, Address::from_low_u64_be(address), out_dir)?;
}

Expand Down
89 changes: 88 additions & 1 deletion cmd/ethrex/l2/deployer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use ethrex_common::{
use ethrex_l2::utils::test_data_io::read_genesis_file;
use ethrex_l2_common::{calldata::Value, prover::ProverType, utils::get_address_from_secret_key};
use ethrex_l2_rpc::signer::{LocalSigner, Signer};
use ethrex_l2_sdk::register_fee_token;
use ethrex_l2_sdk::{
build_generic_tx, calldata::encode_calldata, create2_deploy_from_bytecode,
deploy_with_proxy_from_bytecode, initialize_contract, send_generic_transaction,
Expand Down Expand Up @@ -275,6 +276,16 @@ pub struct DeployerOptions {
help = "Address of the owner of the CommonBridge contract, who can upgrade the contract."
)]
pub bridge_owner: Address,
#[arg(
long,
value_name = "PRIVATE_KEY",
value_parser = parse_private_key,
env = "ETHREX_BRIDGE_OWNER_PK",
help_heading = "Deployer options",
help = "Private key of the owner of the CommonBridge contract. If set, the deployer will send a transaction to accept the ownership.",
requires = "bridge_owner"
)]
pub bridge_owner_pk: Option<SecretKey>,
#[arg(
long,
value_name = "PRIVATE_KEY",
Expand Down Expand Up @@ -336,6 +347,14 @@ pub struct DeployerOptions {
help = "Genesis data is extracted at compile time, used for development"
)]
pub use_compiled_genesis: bool,
#[arg(
long,
value_name = "ADDRESS",
env = "ETHREX_DEPLOYER_INITIAL_FEE_TOKEN",
help_heading = "Deployer options",
help = "This address will be registered as an initial fee token"
)]
pub initial_fee_token: Option<Address>,
}

impl Default for DeployerOptions {
Expand Down Expand Up @@ -396,13 +415,25 @@ impl Default for DeployerOptions {
0x44, 0x17, 0x09, 0x2b, 0x70, 0xa3, 0xe5, 0xf1, 0x0d, 0xc5, 0x04, 0xd0, 0x94, 0x7d,
0xd2, 0x56, 0xb9, 0x65, 0xfc, 0x62,
]),
// Private Key: 0x941e103320615d394a55708be13e45994c7d93b932b064dbcb2b511fe3254e2e
bridge_owner_pk: Some(
SecretKey::from_slice(
H256::from_str(
"941e103320615d394a55708be13e45994c7d93b932b064dbcb2b511fe3254e2e",
)
.expect("Bridge owner private key is a valid hex string")
.as_bytes(),
)
.expect("Bridge owner private key is valid"),
),
on_chain_proposer_owner_pk: None,
sp1_vk_path: None,
risc0_vk_path: None,
deploy_based_contracts: false,
sequencer_registry_owner: None,
inclusion_max_wait: 3000,
use_compiled_genesis: true,
initial_fee_token: None,
}
}
}
Expand Down Expand Up @@ -977,7 +1008,7 @@ async fn initialize_contracts(
info!("Initializing CommonBridge");
let initialize_tx_hash = {
let calldata_values = vec![
Value::Address(opts.bridge_owner),
Value::Address(initializer.address()),
Value::Address(contract_addresses.on_chain_proposer_address),
Value::Uint(opts.inclusion_max_wait.into()),
];
Expand All @@ -994,6 +1025,56 @@ async fn initialize_contracts(
};
info!(tx_hash = %format!("{initialize_tx_hash:#x}"), "CommonBridge initialized");

if let Some(fee_token) = opts.initial_fee_token {
register_fee_token(
eth_client,
contract_addresses.bridge_address,
fee_token,
initializer,
)
.await?;
info!(?fee_token, "CommonBridge initial fee token registered");
}

if opts.bridge_owner != initializer.address() {
let transfer_calldata = encode_calldata(
TRANSFER_OWNERSHIP_SIGNATURE,
&[Value::Address(opts.bridge_owner)],
)?;
let transfer_tx_hash = initialize_contract(
contract_addresses.bridge_address,
transfer_calldata,
initializer,
eth_client,
)
.await?;
if let Some(owner_pk) = opts.bridge_owner_pk {
let signer = Signer::Local(LocalSigner::new(owner_pk));
let accept_calldata = encode_calldata(ACCEPT_OWNERSHIP_SIGNATURE, &[])?;
let accept_tx = build_generic_tx(
eth_client,
TxType::EIP1559,
contract_addresses.bridge_address,
opts.bridge_owner,
accept_calldata.into(),
Overrides::default(),
)
.await?;
let accept_tx_hash = send_generic_transaction(eth_client, accept_tx, &signer).await?;
wait_for_transaction_receipt(accept_tx_hash, eth_client, 100).await?;
info!(
transfer_tx_hash = %format!("{transfer_tx_hash:#x}"),
accept_tx_hash = %format!("{accept_tx_hash:#x}"),
"CommonBridge ownership transferred and accepted"
);
} else {
info!(
transfer_tx_hash = %format!("{transfer_tx_hash:#x}"),
"CommonBridge ownership transfer pending acceptance"
);
}
}

trace!("Contracts initialized");
Ok(())
}
Expand Down Expand Up @@ -1031,6 +1112,8 @@ async fn make_deposits(
.map(|line| line.trim().to_string())
.collect();

let mut last_hash = None;

for pk in private_keys.iter() {
let secret_key = parse_private_key(pk).map_err(|_| {
DeployerError::DecodingError("Error while parsing private key".to_string())
Expand Down Expand Up @@ -1070,6 +1153,7 @@ async fn make_deposits(

match send_generic_transaction(eth_client, build, &signer).await {
Ok(hash) => {
last_hash = Some(hash);
info!(
address =? signer.address(),
?value_to_deposit,
Expand All @@ -1084,6 +1168,9 @@ async fn make_deposits(
}
}
trace!("Deposits finished");
if let Some(hash) = last_hash {
wait_for_transaction_receipt(hash, eth_client, 100).await?;
}
Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions crates/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,7 @@ impl Blockchain {
"Privileged Transactions are not supported in P2P".to_string(),
));
}
Transaction::FeeTokenTransaction(itx) => P2PTransaction::FeeTokenTransaction(itx),
};

Ok(result)
Expand Down
2 changes: 2 additions & 0 deletions crates/blockchain/metrics/metrics_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ impl MetricsTxType {
ethrex_common::types::TxType::EIP4844 => "EIP4844",
ethrex_common::types::TxType::EIP7702 => "EIP7702",
ethrex_common::types::TxType::Privileged => "Privileged",
ethrex_common::types::TxType::FeeToken => "FeeTokenTransaction",
}
}
pub fn all() -> Vec<String> {
Expand All @@ -172,6 +173,7 @@ impl MetricsTxType {
"EIP4844".to_string(),
"EIP7702".to_string(),
"Privileged".to_string(),
"FeeToken".to_string(),
]
}
}
2 changes: 2 additions & 0 deletions crates/common/types/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ impl ReceiptWithBloom {
0x2 => TxType::EIP1559,
0x3 => TxType::EIP4844,
0x4 => TxType::EIP7702,
0x7d => TxType::FeeToken,
0x7e => TxType::Privileged,
ty => {
return Err(RLPDecodeError::Custom(format!(
Expand Down Expand Up @@ -237,6 +238,7 @@ impl RLPDecode for ReceiptWithBloom {
0x2 => TxType::EIP1559,
0x3 => TxType::EIP4844,
0x4 => TxType::EIP7702,
0x7d => TxType::FeeToken,
0x7e => TxType::Privileged,
ty => {
return Err(RLPDecodeError::Custom(format!(
Expand Down
Loading