Skip to content
2 changes: 1 addition & 1 deletion z2/resources/chain-specs/zq2-devnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ consensus.minimum_stake = "10_000_000_000_000_000_000_000_000"
# Gas parameters
consensus.eth_block_gas_limit = 84000000
consensus.gas_price = "4_761_904_800_000"
consensus.contract_upgrades = { deposit_v5 = { height = 0, reinitialise_params = { withdrawal_period = 300 } }, deposit_v6 = { height = 0 }, deposit_v7 = { height = 0 } }
consensus.contract_upgrades = { deposit_v5 = { height = 0, reinitialise_params = { withdrawal_period = 300 } }, deposit_v6 = { height = 0 }, deposit_v7 = { height = 0 }, deposit_v8 = { height = 0 } }
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"] }]
5 changes: 3 additions & 2 deletions z2/resources/chain-specs/zq2-mainnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ consensus.minimum_stake = "10_000_000_000_000_000_000_000_000"
# Gas parameters
consensus.eth_block_gas_limit = 84000000
consensus.gas_price = "4_761_904_800_000"
consensus.contract_upgrades = { deposit_v5 = { height = 0, reinitialise_params = { withdrawal_period = 1209600 } }, deposit_v6 = { height = 13514400 }, deposit_v7 = { height = 13514400, reinitialise_params = { withdrawal_period = 461680 } } }
consensus.contract_upgrades = { deposit_v5 = { height = 0, reinitialise_params = { withdrawal_period = 1209600 } }, deposit_v6 = { height = 13514400 }, deposit_v7 = { height = 13514400, reinitialise_params = { withdrawal_period = 461680 } }, deposit_v8 = { height = 99999999, reinitialise_params = { withdrawal_period = 461680 } } }
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, cancun_active = 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, randao_support = false }
consensus.forks = [
{ at_height = 4770088, executable_blocks = true },
{ at_height = 4854500, scilla_delta_maps_are_applied_correctly = true },
Expand All @@ -39,4 +39,5 @@ consensus.forks = [
{ at_height = 13514400, validator_jailing = true },
{ at_height = 99999999, scilla_empty_maps_are_encoded_correctly = true },
{ at_height = 99999999, cancun_active = true },
{ at_height = 99999999, randao_support = true },
]
6 changes: 3 additions & 3 deletions z2/resources/chain-specs/zq2-testnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ consensus.minimum_stake = "10_000_000_000_000_000_000_000_000"
# Gas parameters
consensus.eth_block_gas_limit = 84000000
consensus.gas_price = "4_761_904_800_000"
consensus.contract_upgrades = { deposit_v5 = { height = 0, reinitialise_params = { withdrawal_period = 1209600 } }, deposit_v6 = { height = 14997600 }, deposit_v7 = { height = 17010000, reinitialise_params = { withdrawal_period = 461680 } } }
consensus.contract_upgrades = { deposit_v5 = { height = 0, reinitialise_params = { withdrawal_period = 1209600 } }, deposit_v6 = { height = 14997600 }, deposit_v7 = { height = 17010000, reinitialise_params = { withdrawal_period = 461680 } }, deposit_v8 = { height = 99999999, reinitialise_params = { withdrawal_period = 461680 } } }
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, cancun_active = 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, randao_support = false }
consensus.forks = [
{ at_height = 8099088, executable_blocks = true },
{ at_height = 8371376, scilla_delta_maps_are_applied_correctly = true },
Expand All @@ -92,5 +92,5 @@ consensus.forks = [
{ at_height = 14997600, validator_jailing = true },
{ at_height = 23685219, scilla_empty_maps_are_encoded_correctly = true },
{ at_height = 23685219, cancun_active = true },

{ at_height = 99999999, randao_support = true },
]
22 changes: 22 additions & 0 deletions z2/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ impl Chain {
height: 0,
reinitialise_params: None,
}),
deposit_v8: Some(ContractUpgradeConfig {
height: 0,
reinitialise_params: None,
}),
},
Self::Zq2Testnet => ContractUpgrades {
deposit_v3: None,
Expand All @@ -119,6 +123,12 @@ impl Chain {
withdrawal_period: 461680,
}), // https://github.com/Zilliqa/zq2/pull/3221
}),
deposit_v8: Some(ContractUpgradeConfig {
height: 99999999,
reinitialise_params: Some(ReinitialiseParams {
withdrawal_period: 461680,
}),
}),
},
Self::Zq2Mainnet => ContractUpgrades {
deposit_v3: None,
Expand All @@ -137,6 +147,12 @@ impl Chain {
withdrawal_period: 461680,
}), // https://github.com/Zilliqa/zq2/pull/3221
}),
deposit_v8: Some(ContractUpgradeConfig {
height: 99999999,
reinitialise_params: Some(ReinitialiseParams {
withdrawal_period: 461680,
}),
}),
},
_ => ContractUpgrades::default(),
}
Expand Down Expand Up @@ -182,6 +198,7 @@ impl Chain {
"validator_jailing": false,
"scilla_empty_maps_are_encoded_correctly": false,
"cancun_active": false,
"randao_support": false,
})),
Chain::Zq2Mainnet => Some(json!({
"at_height": 0,
Expand Down Expand Up @@ -220,6 +237,7 @@ impl Chain {
"validator_jailing": false,
"scilla_empty_maps_are_encoded_correctly": false,
"cancun_active": false,
"randao_support": false,
})),
_ => None,
}
Expand Down Expand Up @@ -271,6 +289,8 @@ impl Chain {
json!({ "at_height": 23685219, "scilla_empty_maps_are_encoded_correctly": true}),
// estimated: 2026-01-14T11.00.00Z
json!({ "at_height": 23685219, "cancun_active": true}),
// estimated: arbitrary high block number no reachable before next fork
json!({ "at_height": 99999999, "randao_support": true}),
]),
Chain::Zq2Mainnet => Some(vec![
json!({ "at_height": 4770088, "executable_blocks": true }),
Expand Down Expand Up @@ -319,6 +339,8 @@ impl Chain {
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}),
// estimated: arbitrary high block number no reachable before next fork
json!({ "at_height": 99999999, "randao_support": true}),
]),
_ => None,
}
Expand Down
4 changes: 4 additions & 0 deletions z2/src/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ pub async fn convert_persistence(
SystemTime::UNIX_EPOCH + Duration::from_micros(zq1_block.timestamp),
ScillaGas(zq1_block.gas_used).into(),
ScillaGas(zq1_block.gas_limit).into(),
None,
None,
);

// For each receipt update block hash. This can be done once all receipts build receipt_root_hash which is used for calculating block hash
Expand Down Expand Up @@ -651,6 +653,8 @@ fn create_empty_block_from_parent(
parent_block.header.timestamp,
parent_block.header.gas_used,
parent_block.header.gas_limit,
None,
None,
)
}

Expand Down
4 changes: 2 additions & 2 deletions z2/src/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ impl SignerClient {
pub async fn get_future_stake(&self, public_key: &NodePublicKey) -> Result<u128> {
let client = self.get_signer().await?;

let data = contracts::deposit_v7::GET_FUTURE_STAKE
let data = contracts::deposit_v8::GET_FUTURE_STAKE
.encode_input(&[Token::Bytes(public_key.as_bytes())])
.unwrap();
let tx = TransactionRequest::default()
.to(contract_addr::DEPOSIT_PROXY)
.input(TransactionInput::both(data.into()));
let output = client.call(tx).await.unwrap();

let future_stake = contracts::deposit_v7::GET_FUTURE_STAKE
let future_stake = contracts::deposit_v8::GET_FUTURE_STAKE
.decode_output(&output)
.unwrap()[0]
.clone()
Expand Down
2 changes: 2 additions & 0 deletions zilliqa/benches/it.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ fn process_empty(c: &mut Criterion) {
SystemTime::UNIX_EPOCH,
EvmGas(0),
EvmGas(0),
None,
None,
);
parent_hash = block.hash();

Expand Down
20 changes: 17 additions & 3 deletions zilliqa/src/api/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,21 @@ fn debug_trace_transaction(params: Params, node: &Arc<Node>) -> Result<TraceResu
.position(|&h| h == txn_hash)
.ok_or_else(|| anyhow!("transaction not found in specified block"))?;

let randao_mix_hash = parent.header.mix_hash.unwrap_or(Hash::ZERO);

// Apply all transactions before the target transaction
for &prev_tx_hash in &block.transactions[0..txn_index] {
let prev_tx = node
.get_transaction_by_hash(prev_tx_hash)?
.ok_or_else(|| anyhow!("transaction not found: {prev_tx_hash}"))?;

state.apply_transaction(prev_tx, block.header, inspector::noop(), false)?;
state.apply_transaction(
prev_tx,
block.header,
randao_mix_hash,
inspector::noop(),
false,
)?;
}

// Get the target transaction
Expand All @@ -160,8 +168,14 @@ fn debug_trace_transaction(params: Params, node: &Arc<Node>) -> Result<TraceResu
let trace_opts = trace_opts.unwrap_or_default();

// Debug trace the transaction
let trace_result =
node.debug_trace_transaction(&mut state, txn_hash, txn_index, &block, trace_opts)?;
let trace_result = node.debug_trace_transaction(
&mut state,
txn_hash,
txn_index,
&block,
randao_mix_hash,
trace_opts,
)?;

trace_result.ok_or_else(|| anyhow!("Failed to trace transaction"))
}
9 changes: 7 additions & 2 deletions zilliqa/src/api/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,19 @@ fn estimate_gas(params: Params, node: &Arc<Node>) -> Result<String> {
let block_number: BlockNumberOrTag = params.optional_next()?.unwrap_or_default();
expect_end_of_params(&mut params, 1, 2)?;

let (block, state) = {
let (block, parent, state) = {
let block = node
.get_block(block_number)?
.ok_or_else(|| anyhow!("missing block: {block_number}"))?;
let parent = node
.get_block(block.parent_hash())?
.ok_or_else(|| anyhow!("missing parent block"))?;

let state = node.get_state(&block)?;
if state.is_empty() {
return Err(anyhow!("State required to execute request does not exist"));
}
(block, state)
(block, parent, state)
};

let return_value = state.estimate_gas(
Expand All @@ -329,6 +333,7 @@ fn estimate_gas(params: Params, node: &Arc<Node>) -> Result<String> {
tx_type: call_params.transaction_type.unwrap_or_default().into(),
disable_eip3607: true,
exec_type: Estimate,
randao_mix_hash: parent.header.mix_hash.unwrap_or(Hash::ZERO),
},
)?;

Expand Down
15 changes: 13 additions & 2 deletions zilliqa/src/api/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ fn trace_block(params: Params, node: &Arc<Node>) -> Result<Vec<TraceResults>> {

let mut traces = Vec::new();

let randao_mix_hash = parent.header.mix_hash.unwrap_or(Hash::ZERO);

// Process each transaction
for &txn_hash in block.transactions.iter() {
let txn = node
Expand All @@ -93,7 +95,8 @@ fn trace_block(params: Params, node: &Arc<Node>) -> Result<Vec<TraceResults>> {
let pre_state = PendingState::new(state.try_clone()?, fork.clone());

// Apply the transaction
let result = state.apply_transaction(txn, block.header, &mut inspector, true)?;
let result =
state.apply_transaction(txn, block.header, randao_mix_hash, &mut inspector, true)?;

// Build trace results
if let TransactionApplyResult::Evm(result, ..) = result {
Expand Down Expand Up @@ -184,6 +187,8 @@ fn trace_filter(params: Params, node: &Arc<Node>) -> Result<Vec<TraceResults>> {

let fork = state.forks.get(block.number()).clone();

let randao_mix_hash = parent.header.mix_hash.unwrap_or(Hash::ZERO);

// Process each transaction in the block
for txn_hash in &block.transactions {
let txn = match node.get_transaction_by_hash(*txn_hash)? {
Expand Down Expand Up @@ -226,7 +231,13 @@ fn trace_filter(params: Params, node: &Arc<Node>) -> Result<Vec<TraceResults>> {
let mut inspector = TracingInspector::new(config);
let pending_state = PendingState::new(state.try_clone()?, fork.clone());

let result = state.apply_transaction(txn, block.header, &mut inspector, true)?;
let result = state.apply_transaction(
txn,
block.header,
randao_mix_hash,
&mut inspector,
true,
)?;

// Only include EVM transaction traces
if let TransactionApplyResult::Evm(result, ..) = result {
Expand Down
Loading
Loading