Add validateServiceTransactionsTransition spec option
This commit is contained in:
parent
caa210107e
commit
b981f7beef
@ -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);
|
||||
}
|
||||
|
||||
|
@ -488,48 +488,50 @@ impl Importer {
|
||||
.epoch_transition(parent.number(), *header.parent_hash())
|
||||
.is_some();
|
||||
|
||||
// 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();
|
||||
if service_transaction_checker.is_some() {
|
||||
match service_transaction_checker.unwrap().refresh_cache(client) {
|
||||
Ok(true) => {
|
||||
trace!(target: "client", "Service transaction cache was refreshed successfully");
|
||||
}
|
||||
Ok(false) => {
|
||||
trace!(target: "client", "Registrar or/and service transactions contract does not exist");
|
||||
}
|
||||
Err(e) => {
|
||||
error!(target: "client", "Error occurred while refreshing service transaction cache: {}", e)
|
||||
}
|
||||
};
|
||||
};
|
||||
for t in &block.transactions {
|
||||
if t.has_zero_gas_price() {
|
||||
match self.miner.service_transaction_checker() {
|
||||
None => {
|
||||
let e = "Service transactions are not allowed. You need to enable Certifier contract.";
|
||||
warn!(target: "client", "Service tx checker error: {:?}", e);
|
||||
bail!(e);
|
||||
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();
|
||||
if service_transaction_checker.is_some() {
|
||||
match service_transaction_checker.unwrap().refresh_cache(client) {
|
||||
Ok(true) => {
|
||||
trace!(target: "client", "Service transaction cache was refreshed successfully");
|
||||
}
|
||||
Some(ref checker) => match checker.check(client, &t) {
|
||||
Ok(true) => {}
|
||||
Ok(false) => {
|
||||
let e = format!(
|
||||
"Service transactions are not allowed for the sender {:?}",
|
||||
t.sender()
|
||||
);
|
||||
warn!(target: "client", "Service tx checker error: {:?}", e);
|
||||
bail!(e);
|
||||
}
|
||||
Err(e) => {
|
||||
debug!(target: "client", "Unable to verify service transaction: {:?}", e);
|
||||
warn!(target: "client", "Service tx checker error: {:?}", e);
|
||||
bail!(e);
|
||||
}
|
||||
},
|
||||
}
|
||||
Ok(false) => {
|
||||
trace!(target: "client", "Registrar or/and service transactions contract does not exist");
|
||||
}
|
||||
Err(e) => {
|
||||
error!(target: "client", "Error occurred while refreshing service transaction cache: {}", e)
|
||||
}
|
||||
};
|
||||
};
|
||||
for t in &block.transactions {
|
||||
if t.has_zero_gas_price() {
|
||||
match self.miner.service_transaction_checker() {
|
||||
None => {
|
||||
let e = "Service transactions are not allowed. You need to enable Certifier contract.";
|
||||
warn!(target: "client", "Service tx checker error: {:?}", e);
|
||||
bail!(e);
|
||||
}
|
||||
Some(ref checker) => match checker.check(client, &t) {
|
||||
Ok(true) => {}
|
||||
Ok(false) => {
|
||||
let e = format!(
|
||||
"Service transactions are not allowed for the sender {:?}",
|
||||
t.sender()
|
||||
);
|
||||
warn!(target: "client", "Service tx checker error: {:?}", e);
|
||||
bail!(e);
|
||||
}
|
||||
Err(e) => {
|
||||
debug!(target: "client", "Unable to verify service transaction: {:?}", e);
|
||||
warn!(target: "client", "Service tx checker error: {:?}", e);
|
||||
bail!(e);
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// t_nb 8.0 Block enacting. Execution of transactions.
|
||||
|
@ -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 {
|
||||
|
@ -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)]
|
||||
|
Loading…
Reference in New Issue
Block a user