Skip to content
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
3 changes: 2 additions & 1 deletion z2/resources/chain-specs/zq2-mainnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ consensus.contract_upgrades = { deposit_v5 = { height = 0, reinitialise_params =
consensus.new_view_broadcast_interval = { secs = 30, nanos = 0 }

api_servers = [{ default_quota = { balance = 500, period = 1 }, port = 4201, enabled_apis = [{ namespace = "eth", apis = ["blockNumber"] }] }, { port = 4202, enabled_apis = ["admin", "debug", "erigon", "eth", "net", "ots", "trace", "txpool", "web3", "zilliqa"] }]
consensus.genesis_fork = { at_height = 0, executable_blocks = false, call_mode_1_sets_caller_to_parent_caller = true, failed_scilla_call_from_gas_exempt_caller_causes_revert = true, scilla_messages_can_call_evm_contracts = true, scilla_contract_creation_increments_account_balance = true, scilla_json_preserve_order = true, scilla_call_respects_evm_state_changes = true, only_mutated_accounts_update_state = true, scilla_call_gas_exempt_addrs = [], scilla_block_number_returns_current_block = true, scilla_maps_are_encoded_correctly = true, transfer_gas_fee_to_zero_account = true, apply_state_changes_only_if_transaction_succeeds = true, apply_scilla_delta_when_evm_succeeded = true, scilla_deduct_funds_from_actual_sender = true, fund_accounts_from_zero_account = [], scilla_delta_maps_are_applied_correctly = false, scilla_server_unlimited_response_size = false, scilla_failed_txn_correct_balance_deduction = false, scilla_transition_proper_order = false, evm_to_scilla_value_transfer_zero = false, restore_xsgd_contract = false, evm_exec_failure_causes_scilla_precompile_to_fail = false, revert_restore_xsgd_contract = false, scilla_fix_contract_code_removal_on_evm_tx = false, restore_ignite_wallet_contracts = false, prevent_zil_transfer_from_evm_to_scilla_contract = false, scilla_failed_txn_correct_gas_fee_charged = false, check_minimum_gas_price = false, inject_access_list = false, use_max_gas_priority_fee = false, failed_zil_transfers_to_eoa_proper_fee_deduction = false, validator_jailing = false, scilla_empty_maps_are_encoded_correctly = false }
consensus.genesis_fork = { at_height = 0, executable_blocks = false, call_mode_1_sets_caller_to_parent_caller = true, failed_scilla_call_from_gas_exempt_caller_causes_revert = true, scilla_messages_can_call_evm_contracts = true, scilla_contract_creation_increments_account_balance = true, scilla_json_preserve_order = true, scilla_call_respects_evm_state_changes = true, only_mutated_accounts_update_state = true, scilla_call_gas_exempt_addrs = [], scilla_block_number_returns_current_block = true, scilla_maps_are_encoded_correctly = true, transfer_gas_fee_to_zero_account = true, apply_state_changes_only_if_transaction_succeeds = true, apply_scilla_delta_when_evm_succeeded = true, scilla_deduct_funds_from_actual_sender = true, fund_accounts_from_zero_account = [], scilla_delta_maps_are_applied_correctly = false, scilla_server_unlimited_response_size = false, scilla_failed_txn_correct_balance_deduction = false, scilla_transition_proper_order = false, evm_to_scilla_value_transfer_zero = false, restore_xsgd_contract = false, evm_exec_failure_causes_scilla_precompile_to_fail = false, revert_restore_xsgd_contract = false, scilla_fix_contract_code_removal_on_evm_tx = false, restore_ignite_wallet_contracts = false, prevent_zil_transfer_from_evm_to_scilla_contract = false, scilla_failed_txn_correct_gas_fee_charged = false, check_minimum_gas_price = false, inject_access_list = false, use_max_gas_priority_fee = false, failed_zil_transfers_to_eoa_proper_fee_deduction = false, validator_jailing = false, scilla_empty_maps_are_encoded_correctly = false, cancun_active = false }
consensus.forks = [
{ at_height = 4770088, executable_blocks = true },
{ at_height = 4854500, scilla_delta_maps_are_applied_correctly = true },
Expand All @@ -38,4 +38,5 @@ consensus.forks = [
{ at_height = 10153271, failed_zil_transfers_to_eoa_proper_fee_deduction = true },
{ at_height = 13514400, validator_jailing = true },
{ at_height = 99999999, scilla_empty_maps_are_encoded_correctly = true },
{ at_height = 99999999, cancun_active = true },
]
6 changes: 4 additions & 2 deletions z2/resources/chain-specs/zq2-testnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ consensus.contract_upgrades = { deposit_v5 = { height = 0, reinitialise_params =
consensus.new_view_broadcast_interval = { secs = 30, nanos = 0 }

api_servers = [{ default_quota = { balance = 500, period = 1 }, port = 4201, enabled_apis = [{ namespace = "eth", apis = ["blockNumber"] }] }, { port = 4202, enabled_apis = ["admin", "debug", "erigon", "eth", "net", "ots", "trace", "txpool", "web3", "zilliqa"] }]
consensus.genesis_fork = { at_height = 0, executable_blocks = false, call_mode_1_sets_caller_to_parent_caller = true, failed_scilla_call_from_gas_exempt_caller_causes_revert = true, scilla_messages_can_call_evm_contracts = true, scilla_contract_creation_increments_account_balance = true, scilla_json_preserve_order = true, scilla_call_respects_evm_state_changes = true, only_mutated_accounts_update_state = true, scilla_call_gas_exempt_addrs = [], scilla_block_number_returns_current_block = true, scilla_maps_are_encoded_correctly = true, transfer_gas_fee_to_zero_account = true, apply_state_changes_only_if_transaction_succeeds = true, apply_scilla_delta_when_evm_succeeded = true, scilla_deduct_funds_from_actual_sender = true, fund_accounts_from_zero_account = [], scilla_delta_maps_are_applied_correctly = false, scilla_server_unlimited_response_size = false, scilla_failed_txn_correct_balance_deduction = false, scilla_transition_proper_order = false, evm_to_scilla_value_transfer_zero = false, restore_xsgd_contract = false, evm_exec_failure_causes_scilla_precompile_to_fail = false, revert_restore_xsgd_contract = false, scilla_fix_contract_code_removal_on_evm_tx = false, restore_ignite_wallet_contracts = false, prevent_zil_transfer_from_evm_to_scilla_contract = false, scilla_failed_txn_correct_gas_fee_charged = false, check_minimum_gas_price = false, inject_access_list = false, use_max_gas_priority_fee = false, failed_zil_transfers_to_eoa_proper_fee_deduction = false, validator_jailing = false, scilla_empty_maps_are_encoded_correctly = false }
consensus.genesis_fork = { at_height = 0, executable_blocks = false, call_mode_1_sets_caller_to_parent_caller = true, failed_scilla_call_from_gas_exempt_caller_causes_revert = true, scilla_messages_can_call_evm_contracts = true, scilla_contract_creation_increments_account_balance = true, scilla_json_preserve_order = true, scilla_call_respects_evm_state_changes = true, only_mutated_accounts_update_state = true, scilla_call_gas_exempt_addrs = [], scilla_block_number_returns_current_block = true, scilla_maps_are_encoded_correctly = true, transfer_gas_fee_to_zero_account = true, apply_state_changes_only_if_transaction_succeeds = true, apply_scilla_delta_when_evm_succeeded = true, scilla_deduct_funds_from_actual_sender = true, fund_accounts_from_zero_account = [], scilla_delta_maps_are_applied_correctly = false, scilla_server_unlimited_response_size = false, scilla_failed_txn_correct_balance_deduction = false, scilla_transition_proper_order = false, evm_to_scilla_value_transfer_zero = false, restore_xsgd_contract = false, evm_exec_failure_causes_scilla_precompile_to_fail = false, revert_restore_xsgd_contract = false, scilla_fix_contract_code_removal_on_evm_tx = false, restore_ignite_wallet_contracts = false, prevent_zil_transfer_from_evm_to_scilla_contract = false, scilla_failed_txn_correct_gas_fee_charged = false, check_minimum_gas_price = false, inject_access_list = false, use_max_gas_priority_fee = false, failed_zil_transfers_to_eoa_proper_fee_deduction = false, validator_jailing = false, scilla_empty_maps_are_encoded_correctly = false, cancun_active = false }
consensus.forks = [
{ at_height = 8099088, executable_blocks = true },
{ at_height = 8371376, scilla_delta_maps_are_applied_correctly = true },
Expand All @@ -90,5 +90,7 @@ consensus.forks = [
{ at_height = 11300000, inject_access_list = true, use_max_gas_priority_fee = true },
{ at_height = 12998790, failed_zil_transfers_to_eoa_proper_fee_deduction = true },
{ at_height = 14997600, validator_jailing = true },
{ at_height = 99999999, scilla_empty_maps_are_encoded_correctly = true },
{ at_height = 23080419, scilla_empty_maps_are_encoded_correctly = true },
{ at_height = 23080419, cancun_active = true },

]
10 changes: 8 additions & 2 deletions z2/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl Chain {
"failed_zil_transfers_to_eoa_proper_fee_deduction": false,
"validator_jailing": false,
"scilla_empty_maps_are_encoded_correctly": false,
"cancun_active": false,
})),
Chain::Zq2Mainnet => Some(json!({
"at_height": 0,
Expand Down Expand Up @@ -218,6 +219,7 @@ impl Chain {
"failed_zil_transfers_to_eoa_proper_fee_deduction": false,
"validator_jailing": false,
"scilla_empty_maps_are_encoded_correctly": false,
"cancun_active": false,
})),
_ => None,
}
Expand Down Expand Up @@ -265,8 +267,10 @@ impl Chain {
json!({ "at_height": 12998790, "failed_zil_transfers_to_eoa_proper_fee_deduction": true}),
// estimated: 2025-09-19T12.00.00Z
json!({ "at_height": 14997600, "validator_jailing": true}),
// estimated: arbitrary high block number no reachable before next fork
json!({ "at_height": 99999999, "scilla_empty_maps_are_encoded_correctly": true}),
// estimated: 2026-01-07T11.00.00Z
json!({ "at_height": 23080419, "scilla_empty_maps_are_encoded_correctly": true}),
// estimated: 2026-01-07T11.00.00Z
json!({ "at_height": 23080419, "cancun_active": true}),
]),
Chain::Zq2Mainnet => Some(vec![
json!({ "at_height": 4770088, "executable_blocks": true }),
Expand Down Expand Up @@ -313,6 +317,8 @@ impl Chain {
json!({ "at_height": 13514400, "validator_jailing": true}),
// estimated: arbitrary high block number no reachable before next fork
json!({ "at_height": 99999999, "scilla_empty_maps_are_encoded_correctly": true}),
// estimated: arbitrary high block number no reachable before next fork
json!({ "at_height": 99999999, "cancun_active": true}),
]),
_ => None,
}
Expand Down
13 changes: 13 additions & 0 deletions zilliqa/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ pub struct Fork {
pub failed_zil_transfers_to_eoa_proper_fee_deduction: bool,
pub validator_jailing: bool,
pub scilla_empty_maps_are_encoded_correctly: bool,
pub cancun_active: bool,
}

pub enum ForkName {
Expand Down Expand Up @@ -908,6 +909,8 @@ pub struct ForkDelta {
pub validator_jailing: Option<bool>,
/// if true, empty scilla maps having no presence in state are encoded as empty maps, not empty values
pub scilla_empty_maps_are_encoded_correctly: Option<bool>,
/// if true, cancun is activated in evm
pub cancun_active: Option<bool>,
}

impl Fork {
Expand Down Expand Up @@ -1013,6 +1016,7 @@ impl Fork {
scilla_empty_maps_are_encoded_correctly: delta
.scilla_empty_maps_are_encoded_correctly
.unwrap_or(self.scilla_empty_maps_are_encoded_correctly),
cancun_active: delta.cancun_active.unwrap_or(self.cancun_active),
}
}
}
Expand Down Expand Up @@ -1115,6 +1119,7 @@ pub fn genesis_fork_default() -> Fork {
failed_zil_transfers_to_eoa_proper_fee_deduction: true,
validator_jailing: true,
scilla_empty_maps_are_encoded_correctly: true,
cancun_active: true,
}
}

Expand Down Expand Up @@ -1283,6 +1288,7 @@ mod tests {
failed_zil_transfers_to_eoa_proper_fee_deduction: None,
validator_jailing: None,
scilla_empty_maps_are_encoded_correctly: None,
cancun_active: None,
}],
..Default::default()
};
Expand Down Expand Up @@ -1340,6 +1346,7 @@ mod tests {
failed_zil_transfers_to_eoa_proper_fee_deduction: None,
validator_jailing: Some(false),
scilla_empty_maps_are_encoded_correctly: Some(false),
cancun_active: Some(false),
},
ForkDelta {
at_height: 20,
Expand Down Expand Up @@ -1377,6 +1384,7 @@ mod tests {
failed_zil_transfers_to_eoa_proper_fee_deduction: None,
validator_jailing: None,
scilla_empty_maps_are_encoded_correctly: None,
cancun_active: None,
},
],
..Default::default()
Expand Down Expand Up @@ -1451,6 +1459,7 @@ mod tests {
failed_zil_transfers_to_eoa_proper_fee_deduction: None,
validator_jailing: None,
scilla_empty_maps_are_encoded_correctly: None,
cancun_active: None,
},
ForkDelta {
at_height: 10,
Expand Down Expand Up @@ -1488,6 +1497,7 @@ mod tests {
failed_zil_transfers_to_eoa_proper_fee_deduction: None,
validator_jailing: None,
scilla_empty_maps_are_encoded_correctly: None,
cancun_active: None,
},
],
..Default::default()
Expand Down Expand Up @@ -1550,6 +1560,7 @@ mod tests {
failed_zil_transfers_to_eoa_proper_fee_deduction: true,
validator_jailing: true,
scilla_empty_maps_are_encoded_correctly: true,
cancun_active: true,
},
forks: vec![],
..Default::default()
Expand Down Expand Up @@ -1600,6 +1611,7 @@ mod tests {
failed_zil_transfers_to_eoa_proper_fee_deduction: None,
validator_jailing: None,
scilla_empty_maps_are_encoded_correctly: None,
cancun_active: None,
},
ForkDelta {
at_height: 20,
Expand Down Expand Up @@ -1637,6 +1649,7 @@ mod tests {
failed_zil_transfers_to_eoa_proper_fee_deduction: None,
validator_jailing: None,
scilla_empty_maps_are_encoded_correctly: None,
cancun_active: None,
},
],
..Default::default()
Expand Down
7 changes: 4 additions & 3 deletions zilliqa/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ use crate::{
precompiles::ZQ2PrecompileProvider,
};

pub(crate) const SPEC_ID: SpecId = SpecId::SHANGHAI;
pub(crate) const SPEC_ID_SHANGHAI: SpecId = SpecId::SHANGHAI;
pub(crate) const SPEC_ID_CANCUN: SpecId = SpecId::CANCUN;
pub type ZQ2EvmContext =
Context<BlockEnv, TxEnv, CfgEnv, PendingState, Journal<PendingState>, ExternalContext>;
pub(crate) fn new_zq2_evm_ctx(db: PendingState, chain: ExternalContext) -> ZQ2EvmContext {
let ctx: Context<BlockEnv, TxEnv, CfgEnv, PendingState, Journal<PendingState>> =
Context::new(db, SPEC_ID);
Context::new(db, chain.spec_id);
ctx.with_chain(chain)
}

Expand All @@ -49,7 +50,7 @@ impl<I: Inspector<ZQ2EvmContext>> ZQ2Evm<I> {
let mut precompiles = ZQ2PrecompileProvider::new();
<ZQ2PrecompileProvider as PrecompileProvider<ZQ2EvmContext>>::set_spec(
&mut precompiles,
SPEC_ID,
ctx.chain.spec_id,
);
ZQ2Evm(Evm {
ctx,
Expand Down
26 changes: 21 additions & 5 deletions zilliqa/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ use revm::{
BlockEnv, CfgEnv,
result::{ExecutionResult, HaltReason, Output, ResultAndState},
},
context_interface::{DBErrorMarker, TransactionType, transaction::AccessList},
context_interface::{
DBErrorMarker, TransactionType, block::BlobExcessGasAndPrice, transaction::AccessList,
},
handler::EvmTr,
primitives::{B256, KECCAK_EMPTY},
primitives::{B256, KECCAK_EMPTY, eip4844::MIN_BLOB_GASPRICE, hardfork::SpecId},
state::{AccountInfo, Bytecode, EvmState},
};
use revm_context::{ContextTr, TxEnv};
Expand All @@ -39,7 +41,7 @@ use crate::{
constants, contracts,
crypto::{Hash, NodePublicKey},
error::ensure_success,
evm::{SPEC_ID, ZQ2Evm, ZQ2EvmContext, new_zq2_evm_ctx},
evm::{SPEC_ID_CANCUN, SPEC_ID_SHANGHAI, ZQ2Evm, ZQ2EvmContext, new_zq2_evm_ctx},
inspector::{self, ScillaInspector, TouchedAddressInspector},
message::{Block, BlockHeader},
precompiles::{PENALTY_ADDRESS, SCILLA_CALL_ADDRESS, ViewHistory},
Expand Down Expand Up @@ -446,6 +448,7 @@ pub struct ExternalContext {
pub has_called_scilla_precompile: bool,
pub finalized_view: u64,
pub view_history: Arc<RwLock<ViewHistory>>,
pub spec_id: SpecId,
}

pub enum BaseFeeAndNonceCheck {
Expand Down Expand Up @@ -564,6 +567,18 @@ impl State {
} else {
(self.view_history.clone(), self.finalized_view)
};

let (spec_id, blob_excess_gas_and_price) = {
if fork.cancun_active {
(
SPEC_ID_CANCUN,
Some(BlobExcessGasAndPrice::new(0, MIN_BLOB_GASPRICE)),
)
} else {
(SPEC_ID_SHANGHAI, None)
}
};

let external_context = ExternalContext {
touched_address_inspector: TouchedAddressInspector::default(),
fork: fork.clone(),
Expand All @@ -573,6 +588,7 @@ impl State {
has_called_scilla_precompile: false,
finalized_view,
view_history,
spec_id,
};

let (tx_type, access_list, gas_priority_fee) = {
Expand Down Expand Up @@ -603,7 +619,7 @@ impl State {

let evm_ctx = new_zq2_evm_ctx(pending_state, external_context)
.with_cfg({
let mut cfg = CfgEnv::new_with_spec(SPEC_ID);
let mut cfg = CfgEnv::new_with_spec(spec_id);
cfg.disable_eip3607 = extra_opts.disable_eip3607;
cfg.chain_id = self.chain_id.eth;
cfg.disable_base_fee = match base_fee_and_nonce_check {
Expand All @@ -629,7 +645,7 @@ impl State {
basefee: self.gas_price.try_into()?,
difficulty: U256::from(1),
prevrandao: Some(Hash::builder().with(padded_view_number).finalize().into()),
blob_excess_gas_and_price: None,
blob_excess_gas_and_price,
beneficiary: Default::default(),
});

Expand Down
Loading