complete null-signatures removal (#11491)

* complete null-signatures removal

* unsigned transactions are disallowed by the type system

* "fix" verification test

* machine: bring the test back

* machine: simplify the test
This commit is contained in:
Andronik Ordian
2020-02-15 13:26:08 +01:00
committed by GitHub
parent 856a075588
commit a4aef98acd
6 changed files with 9 additions and 51 deletions

View File

@@ -851,7 +851,7 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
return Err(ExecutionError::NotEnoughBaseGas { required: base_gas_required, got: t.gas });
}
if !t.is_unsigned() && check_nonce && schedule.kill_dust != CleanDustMode::Off && !self.state.exists(&sender)? {
if check_nonce && schedule.kill_dust != CleanDustMode::Off && !self.state.exists(&sender)? {
return Err(ExecutionError::SenderMustExist);
}
@@ -884,10 +884,8 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
let mut substate = Substate::new();
// NOTE: there can be no invalid transactions from this point.
if !schedule.keep_unsigned_nonce || !t.is_unsigned() {
self.state.inc_nonce(&sender)?;
}
self.state.inc_nonce(&sender)?;
self.state.sub_balance(
&sender,
&U256::try_from(gas_cost).expect("Total cost (value + gas_cost) is lower than max allowed balance (U256); gas_cost has to fit U256; qed"),

View File

@@ -24,7 +24,6 @@ use log::{debug, trace, warn};
use account_state::{Backend as StateBackend, State, CleanupMode};
use common_types::{
transaction::UNSIGNED_SENDER,
log_entry::LogEntry,
};
use trace::{Tracer, VMTracer};
@@ -265,11 +264,9 @@ impl<'a, T: 'a, V: 'a, B: 'a> Ext for Externalities<'a, T, V, B>
};
if !self.static_flag {
if !self.schedule.keep_unsigned_nonce || params.sender != UNSIGNED_SENDER {
if let Err(e) = self.state.inc_nonce(&self.origin_info.address) {
debug!(target: "ext", "Database corruption encountered: {:?}", e);
return Ok(ContractCreateResult::Failed)
}
if let Err(e) = self.state.inc_nonce(&self.origin_info.address) {
warn!(target: "ext", "Database corruption encountered: {:?}", e);
return Ok(ContractCreateResult::Failed)
}
}

View File

@@ -423,19 +423,10 @@ mod tests {
fn should_disallow_unsigned_transactions() {
let rlp = "ea80843b9aca0083015f90948921ebb5f79e9e3920abe571004d0b1d5119c154865af3107a400080038080";
let transaction: UnverifiedTransaction = ::rlp::decode(&::rustc_hex::FromHex::from_hex(rlp).unwrap()).unwrap();
let spec = spec::new_ropsten_test();
let ethparams = get_default_ethash_extensions();
let machine = Machine::with_ethash_extensions(
spec.params().clone(),
Default::default(),
ethparams,
assert_eq!(
transaction::Error::from(transaction.verify_unordered().unwrap_err()),
transaction::Error::InvalidSignature("invalid EC signature".into()),
);
let mut header = Header::new();
header.set_number(15);
let res = machine.verify_transaction_basic(&transaction, &header);
assert_eq!(res, Err(transaction::Error::InvalidSignature("invalid EC signature".into())));
}
#[test]