1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! System transaction for the `MegaETH` EVM.
//!
//! The mega system transaction is a special protocol-maintenance transaction with minimal
//! side effects:
//! - no transaction fee (no L2 gas fee, no L1 data fee, no base fee, etc.), thus no state change to
//! the block beneficiary or any fee vaults.
//! - system address's nonce still bumps as normal transactions
//!
//! This module contains constants, types, and utilities related to mega system transactions.
use ;
use DEPOSIT_TRANSACTION_TYPE;
use Transaction;
use crate::;
/// The `MegaETH` system address for deposit-like transaction processing.
/// Normal transactions sent from this address are processed as deposit transactions,
/// bypassing signature validation, nonce verification, and fee deduction.
///
/// It can only call whitelisted addresses.
pub const MEGA_SYSTEM_ADDRESS: Address = address!;
/// The whitelist of addresses that are allowed to be called by the `MegaETH` system address.
pub const MEGA_SYSTEM_TX_WHITELIST: & = &;
/// The source hash of the `MegaETH` system transaction, used to set the `source_hash` field of the
/// op deposit info. The value is `keccak256("MEGA_SYSTEM_TRANSACTION")`.
pub const MEGA_SYSTEM_TRANSACTION_SOURCE_HASH: B256 =
b256!;
/// The source hash of the `MegaETH` keyless-deploy sandbox transaction. Used to set the
/// `source_hash` field of the op deposit info so the sandbox tx is treated as a deposit-like
/// transaction (bypasses L1/operator fee, validation, fee distribution). The value is
/// `keccak256("MEGA_SANDBOX_TRANSACTION")`.
pub const SANDBOX_TX_SOURCE_HASH: B256 =
b256!;
/// Checks if a transaction is sent from the given system address.
/// Checks if a transaction is a mega system transaction using the given system address.
/// A mega system transaction is a legacy transaction that is submitted by the system address
/// and calls a whitelisted address in `MEGA_SYSTEM_TX_WHITELIST`.
/// Checks if a transaction is a mega system transaction.
///
/// # Arguments
///
/// * `tx_signer` - The signer of the transaction
/// * `tx_type` - The type of the transaction
/// * `tx_kind` - The kind of the transaction
/// * `system_address` - The current system address for this block
///
/// # Returns
///
/// Returns `true` if the transaction is a mega system transaction, `false` otherwise.
/// Checks if a transaction should be processed as a deposit-like transaction.
///
/// This includes both actual deposit transactions (`DEPOSIT_TRANSACTION_TYPE`) and normal
/// transactions from the `MegaETH` system address (mega system transactions).
///
/// # Arguments
///
/// * `tx` - The transaction to check
///
/// # Returns
///
/// Returns `true` if the transaction should be processed as deposit-like, `false` otherwise.