Add validateServiceTransactionsTransition spec option

This commit is contained in:
POA 2021-11-12 13:06:19 +03:00
parent caa210107e
commit b981f7beef
4 changed files with 51 additions and 41 deletions

View File

@ -45,7 +45,7 @@ impl ServiceTransactionChecker {
) -> Result<bool, String> {
let sender = tx.sender();
// Skip checking the contract if the transaction does not have zero gas price
if !tx.tx().gas_price.is_zero() {
if !tx.has_zero_gas_price() {
return Ok(false);
}

View File

@ -488,6 +488,7 @@ impl Importer {
.epoch_transition(parent.number(), *header.parent_hash())
.is_some();
if header.number() >= engine.params().validate_service_transactions_transition {
// Check if zero gas price transactions are certified to be service transactions
// using the Certifier contract. If they are not certified, the block is treated as invalid.
let service_transaction_checker = self.miner.service_transaction_checker();
@ -531,6 +532,7 @@ impl Importer {
}
};
}
}
// t_nb 8.0 Block enacting. Execution of transactions.
let enact_result = enact_verified(

View File

@ -191,6 +191,8 @@ pub struct CommonParams {
pub eip1559_fee_collector: Option<Address>,
/// Block at which the fee collector should start being used.
pub eip1559_fee_collector_transition: BlockNumber,
/// Block at which zero gas price transactions start being checked with Certifier contract.
pub validate_service_transactions_transition: BlockNumber,
}
impl CommonParams {
@ -475,6 +477,9 @@ impl From<ethjson::spec::Params> for CommonParams {
eip1559_fee_collector_transition: p
.eip1559_fee_collector_transition
.map_or_else(BlockNumber::max_value, Into::into),
validate_service_transactions_transition: p
.validate_service_transactions_transition
.map_or_else(BlockNumber::max_value, Into::into),
}
}
}
@ -752,6 +757,7 @@ impl Spec {
params.transaction_permission_contract_transition,
params.eip1559_fee_collector_transition,
params.eip1559_base_fee_min_value_transition,
params.validate_service_transactions_transition,
];
// BUG: Rinkeby has homestead transition at block 1 but we can't reflect that in specs for non-Ethash networks
if params.network_id == 0x4 {

View File

@ -166,6 +166,8 @@ pub struct Params {
pub eip1559_fee_collector: Option<Address>,
/// Block at which the fee collector should start being used.
pub eip1559_fee_collector_transition: Option<Uint>,
/// Block at which zero gas price transactions start being checked with Certifier contract.
pub validate_service_transactions_transition: Option<Uint>,
}
#[cfg(test)]