Skip to content

Commit bd30ee2

Browse files
committed
Support l1 -> l2 transactions
1 parent 9947071 commit bd30ee2

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

core/bin/zksync_server/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct Cli {
4444
/// Comma-separated list of components to launch.
4545
#[arg(
4646
long,
47-
default_value = "api,state_keeper"
47+
default_value = "api,eth,state_keeper"
4848
)]
4949
components: ComponentsToRun,
5050
/// Path to the yaml config. If set, it will be used instead of env vars.

core/lib/mempool/src/mempool_store.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,16 @@ impl MempoolStore {
154154
pub fn next_transaction(
155155
&mut self,
156156
filter: &L2TxFilter,
157-
) -> Option<(Transaction, TransactionTimeRangeConstraint)> { // todo: ignore prio txs for now
158-
// todo: priority transactions
157+
) -> Option<(Transaction, TransactionTimeRangeConstraint)> {
158+
if let Some(transaction) = self.l1_transactions.remove(&self.next_priority_id) {
159+
self.next_priority_id += 1;
160+
// L1 transactions can't use block.timestamp in AA and hence do not need to have a constraint
161+
return Some((
162+
transaction.into(),
163+
TransactionTimeRangeConstraint::default(),
164+
));
165+
}
166+
159167
let mut removed = 0;
160168
// We want to fetch the next transaction that would match the fee requirements.
161169
let tx_pointer = self

core/node/node_framework/src/implementations/layers/eth_watch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl WiringLayer for EthWatchLayer {
5959
let main_pool = input.master_pool.get().await?;
6060
let client = input.eth_client.0;
6161

62+
println!("{:?}", self.contracts_config);
6263
let eth_client = EthHttpQueryClient::new(
6364
client,
6465
self.contracts_config.diamond_proxy_addr,

core/node/zkos_vm_runner/src/zkos_conversions.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ impl From<Transaction> for TransactionData {
9292
U256::zero()
9393
};
9494

95-
// todo: second `reserved` value should be non-zero for deployment tx
96-
9795
// Ethereum transactions do not sign gas per pubdata limit, and so for them we need to use
9896
// some default value. We use the maximum possible value that is allowed by the bootloader
9997
// (i.e. we can not use u64::MAX, because the bootloader requires gas per pubdata for such
@@ -137,8 +135,32 @@ impl From<Transaction> for TransactionData {
137135
raw_bytes: execute_tx.raw_bytes.map(|a| a.0),
138136
}
139137
}
140-
ExecuteTransactionCommon::L1(_) => {
141-
unimplemented!("l1 transactions are not supported for zk os")
138+
ExecuteTransactionCommon::L1(common_data) => {
139+
// TODO: cleanup - double check gas fields, and sender, use constant for tx type
140+
TransactionData {
141+
tx_type: 255,
142+
from: common_data.sender,
143+
to: execute_tx.execute.contract_address,
144+
gas_limit: common_data.gas_limit,
145+
pubdata_price_limit: common_data.gas_per_pubdata_limit,
146+
max_fee_per_gas: common_data.max_fee_per_gas,
147+
max_priority_fee_per_gas: U256::zero(),
148+
paymaster: Address::zero(),
149+
nonce: U256::zero(),
150+
value: execute_tx.execute.value,
151+
reserved: [
152+
common_data.to_mint,
153+
U256::from_big_endian(common_data.refund_recipient.as_bytes()),
154+
U256::zero(),
155+
U256::zero(),
156+
],
157+
data: execute_tx.execute.calldata,
158+
signature: vec![],
159+
factory_deps: execute_tx.execute.factory_deps,
160+
paymaster_input: vec![],
161+
reserved_dynamic: vec![],
162+
raw_bytes: execute_tx.raw_bytes.map(|a| a.0),
163+
}
142164
}
143165
ExecuteTransactionCommon::ProtocolUpgrade(_) => {
144166
unreachable!()

0 commit comments

Comments
 (0)