Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
POA | 6e06824c23 | |
Rim Rakhimov | 43d6da6b52 | |
Rim Rakhimov | 412d797a3b | |
Rim Rakhimov | 63bab44e3c | |
Rim Rakhimov | f703d01f23 | |
POA | f13fa10b8a |
18
CHANGELOG.md
18
CHANGELOG.md
|
@ -1,3 +1,21 @@
|
|||
## OpenEthereum v3.3.3
|
||||
|
||||
Enhancements:
|
||||
* Implement eip-3607 (#593)
|
||||
|
||||
Bug fixes:
|
||||
* Add type field for legacy transactions in RPC calls (#580)
|
||||
* Makes eth_mining to return False if not is not allowed to seal (#581)
|
||||
* Made nodes data concatenate as RLP sequences instead of bytes (#598)
|
||||
|
||||
## OpenEthereum v3.3.2
|
||||
|
||||
Enhancements:
|
||||
* London hardfork block: Sokol (24114400)
|
||||
|
||||
Bug fixes:
|
||||
* Fix for maxPriorityFeePerGas overflow
|
||||
|
||||
## OpenEthereum v3.3.1
|
||||
|
||||
Enhancements:
|
||||
|
|
|
@ -2932,7 +2932,7 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
|||
|
||||
[[package]]
|
||||
name = "openethereum"
|
||||
version = "3.3.1"
|
||||
version = "3.3.3"
|
||||
dependencies = [
|
||||
"ansi_term 0.10.2",
|
||||
"atty",
|
||||
|
@ -3282,7 +3282,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "parity-version"
|
||||
version = "3.3.1"
|
||||
version = "3.3.3"
|
||||
dependencies = [
|
||||
"parity-bytes",
|
||||
"rlp",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
description = "OpenEthereum"
|
||||
name = "openethereum"
|
||||
# NOTE Make sure to update util/version/Cargo.toml as well
|
||||
version = "3.3.1"
|
||||
version = "3.3.3"
|
||||
license = "GPL-3.0"
|
||||
authors = [
|
||||
"OpenEthereum developers",
|
||||
|
|
|
@ -640,7 +640,7 @@ impl Configuration {
|
|||
|
||||
fn pool_verification_options(&self) -> Result<pool::verifier::Options, String> {
|
||||
Ok(pool::verifier::Options {
|
||||
// NOTE min_gas_price,block_gas_limit and block_base_fee will be overwritten right after start.
|
||||
// NOTE min_gas_price,block_gas_limit block_base_fee, and allow_non_eoa_sender will be overwritten right after start.
|
||||
minimal_gas_price: U256::from(20_000_000) * 1_000u32,
|
||||
block_gas_limit: U256::max_value(),
|
||||
block_base_fee: None,
|
||||
|
@ -649,6 +649,7 @@ impl Configuration {
|
|||
None => U256::max_value(),
|
||||
},
|
||||
no_early_reject: self.args.flag_tx_queue_no_early_reject,
|
||||
allow_non_eoa_sender: false,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -370,7 +370,14 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<RunningClient
|
|||
let base_fee = client
|
||||
.engine()
|
||||
.calculate_base_fee(&client.best_block_header());
|
||||
miner.update_transaction_queue_limits(*client.best_block_header().gas_limit(), base_fee);
|
||||
let allow_non_eoa_sender = client
|
||||
.engine()
|
||||
.allow_non_eoa_sender(client.best_block_header().number() + 1);
|
||||
miner.update_transaction_queue_limits(
|
||||
*client.best_block_header().gas_limit(),
|
||||
base_fee,
|
||||
allow_non_eoa_sender,
|
||||
);
|
||||
|
||||
let connection_filter = connection_filter_address.map(|a| {
|
||||
Arc::new(NodeFilter::new(
|
||||
|
|
|
@ -32,6 +32,8 @@ pub struct AccountDetails {
|
|||
pub nonce: U256,
|
||||
/// Current account balance
|
||||
pub balance: U256,
|
||||
/// Code hash associated with an account if any
|
||||
pub code_hash: Option<H256>,
|
||||
/// Is this account a local account?
|
||||
pub is_local: bool,
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ impl Default for TestClient {
|
|||
account_details: AccountDetails {
|
||||
nonce: 123.into(),
|
||||
balance: 63_100.into(),
|
||||
code_hash: None,
|
||||
is_local: false,
|
||||
},
|
||||
gas_required: 21_000.into(),
|
||||
|
@ -68,6 +69,11 @@ impl TestClient {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_code_hash<T: Into<H256>>(mut self, code_hash: T) -> Self {
|
||||
self.account_details.code_hash = Some(code_hash.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_gas_required<T: Into<U256>>(mut self, gas_required: T) -> Self {
|
||||
self.gas_required = gas_required.into();
|
||||
self
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use ethereum_types::U256;
|
||||
use hash::KECCAK_EMPTY;
|
||||
use txpool;
|
||||
use types::transaction::{self, PendingTransaction};
|
||||
|
||||
|
@ -47,6 +48,7 @@ fn new_queue() -> TransactionQueue {
|
|||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
block_base_fee: None,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
)
|
||||
|
@ -66,6 +68,7 @@ fn should_return_correct_nonces_when_dropped_because_of_limit() {
|
|||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
block_base_fee: None,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
|
@ -127,6 +130,7 @@ fn should_never_drop_local_transactions_from_different_senders() {
|
|||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
block_base_fee: None,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
|
@ -272,6 +276,71 @@ fn should_import_transaction_below_min_gas_price_threshold_if_local() {
|
|||
assert_eq!(txq.status().status.transaction_count, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_reject_transaction_from_non_eoa_if_non_eoa_sender_is_not_allowed() {
|
||||
// given
|
||||
let txq = new_queue();
|
||||
let tx = Tx::default();
|
||||
let code_hash = [
|
||||
0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a, 0x0f,
|
||||
0x0e, 0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a,
|
||||
0x0f, 0x0e,
|
||||
];
|
||||
|
||||
// when
|
||||
let res = txq.import(
|
||||
TestClient::new().with_code_hash(code_hash),
|
||||
vec![tx.signed().unverified()],
|
||||
);
|
||||
|
||||
// then
|
||||
assert_eq!(res, vec![Err(transaction::Error::SenderIsNotEOA)]);
|
||||
assert_eq!(txq.status().status.transaction_count, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_import_transaction_from_non_eoa_if_non_eoa_sender_is_allowed() {
|
||||
// given
|
||||
let txq = new_queue();
|
||||
let tx = Tx::default();
|
||||
let code_hash = [
|
||||
0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a, 0x0f,
|
||||
0x0e, 0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a, 0x0f, 0x0e, 0x0c, 0x0a,
|
||||
0x0f, 0x0e,
|
||||
];
|
||||
txq.set_verifier_options(verifier::Options {
|
||||
allow_non_eoa_sender: true,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
// when
|
||||
let res = txq.import(
|
||||
TestClient::new().with_code_hash(code_hash),
|
||||
vec![tx.signed().unverified()],
|
||||
);
|
||||
|
||||
// then
|
||||
assert_eq!(res, vec![Ok(())]);
|
||||
assert_eq!(txq.status().status.transaction_count, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_import_transaction_if_account_code_hash_is_keccak_empty() {
|
||||
// given
|
||||
let txq = new_queue();
|
||||
let tx = Tx::default();
|
||||
|
||||
// when
|
||||
let res = txq.import(
|
||||
TestClient::new().with_code_hash(KECCAK_EMPTY),
|
||||
vec![tx.signed().unverified()],
|
||||
);
|
||||
|
||||
// then
|
||||
assert_eq!(res, vec![Ok(())]);
|
||||
assert_eq!(txq.status().status.transaction_count, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_import_txs_from_same_sender() {
|
||||
// given
|
||||
|
@ -545,6 +614,7 @@ fn should_prefer_current_transactions_when_hitting_the_limit() {
|
|||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
block_base_fee: None,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
|
@ -1043,6 +1113,7 @@ fn should_include_local_transaction_to_a_full_pool() {
|
|||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
block_base_fee: None,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
|
@ -1076,6 +1147,7 @@ fn should_avoid_verifying_transaction_already_in_pool() {
|
|||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
block_base_fee: None,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
|
@ -1112,6 +1184,7 @@ fn should_avoid_reverifying_recently_rejected_transactions() {
|
|||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
block_base_fee: None,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
|
@ -1161,6 +1234,7 @@ fn should_reject_early_in_case_gas_price_is_less_than_min_effective() {
|
|||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
block_base_fee: None,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
|
@ -1204,6 +1278,7 @@ fn should_not_reject_early_in_case_gas_price_is_less_than_min_effective() {
|
|||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: true,
|
||||
block_base_fee: None,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
|
|
|
@ -31,6 +31,7 @@ use std::{
|
|||
};
|
||||
|
||||
use ethereum_types::{H256, U256};
|
||||
use hash::KECCAK_EMPTY;
|
||||
use txpool;
|
||||
use types::transaction;
|
||||
|
||||
|
@ -52,6 +53,8 @@ pub struct Options {
|
|||
pub tx_gas_limit: U256,
|
||||
/// Skip checks for early rejection, to make sure that local transactions are always imported.
|
||||
pub no_early_reject: bool,
|
||||
/// Accept transactions from non EOAs (see EIP-3607)
|
||||
pub allow_non_eoa_sender: bool,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -63,6 +66,7 @@ impl Default for Options {
|
|||
block_base_fee: None,
|
||||
tx_gas_limit: U256::max_value(),
|
||||
no_early_reject: false,
|
||||
allow_non_eoa_sender: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -317,6 +321,20 @@ impl<C: Client> txpool::Verifier<Transaction>
|
|||
let sender = transaction.sender();
|
||||
let account_details = self.client.account_details(&sender);
|
||||
|
||||
if !self.options.allow_non_eoa_sender {
|
||||
if let Some(code_hash) = account_details.code_hash {
|
||||
if code_hash != KECCAK_EMPTY {
|
||||
debug!(
|
||||
target: "txqueue",
|
||||
"[{:?}] Rejected tx, sender is not an EOA: {}",
|
||||
hash,
|
||||
code_hash
|
||||
);
|
||||
bail!(transaction::Error::SenderIsNotEOA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let effective_priority_fee =
|
||||
transaction.effective_priority_fee(self.options.block_base_fee);
|
||||
|
||||
|
|
|
@ -52,7 +52,16 @@
|
|||
"eip1884Transition": 12095200,
|
||||
"eip2028Transition": 12095200,
|
||||
"eip2929Transition": 21050600,
|
||||
"eip2930Transition": 21050600
|
||||
"eip2930Transition": 21050600,
|
||||
"eip3198Transition": 24114400,
|
||||
"eip3529Transition": 24114400,
|
||||
"eip3541Transition": 24114400,
|
||||
"eip1559Transition": 24114400,
|
||||
"eip1559BaseFeeMaxChangeDenominator": "0x8",
|
||||
"eip1559ElasticityMultiplier": "0x2",
|
||||
"eip1559BaseFeeInitialValue": "0x3b9aca00",
|
||||
"eip1559FeeCollector": "0xE8DDc5c7A2d2F0D7a9798459c0104fDf5E987ACA",
|
||||
"eip1559FeeCollectorTransition": 24114400
|
||||
},
|
||||
"genesis": {
|
||||
"seal": {
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "Morden",
|
||||
"engine": {
|
||||
"null": {
|
||||
"params": {}
|
||||
}
|
||||
},
|
||||
"params": {
|
||||
"gasLimitBoundDivisor": "0x0400",
|
||||
"accountStartNonce": "0x0",
|
||||
"maximumExtraDataSize": "0x20",
|
||||
"minGasLimit": "0x1388",
|
||||
"networkID" : "0x2",
|
||||
"registrar" : "0x0000000000000000000000000000000000001337",
|
||||
"eip140Transition": "0x0",
|
||||
"eip211Transition": "0x0",
|
||||
"eip214Transition": "0x0",
|
||||
"eip658Transition": "0x0",
|
||||
"eip3607Transition": "0x2"
|
||||
},
|
||||
"genesis": {
|
||||
"seal": {
|
||||
"ethereum": {
|
||||
"nonce": "0x00006d6f7264656e",
|
||||
"mixHash": "0x00000000000000000000000000000000000000647572616c65787365646c6578"
|
||||
}
|
||||
},
|
||||
"difficulty": "0x20000",
|
||||
"author": "0x0000000000000000000000000000000000000000",
|
||||
"timestamp": "0x00",
|
||||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"extraData": "0x",
|
||||
"gasLimit": "0x2fefd8"
|
||||
},
|
||||
"accounts": {
|
||||
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
|
||||
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" },
|
||||
"0x71562b71999873DB5b286dF957af199Ec94617F7": {
|
||||
"balance": "1000000000000000000",
|
||||
"nonce": "0",
|
||||
"code": "0xB0B0FACE"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2280,11 +2280,6 @@ impl BlockChainClient for Client {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_aura(&self) -> bool {
|
||||
let engine = self.engine.clone();
|
||||
engine.name() == "AuthorityRound"
|
||||
}
|
||||
|
||||
fn is_processing_fork(&self) -> bool {
|
||||
let chain = self.chain.read();
|
||||
self.importer
|
||||
|
|
|
@ -1087,13 +1087,20 @@ impl BlockChainClient for TestBlockChainClient {
|
|||
let mut rlp = RlpStream::new();
|
||||
rlp.append(&hash.clone());
|
||||
return Some(rlp.out());
|
||||
} else if *hash
|
||||
== H256::from_str("000000000000000000000000000000000000000000000000000000000000000a")
|
||||
.unwrap()
|
||||
{
|
||||
// for basic `return_node_data` tests
|
||||
return Some(vec![0xaa, 0xaa]);
|
||||
} else if *hash
|
||||
== H256::from_str("000000000000000000000000000000000000000000000000000000000000000c")
|
||||
.unwrap()
|
||||
{
|
||||
return Some(vec![0xcc]);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn is_aura(&self) -> bool {
|
||||
self.engine().name() == "AuthorityRound"
|
||||
}
|
||||
}
|
||||
|
||||
impl IoClient for TestBlockChainClient {
|
||||
|
|
|
@ -258,9 +258,6 @@ pub trait BlockChainClient:
|
|||
/// Get block total difficulty.
|
||||
fn block_total_difficulty(&self, id: BlockId) -> Option<U256>;
|
||||
|
||||
/// Is it AuRa engine?
|
||||
fn is_aura(&self) -> bool;
|
||||
|
||||
/// Attempt to get address storage root at given block.
|
||||
/// May not fail on BlockId::Latest.
|
||||
fn storage_root(&self, address: &Address, id: BlockId) -> Option<H256>;
|
||||
|
|
|
@ -1557,6 +1557,43 @@ impl Engine<EthereumMachine> for AuthorityRound {
|
|||
}
|
||||
}
|
||||
|
||||
// Mostly is the same as `fn sealing_state(&self)` except that it does not
|
||||
// check whether the node is a step proposer.
|
||||
fn is_allowed_to_seal(&self) -> bool {
|
||||
let our_addr = match *self.signer.read() {
|
||||
Some(ref signer) => signer.address(),
|
||||
None => return false,
|
||||
};
|
||||
|
||||
let client = match self.upgrade_client_or("Not preparing block") {
|
||||
Ok(client) => client,
|
||||
Err(_) => return false,
|
||||
};
|
||||
|
||||
let parent = match client.as_full_client() {
|
||||
Some(full_client) => full_client.best_block_header(),
|
||||
None => {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
let validators = if self.immediate_transitions {
|
||||
CowLike::Borrowed(&*self.validators)
|
||||
} else {
|
||||
let mut epoch_manager = self.epoch_manager.lock();
|
||||
if !epoch_manager.zoom_to_after(
|
||||
&*client,
|
||||
&self.machine,
|
||||
&*self.validators,
|
||||
parent.hash(),
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
CowLike::Owned(epoch_manager.validators().clone())
|
||||
};
|
||||
validators.contains(&parent.hash(), &our_addr)
|
||||
}
|
||||
|
||||
fn sealing_state(&self) -> SealingState {
|
||||
let our_addr = match *self.signer.read() {
|
||||
Some(ref signer) => signer.address(),
|
||||
|
|
|
@ -470,6 +470,14 @@ pub trait Engine<M: Machine>: Sync + Send {
|
|||
/// Register a component which signs consensus messages.
|
||||
fn set_signer(&self, _signer: Option<Box<dyn EngineSigner>>) {}
|
||||
|
||||
/// Returns whether the current node is a validator and
|
||||
/// actually may seal a block if AuRa engine is used.
|
||||
///
|
||||
/// Used by `eth_mining` rpc call.
|
||||
fn is_allowed_to_seal(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Sign using the EngineSigner, to be used for consensus tx signing.
|
||||
fn sign(&self, _hash: H256) -> Result<Signature, M::Error> {
|
||||
unimplemented!()
|
||||
|
@ -660,6 +668,14 @@ pub trait EthEngine: Engine<::machine::EthereumMachine> {
|
|||
fn min_gas_limit(&self) -> U256 {
|
||||
self.params().min_gas_limit
|
||||
}
|
||||
|
||||
/// Returns whether transactions from non externally owned accounts (EOA)
|
||||
/// are allowed in the given block number (see EIP-3607).
|
||||
///
|
||||
/// That is only possible if EIP-3607 is still not activated.
|
||||
fn allow_non_eoa_sender(&self, best_block_number: BlockNumber) -> bool {
|
||||
self.params().eip3607_transition > best_block_number
|
||||
}
|
||||
}
|
||||
|
||||
// convenience wrappers for existing functions.
|
||||
|
|
|
@ -2760,6 +2760,127 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
evm_test! {test_too_big_max_priority_fee_with_not_enough_cash: test_too_big_max_priority_fee_with_not_enough_cash_int}
|
||||
fn test_too_big_max_priority_fee_with_not_enough_cash(factory: Factory) {
|
||||
let keypair = Random.generate();
|
||||
let max_priority_fee_per_gas /* 2**256 - 1 */ = U256::from(340282366920938463463374607431768211455u128)
|
||||
* U256::from(340282366920938463463374607431768211455u128)
|
||||
+ U256::from(340282366920938463463374607431768211455u128)
|
||||
+ U256::from(340282366920938463463374607431768211455u128);
|
||||
let t = TypedTransaction::EIP1559Transaction(EIP1559TransactionTx {
|
||||
transaction: AccessListTx::new(
|
||||
Transaction {
|
||||
action: Action::Create,
|
||||
value: U256::from(17),
|
||||
data: "3331600055".from_hex().unwrap(),
|
||||
gas: U256::from(100_000),
|
||||
gas_price: max_priority_fee_per_gas,
|
||||
nonce: U256::zero(),
|
||||
},
|
||||
vec![
|
||||
(
|
||||
H160::from_low_u64_be(10),
|
||||
vec![H256::from_low_u64_be(102), H256::from_low_u64_be(103)],
|
||||
),
|
||||
(H160::from_low_u64_be(400), vec![]),
|
||||
],
|
||||
),
|
||||
max_priority_fee_per_gas,
|
||||
})
|
||||
.sign(keypair.secret(), None);
|
||||
|
||||
let sender = t.sender();
|
||||
|
||||
let mut state = get_temp_state_with_factory(factory);
|
||||
state
|
||||
.add_balance(&sender, &U256::from(15000017), CleanupMode::NoEmpty)
|
||||
.unwrap();
|
||||
let mut info = EnvInfo::default();
|
||||
info.gas_limit = U256::from(100_000);
|
||||
info.base_fee = Some(U256::from(100));
|
||||
let machine = make_london_machine(0);
|
||||
let schedule = machine.schedule(info.number);
|
||||
|
||||
let res = {
|
||||
let mut ex = Executive::new(&mut state, &info, &machine, &schedule);
|
||||
let opts = TransactOptions::with_no_tracing();
|
||||
ex.transact(&t, opts)
|
||||
};
|
||||
|
||||
match res {
|
||||
Err(ExecutionError::NotEnoughCash { required, got })
|
||||
if required
|
||||
== U512::from(max_priority_fee_per_gas) * U512::from(100_000)
|
||||
+ U512::from(17)
|
||||
&& got == U512::from(15000017) =>
|
||||
{
|
||||
()
|
||||
}
|
||||
_ => assert!(false, "Expected not enough cash error. {:?}", res),
|
||||
}
|
||||
}
|
||||
|
||||
evm_test! {test_too_big_max_priority_fee_with_less_max_fee_per_gas: test_too_big_max_priority_fee_with_less_max_fee_per_gas_int}
|
||||
fn test_too_big_max_priority_fee_with_less_max_fee_per_gas(factory: Factory) {
|
||||
let keypair = Random.generate();
|
||||
let max_priority_fee_per_gas /* 2**256 - 1 */ = U256::from(340282366920938463463374607431768211455u128)
|
||||
* U256::from(340282366920938463463374607431768211455u128)
|
||||
+ U256::from(340282366920938463463374607431768211455u128)
|
||||
+ U256::from(340282366920938463463374607431768211455u128);
|
||||
let t = TypedTransaction::EIP1559Transaction(EIP1559TransactionTx {
|
||||
transaction: AccessListTx::new(
|
||||
Transaction {
|
||||
action: Action::Create,
|
||||
value: U256::from(17),
|
||||
data: "3331600055".from_hex().unwrap(),
|
||||
gas: U256::from(100_000),
|
||||
gas_price: U256::from(150),
|
||||
nonce: U256::zero(),
|
||||
},
|
||||
vec![
|
||||
(
|
||||
H160::from_low_u64_be(10),
|
||||
vec![H256::from_low_u64_be(102), H256::from_low_u64_be(103)],
|
||||
),
|
||||
(H160::from_low_u64_be(400), vec![]),
|
||||
],
|
||||
),
|
||||
max_priority_fee_per_gas,
|
||||
})
|
||||
.sign(keypair.secret(), None);
|
||||
|
||||
let sender = t.sender();
|
||||
|
||||
let mut state = get_temp_state_with_factory(factory);
|
||||
state
|
||||
.add_balance(&sender, &U256::from(15000017), CleanupMode::NoEmpty)
|
||||
.unwrap();
|
||||
let mut info = EnvInfo::default();
|
||||
info.gas_limit = U256::from(100_000);
|
||||
info.base_fee = Some(U256::from(100));
|
||||
let machine = make_london_machine(0);
|
||||
let schedule = machine.schedule(info.number);
|
||||
|
||||
let res = {
|
||||
let mut ex = Executive::new(&mut state, &info, &machine, &schedule);
|
||||
let opts = TransactOptions::with_no_tracing();
|
||||
ex.transact(&t, opts)
|
||||
};
|
||||
|
||||
match res {
|
||||
Err(ExecutionError::TransactionMalformed(err))
|
||||
if err.contains("maxPriorityFeePerGas higher than maxFeePerGas") =>
|
||||
{
|
||||
()
|
||||
}
|
||||
_ => assert!(
|
||||
false,
|
||||
"Expected maxPriorityFeePerGas higher than maxFeePerGas error. {:?}",
|
||||
res
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
evm_test! {test_keccak: test_keccak_int}
|
||||
fn test_keccak(factory: Factory) {
|
||||
let code = "6064640fffffffff20600055".from_hex().unwrap();
|
||||
|
|
|
@ -190,6 +190,7 @@ impl Default for MinerOptions {
|
|||
block_base_fee: None,
|
||||
tx_gas_limit: U256::max_value(),
|
||||
no_early_reject: false,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -341,6 +342,7 @@ impl Miner {
|
|||
block_base_fee: None,
|
||||
tx_gas_limit: U256::max_value(),
|
||||
no_early_reject: false,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
reseal_min_period: Duration::from_secs(0),
|
||||
force_sealing,
|
||||
|
@ -382,6 +384,7 @@ impl Miner {
|
|||
&self,
|
||||
block_gas_limit: U256,
|
||||
block_base_fee: Option<U256>,
|
||||
allow_non_eoa_sender: bool,
|
||||
) {
|
||||
trace!(target: "miner", "minimal_gas_price: recalibrating...");
|
||||
let txq = self.transaction_queue.clone();
|
||||
|
@ -391,6 +394,7 @@ impl Miner {
|
|||
options.minimal_gas_price = gas_price;
|
||||
options.block_gas_limit = block_gas_limit;
|
||||
options.block_base_fee = block_base_fee;
|
||||
options.allow_non_eoa_sender = allow_non_eoa_sender;
|
||||
txq.set_verifier_options(options);
|
||||
});
|
||||
|
||||
|
@ -1377,7 +1381,7 @@ impl miner::MinerService for Miner {
|
|||
}
|
||||
|
||||
fn is_currently_sealing(&self) -> bool {
|
||||
self.sealing.lock().enabled
|
||||
self.sealing.lock().enabled && self.engine.is_allowed_to_seal()
|
||||
}
|
||||
|
||||
fn work_package<C>(&self, chain: &C) -> Option<(H256, BlockNumber, u64, U256)>
|
||||
|
@ -1466,7 +1470,10 @@ impl miner::MinerService for Miner {
|
|||
} else {
|
||||
1
|
||||
};
|
||||
self.update_transaction_queue_limits(gas_limit, base_fee);
|
||||
let allow_non_eoa_sender = self
|
||||
.engine
|
||||
.allow_non_eoa_sender(chain.best_block_header().number() + 1);
|
||||
self.update_transaction_queue_limits(gas_limit, base_fee, allow_non_eoa_sender);
|
||||
|
||||
// t_nb 10.2 Then import all transactions from retracted blocks (retracted means from side chain).
|
||||
let client = self.pool_client(chain);
|
||||
|
@ -1608,7 +1615,9 @@ mod tests {
|
|||
|
||||
use client::{ChainInfo, EachBlockWith, ImportSealedBlock, TestBlockChainClient};
|
||||
use miner::{MinerService, PendingOrdering};
|
||||
use test_helpers::{generate_dummy_client, generate_dummy_client_with_spec};
|
||||
use test_helpers::{
|
||||
dummy_engine_signer_with_address, generate_dummy_client, generate_dummy_client_with_spec,
|
||||
};
|
||||
use types::transaction::{Transaction, TypedTransaction};
|
||||
|
||||
#[test]
|
||||
|
@ -1668,6 +1677,7 @@ mod tests {
|
|||
block_base_fee: None,
|
||||
tx_gas_limit: U256::max_value(),
|
||||
no_early_reject: false,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
},
|
||||
GasPricer::new_fixed(0u64.into()),
|
||||
|
@ -1813,6 +1823,40 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_activate_eip_3607_according_to_spec() {
|
||||
// given
|
||||
let spec = Spec::new_test_eip3607();
|
||||
let miner = Miner::new_for_tests(&spec, None);
|
||||
let client = TestBlockChainClient::new_with_spec(spec);
|
||||
|
||||
let imported = [H256::zero()];
|
||||
let empty = &[];
|
||||
|
||||
// the client best block is below EIP-3607 transition number
|
||||
miner.chain_new_blocks(&client, &imported, empty, &imported, empty, false);
|
||||
assert!(
|
||||
miner.queue_status().options.allow_non_eoa_sender,
|
||||
"The client best block is below EIP-3607 transition number. Non EOA senders should be allowed"
|
||||
);
|
||||
|
||||
// the client best block equals EIP-3607 transition number
|
||||
client.add_block(EachBlockWith::Nothing, |header| header);
|
||||
miner.chain_new_blocks(&client, &imported, empty, &imported, empty, false);
|
||||
assert!(
|
||||
!miner.queue_status().options.allow_non_eoa_sender,
|
||||
"The client best block equals EIP-3607 transition number. Non EOA senders should not be allowed"
|
||||
);
|
||||
|
||||
// the client best block is above EIP-3607 transition number
|
||||
client.add_block(EachBlockWith::Nothing, |header| header);
|
||||
miner.chain_new_blocks(&client, &imported, empty, &imported, empty, false);
|
||||
assert!(
|
||||
!miner.queue_status().options.allow_non_eoa_sender,
|
||||
"The client best block is above EIP-3607 transition number. Non EOA senders should not be allowed"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_treat_unfamiliar_locals_selectively() {
|
||||
// given
|
||||
|
@ -2078,6 +2122,31 @@ mod tests {
|
|||
assert!(miner.is_currently_sealing());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_mine_if_is_not_allowed_to_seal() {
|
||||
let spec = Spec::new_test_round();
|
||||
let miner = Miner::new_for_tests_force_sealing(&spec, None, true);
|
||||
assert!(!miner.is_currently_sealing());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_mine_if_is_allowed_to_seal() {
|
||||
let verifier: Address = [
|
||||
0x7d, 0x57, 0x7a, 0x59, 0x7b, 0x27, 0x42, 0xb4, 0x98, 0xcb, 0x5c, 0xf0, 0xc2, 0x6c,
|
||||
0xdc, 0xd7, 0x26, 0xd3, 0x9e, 0x6e,
|
||||
]
|
||||
.into();
|
||||
|
||||
let spec = Spec::new_test_round();
|
||||
let client: Arc<dyn EngineClient> = generate_dummy_client(2);
|
||||
|
||||
let miner = Miner::new_for_tests_force_sealing(&spec, None, true);
|
||||
miner.engine.register_client(Arc::downgrade(&client));
|
||||
miner.set_author(Author::Sealer(dummy_engine_signer_with_address(verifier)));
|
||||
|
||||
assert!(miner.is_currently_sealing());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_set_new_minimum_gas_price() {
|
||||
// Creates a new GasPricer::Fixed behind the scenes
|
||||
|
|
|
@ -30,7 +30,7 @@ use types::{
|
|||
};
|
||||
|
||||
use call_contract::CallContract;
|
||||
use client::{BlockInfo, Nonce, TransactionId};
|
||||
use client::{BlockId, BlockInfo, Nonce, TransactionId};
|
||||
use engines::EthEngine;
|
||||
use miner;
|
||||
use transaction_ext::Transaction;
|
||||
|
@ -168,6 +168,7 @@ where
|
|||
pool::client::AccountDetails {
|
||||
nonce: self.cached_nonces.account_nonce(address),
|
||||
balance: self.chain.latest_balance(address),
|
||||
code_hash: self.chain.code_hash(address, BlockId::Latest),
|
||||
is_local: self.accounts.is_local(address),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,6 +147,8 @@ pub struct CommonParams {
|
|||
pub eip3529_transition: BlockNumber,
|
||||
/// Number of first block where EIP-3541 rule begins.
|
||||
pub eip3541_transition: BlockNumber,
|
||||
/// Number of first block where EIP-3607 rule begins.
|
||||
pub eip3607_transition: BlockNumber,
|
||||
/// Number of first block where dust cleanup rules (EIP-168 and EIP169) begin.
|
||||
pub dust_protection_transition: BlockNumber,
|
||||
/// Nonce cap increase per block. Nonce cap is only checked if dust protection is enabled.
|
||||
|
@ -434,6 +436,7 @@ impl From<ethjson::spec::Params> for CommonParams {
|
|||
dust_protection_transition: p
|
||||
.dust_protection_transition
|
||||
.map_or_else(BlockNumber::max_value, Into::into),
|
||||
eip3607_transition: p.eip3607_transition.map_or(0, Into::into),
|
||||
nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into),
|
||||
remove_dust_contracts: p.remove_dust_contracts.unwrap_or(false),
|
||||
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
|
||||
|
@ -1151,6 +1154,13 @@ impl Spec {
|
|||
load_bundled!("test/constructor")
|
||||
}
|
||||
|
||||
/// Create a new Spec which is a NullEngine consensus with EIP3607 transition equal to 2,
|
||||
/// and with a contract at address '0x71562b71999873DB5b286dF957af199Ec94617F7'.
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
pub fn new_test_eip3607() -> Self {
|
||||
load_bundled!("test/eip3607_test")
|
||||
}
|
||||
|
||||
/// Create a new Spec with Autority Round randomness contract
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
pub fn new_test_round_randomness_contract() -> Spec {
|
||||
|
|
|
@ -46,6 +46,8 @@ use block::{Drain, OpenBlock};
|
|||
use client::{
|
||||
ChainInfo, ChainMessageType, ChainNotify, Client, ClientConfig, ImportBlock, PrepareOpenBlock,
|
||||
};
|
||||
use engines::EngineSigner;
|
||||
use ethjson::crypto::publickey::{Public, Signature};
|
||||
use factory::Factories;
|
||||
use miner::Miner;
|
||||
use spec::Spec;
|
||||
|
@ -644,3 +646,38 @@ impl ChainNotify for TestNotify {
|
|||
self.messages.write().push(data);
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns engine signer with specified address
|
||||
pub fn dummy_engine_signer_with_address(addr: Address) -> Box<dyn EngineSigner> {
|
||||
struct TestEngineSigner(Address);
|
||||
|
||||
impl TestEngineSigner {
|
||||
fn with_address(addr: Address) -> Self {
|
||||
Self(addr)
|
||||
}
|
||||
}
|
||||
|
||||
impl EngineSigner for TestEngineSigner {
|
||||
fn sign(&self, _hash: H256) -> Result<Signature, ethjson::crypto::publickey::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn address(&self) -> Address {
|
||||
self.0
|
||||
}
|
||||
|
||||
fn decrypt(
|
||||
&self,
|
||||
_auth_data: &[u8],
|
||||
_cipher: &[u8],
|
||||
) -> Result<Vec<u8>, parity_crypto::publickey::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn public(&self) -> Option<Public> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
Box::new(TestEngineSigner::with_address(addr))
|
||||
}
|
||||
|
|
|
@ -1704,6 +1704,14 @@ pub mod tests {
|
|||
assert!(!sync_status(SyncState::Idle).is_syncing(queue_info(0, 0)));
|
||||
}
|
||||
|
||||
pub fn dummy_sync(client: &dyn BlockChainClient) -> ChainSync {
|
||||
ChainSync::new(
|
||||
SyncConfig::default(),
|
||||
client,
|
||||
ForkFilterApi::new_dummy(client),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn dummy_sync_with_peer(
|
||||
peer_latest_hash: H256,
|
||||
client: &dyn BlockChainClient,
|
||||
|
|
|
@ -351,36 +351,34 @@ impl SyncSupplier {
|
|||
}
|
||||
|
||||
fn return_node_data(io: &dyn SyncIo, rlp: &Rlp, peer_id: PeerId) -> RlpResponseResult {
|
||||
if io.chain().is_aura() {
|
||||
let count = cmp::min(rlp.item_count().unwrap_or(0), MAX_NODE_DATA_TO_SEND);
|
||||
if count == 0 {
|
||||
debug!(target: "sync", "Empty GetNodeData request, ignoring.");
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let mut data = Bytes::new();
|
||||
|
||||
let mut added = 0usize;
|
||||
for i in 0..count {
|
||||
if let Some(ref mut node_data) = io.chain().state_data(&rlp.val_at::<H256>(i)?) {
|
||||
data.append(node_data);
|
||||
added += 1;
|
||||
if data.len() > PAYLOAD_SOFT_LIMIT {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut rlp = RlpStream::new_list(added);
|
||||
rlp.append_raw(&data, added);
|
||||
trace!(target: "sync", "{} -> GetNodeData: returned {} entries", peer_id, added);
|
||||
Ok(Some((NodeDataPacket, rlp)))
|
||||
} else {
|
||||
// GetNodeData requests are ignored since we don't have a correct
|
||||
// implementation of the NodeData response, see issue #508
|
||||
debug!("Ignoring GetNodeData request");
|
||||
Ok(None)
|
||||
let count = cmp::min(rlp.item_count().unwrap_or(0), MAX_NODE_DATA_TO_SEND);
|
||||
trace!(target: "sync", "{} -> GetNodeData: {} entries", peer_id, count);
|
||||
if count == 0 {
|
||||
debug!(target: "sync", "Empty GetNodeData request, ignoring.");
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let mut added = 0usize;
|
||||
let mut data = Vec::new();
|
||||
let mut total_bytes = 0;
|
||||
for i in 0..count {
|
||||
if let Some(node_data) = io.chain().state_data(&rlp.val_at::<H256>(i)?) {
|
||||
total_bytes += node_data.len();
|
||||
// Check that the packet won't be oversized
|
||||
if total_bytes > PAYLOAD_SOFT_LIMIT {
|
||||
break;
|
||||
}
|
||||
data.push(node_data);
|
||||
added += 1;
|
||||
}
|
||||
}
|
||||
|
||||
let mut rlp = RlpStream::new_list(added);
|
||||
for d in data {
|
||||
rlp.append(&d);
|
||||
}
|
||||
trace!(target: "sync", "{} -> GetNodeData: returned {} entries", peer_id, added);
|
||||
Ok(Some((NodeDataPacket, rlp)))
|
||||
}
|
||||
|
||||
fn return_receipts(io: &dyn SyncIo, rlp: &Rlp, peer_id: PeerId) -> RlpResponseResult {
|
||||
|
@ -816,4 +814,48 @@ mod test {
|
|||
);
|
||||
assert_eq!(1, io.packets.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dispatch_get_node_data_request() {
|
||||
let mut client = TestBlockChainClient::new_with_spec(Spec::new_test_round());
|
||||
let queue = RwLock::new(VecDeque::new());
|
||||
let sync = dummy_sync(&client);
|
||||
let ss = TestSnapshotService::new();
|
||||
let mut io = TestIo::new(&mut client, &ss, &queue, None);
|
||||
|
||||
let mut node_list = RlpStream::new_list(3);
|
||||
node_list.append(
|
||||
&H256::from_str("000000000000000000000000000000000000000000000000000000000000000a")
|
||||
.unwrap(),
|
||||
);
|
||||
node_list.append(
|
||||
&H256::from_str("000000000000000000000000000000000000000000000000000000000000000b")
|
||||
.unwrap(),
|
||||
);
|
||||
node_list.append(
|
||||
&H256::from_str("000000000000000000000000000000000000000000000000000000000000000c")
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
let node_request = node_list;
|
||||
let node_request = prepend_request_id(node_request, Some(0x0b3a73ce2ff2));
|
||||
|
||||
io.sender = Some(2usize);
|
||||
|
||||
// it returns rlp ONLY for hashes ending with "a" and "c"
|
||||
SyncSupplier::dispatch_packet(
|
||||
&RwLock::new(sync),
|
||||
&mut io,
|
||||
0usize,
|
||||
GetNodeDataPacket.id(),
|
||||
&node_request.out(),
|
||||
);
|
||||
assert_eq!(1, io.packets.len());
|
||||
assert_eq!(
|
||||
&io.packets[0].data,
|
||||
&vec![
|
||||
0xcd, 0x86, 0x0b, 0x3a, 0x73, 0xce, 0x2f, 0xf2, 0xc5, 0x82, 0xaa, 0xaa, 0x81, 0xcc
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,6 +93,8 @@ pub enum Error {
|
|||
InvalidRlp(String),
|
||||
/// Transaciton is still not enabled.
|
||||
TransactionTypeNotEnabled,
|
||||
/// Transaction sender is not an EOA (see EIP-3607)
|
||||
SenderIsNotEOA,
|
||||
}
|
||||
|
||||
impl From<crypto::publickey::Error> for Error {
|
||||
|
@ -154,6 +156,7 @@ impl fmt::Display for Error {
|
|||
TransactionTypeNotEnabled => {
|
||||
format!("Transaction type is not enabled for current block")
|
||||
}
|
||||
SenderIsNotEOA => "Transaction sender is not an EOA (see EIP-3607)".into(),
|
||||
};
|
||||
|
||||
f.write_fmt(format_args!("Transaction error ({})", msg))
|
||||
|
|
|
@ -634,10 +634,16 @@ impl TypedTransaction {
|
|||
|
||||
pub fn effective_gas_price(&self, block_base_fee: Option<U256>) -> U256 {
|
||||
match self {
|
||||
Self::EIP1559Transaction(tx) => min(
|
||||
self.tx().gas_price,
|
||||
tx.max_priority_fee_per_gas + block_base_fee.unwrap_or_default(),
|
||||
),
|
||||
Self::EIP1559Transaction(tx) => {
|
||||
let (v2, overflow) = tx
|
||||
.max_priority_fee_per_gas
|
||||
.overflowing_add(block_base_fee.unwrap_or_default());
|
||||
if overflow {
|
||||
self.tx().gas_price
|
||||
} else {
|
||||
min(self.tx().gas_price, v2)
|
||||
}
|
||||
}
|
||||
Self::AccessList(_) => self.tx().gas_price,
|
||||
Self::Legacy(_) => self.tx().gas_price,
|
||||
}
|
||||
|
@ -1337,4 +1343,41 @@ mod tests {
|
|||
test_vector("f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10", "9bddad43f934d313c2b79ca28a432dd2b7281029");
|
||||
test_vector("f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb", "3c24d7329e92f84f08556ceb6df1cdb0104ca49f");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_panic_on_effective_gas_price_overflow() {
|
||||
use self::publickey::{Generator, Random};
|
||||
let key = Random.generate();
|
||||
let gas_price /* 2**256 - 1 */ = U256::from(340282366920938463463374607431768211455u128)
|
||||
* U256::from(340282366920938463463374607431768211455u128)
|
||||
+ U256::from(340282366920938463463374607431768211455u128)
|
||||
+ U256::from(340282366920938463463374607431768211455u128);
|
||||
let t = TypedTransaction::EIP1559Transaction(EIP1559TransactionTx {
|
||||
transaction: AccessListTx::new(
|
||||
Transaction {
|
||||
action: Action::Create,
|
||||
nonce: U256::from(42),
|
||||
gas_price,
|
||||
gas: U256::from(50_000),
|
||||
value: U256::from(1),
|
||||
data: b"Hello!".to_vec(),
|
||||
},
|
||||
vec![
|
||||
(
|
||||
H160::from_low_u64_be(10),
|
||||
vec![H256::from_low_u64_be(102), H256::from_low_u64_be(103)],
|
||||
),
|
||||
(H160::from_low_u64_be(400), vec![]),
|
||||
],
|
||||
),
|
||||
max_priority_fee_per_gas: gas_price,
|
||||
})
|
||||
.sign(&key.secret(), Some(69));
|
||||
|
||||
let result = t.transaction.effective_gas_price(Some(124.into()));
|
||||
assert_eq!(
|
||||
gas_price, result,
|
||||
"Invalid effective gas price, when max_priority_fee_per_gas is U256::max"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ impl TypedTxId {
|
|||
pub fn from_U64_option_id(n: Option<U64>) -> Option<Self> {
|
||||
match n.map(|t| t.as_u64()) {
|
||||
None => Some(Self::Legacy),
|
||||
Some(0x00) => Some(Self::Legacy),
|
||||
Some(0x01) => Some(Self::AccessList),
|
||||
Some(0x02) => Some(Self::EIP1559Transaction),
|
||||
_ => None,
|
||||
|
@ -59,10 +60,7 @@ impl TypedTxId {
|
|||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn to_U64_option_id(self) -> Option<U64> {
|
||||
match self {
|
||||
Self::Legacy => None,
|
||||
_ => Some(U64::from(self as u8)),
|
||||
}
|
||||
Some(U64::from(self as u8))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +91,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn typed_tx_id_to_u64_option_id() {
|
||||
assert_eq!(None, TypedTxId::Legacy.to_U64_option_id());
|
||||
assert_eq!(Some(U64::from(0x00)), TypedTxId::Legacy.to_U64_option_id());
|
||||
assert_eq!(
|
||||
Some(U64::from(0x01)),
|
||||
TypedTxId::AccessList.to_U64_option_id()
|
||||
|
|
|
@ -120,6 +120,8 @@ pub struct Params {
|
|||
/// See `CommonParams` docs.
|
||||
pub eip3541_transition: Option<Uint>,
|
||||
/// See `CommonParams` docs.
|
||||
pub eip3607_transition: Option<Uint>,
|
||||
/// See `CommonParams` docs.
|
||||
pub dust_protection_transition: Option<Uint>,
|
||||
/// See `CommonParams` docs.
|
||||
pub nonce_cap_increment: Option<Uint>,
|
||||
|
|
|
@ -408,6 +408,7 @@ pub fn transaction_message(error: &TransactionError) -> String {
|
|||
TooBig => "Transaction is too big, see chain specification for the limit.".into(),
|
||||
InvalidRlp(ref descr) => format!("Invalid RLP data: {}", descr),
|
||||
TransactionTypeNotEnabled => format!("Transaction type is not enabled for current block"),
|
||||
SenderIsNotEOA => "Transaction sender is not an EOA (see EIP-3607)".into(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -335,6 +335,7 @@ impl MinerService for TestMinerService {
|
|||
tx_gas_limit: 5_000_000.into(),
|
||||
no_early_reject: false,
|
||||
block_base_fee: None,
|
||||
allow_non_eoa_sender: false,
|
||||
},
|
||||
status: txpool::LightStatus {
|
||||
mem_usage: 1_000,
|
||||
|
|
|
@ -765,7 +765,7 @@ fn rpc_eth_pending_transaction_by_hash() {
|
|||
.insert(H256::zero(), tx);
|
||||
}
|
||||
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":null,"blockNumber":null,"chainId":null,"condition":null,"creates":null,"from":"0x0f65fe9276bc9a24ae7083ae28e2660ef72df99e","gas":"0x5208","gasPrice":"0x1","hash":"0x41df922fd0d4766fcc02e161f8295ec28522f329ae487f14d811e4b64c8d6e31","input":"0x","nonce":"0x0","publicKey":"0x7ae46da747962c2ee46825839c1ef9298e3bd2e70ca2938495c3693a485ec3eaa8f196327881090ff64cf4fbb0a48485d4f83098e189ed3b7a87d5941b59f789","r":"0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353","raw":"0xf85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804","s":"0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804","standardV":"0x0","to":"0x095e7baea6a6c7c4c2dfeb977efac326af552d87","transactionIndex":null,"v":"0x1b","value":"0xa"},"id":1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":null,"blockNumber":null,"chainId":null,"condition":null,"creates":null,"from":"0x0f65fe9276bc9a24ae7083ae28e2660ef72df99e","gas":"0x5208","gasPrice":"0x1","hash":"0x41df922fd0d4766fcc02e161f8295ec28522f329ae487f14d811e4b64c8d6e31","input":"0x","nonce":"0x0","publicKey":"0x7ae46da747962c2ee46825839c1ef9298e3bd2e70ca2938495c3693a485ec3eaa8f196327881090ff64cf4fbb0a48485d4f83098e189ed3b7a87d5941b59f789","r":"0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353","raw":"0xf85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804","s":"0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804","standardV":"0x0","to":"0x095e7baea6a6c7c4c2dfeb977efac326af552d87","transactionIndex":null,"type":"0x0","v":"0x1b","value":"0xa"},"id":1}"#;
|
||||
let request = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_getTransactionByHash",
|
||||
|
@ -1245,7 +1245,7 @@ fn rpc_eth_transaction_receipt() {
|
|||
"params": ["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],
|
||||
"id": 1
|
||||
}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","contractAddress":null,"cumulativeGasUsed":"0x20","effectiveGasPrice":"0x0","from":"0xb60e8dd61c5d32be8058bb8eb970870f07233155","gasUsed":"0x10","logs":[{"address":"0x33990122638b9132ca29c723bdf037f1a891a70c","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","data":"0x","logIndex":"0x1","removed":false,"topics":["0xa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc","0x4861736852656700000000000000000000000000000000000000000000000000"],"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","transactionLogIndex":"0x0","type":"mined"}],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","root":"0x0000000000000000000000000000000000000000000000000000000000000000","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0"},"id":1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","contractAddress":null,"cumulativeGasUsed":"0x20","effectiveGasPrice":"0x0","from":"0xb60e8dd61c5d32be8058bb8eb970870f07233155","gasUsed":"0x10","logs":[{"address":"0x33990122638b9132ca29c723bdf037f1a891a70c","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","data":"0x","logIndex":"0x1","removed":false,"topics":["0xa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc","0x4861736852656700000000000000000000000000000000000000000000000000"],"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","transactionLogIndex":"0x0","type":"mined"}],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","root":"0x0000000000000000000000000000000000000000000000000000000000000000","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","type":"0x0"},"id":1}"#;
|
||||
|
||||
assert_eq!(
|
||||
tester.io.handle_request_sync(request),
|
||||
|
@ -1300,7 +1300,7 @@ fn rpc_eth_pending_receipt() {
|
|||
"params": ["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],
|
||||
"id": 1
|
||||
}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":null,"blockNumber":null,"contractAddress":null,"cumulativeGasUsed":"0x20","effectiveGasPrice":"0x0","from":"0xb60e8dd61c5d32be8058bb8eb970870f07233155","gasUsed":"0x10","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionHash":"0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238","transactionIndex":"0x0"},"id":1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":null,"blockNumber":null,"contractAddress":null,"cumulativeGasUsed":"0x20","effectiveGasPrice":"0x0","from":"0xb60e8dd61c5d32be8058bb8eb970870f07233155","gasUsed":"0x10","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionHash":"0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238","transactionIndex":"0x0","type":"0x0"},"id":1}"#;
|
||||
assert_eq!(
|
||||
tester.io.handle_request_sync(request),
|
||||
Some(response.to_owned())
|
||||
|
|
|
@ -572,7 +572,7 @@ fn rpc_parity_block_receipts() {
|
|||
"params": [],
|
||||
"id": 1
|
||||
}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":[{"blockHash":"0x0000000000000000000000000000000000000000000000000000000000000003","blockNumber":"0x0","contractAddress":null,"cumulativeGasUsed":"0x5208","effectiveGasPrice":"0x0","from":"0x0000000000000000000000000000000000000009","gasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001","to":null,"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000001","transactionIndex":"0x0"}],"id":1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":[{"blockHash":"0x0000000000000000000000000000000000000000000000000000000000000003","blockNumber":"0x0","contractAddress":null,"cumulativeGasUsed":"0x5208","effectiveGasPrice":"0x0","from":"0x0000000000000000000000000000000000000009","gasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001","to":null,"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000001","transactionIndex":"0x0","type":"0x0"}],"id":1}"#;
|
||||
|
||||
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ fn rpc_parity_remove_transaction() {
|
|||
.to_owned()
|
||||
+ &format!("0x{:x}", hash)
|
||||
+ r#""], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":null,"blockNumber":null,"chainId":null,"condition":null,"creates":null,"from":"0x0000000000000000000000000000000000000002","gas":"0x76c0","gasPrice":"0x9184e72a000","hash":"0x49569012bc8523519642c337fded3f20ba987beab31e14c67223b3d31359956f","input":"0x","nonce":"0x1","publicKey":null,"r":"0x1","raw":"0xe9018609184e72a0008276c0940000000000000000000000000000000000000005849184e72a801f0101","s":"0x1","standardV":"0x4","to":"0x0000000000000000000000000000000000000005","transactionIndex":null,"v":"0x1f","value":"0x9184e72a"},"id":1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":null,"blockNumber":null,"chainId":null,"condition":null,"creates":null,"from":"0x0000000000000000000000000000000000000002","gas":"0x76c0","gasPrice":"0x9184e72a000","hash":"0x49569012bc8523519642c337fded3f20ba987beab31e14c67223b3d31359956f","input":"0x","nonce":"0x1","publicKey":null,"r":"0x1","raw":"0xe9018609184e72a0008276c0940000000000000000000000000000000000000005849184e72a801f0101","s":"0x1","standardV":"0x4","to":"0x0000000000000000000000000000000000000005","transactionIndex":null,"type":"0x0","v":"0x1f","value":"0x9184e72a"},"id":1}"#;
|
||||
|
||||
miner.pending_transactions.lock().insert(hash, signed);
|
||||
assert_eq!(io.handle_request_sync(&request), Some(response.to_owned()));
|
||||
|
|
|
@ -656,6 +656,7 @@ fn should_confirm_sign_transaction_with_rlp() {
|
|||
+ &format!("\"s\":\"0x{:x}\",", U256::from(signature.s()))
|
||||
+ &format!("\"standardV\":\"0x{:x}\",", U256::from(t.standard_v()))
|
||||
+ r#""to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionIndex":null,"#
|
||||
+ r#""type":"0x0","#
|
||||
+ &format!("\"v\":\"0x{:x}\",", U256::from(t.v()))
|
||||
+ r#""value":"0x1""#
|
||||
+ r#"}},"id":1}"#;
|
||||
|
|
|
@ -427,6 +427,7 @@ fn should_add_sign_transaction_to_the_queue() {
|
|||
+ &format!("\"s\":\"0x{:x}\",", U256::from(signature.s()))
|
||||
+ &format!("\"standardV\":\"0x{:x}\",", U256::from(t.standard_v()))
|
||||
+ r#""to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionIndex":null,"#
|
||||
+ r#""type":"0x0","#
|
||||
+ &format!("\"v\":\"0x{:x}\",", U256::from(t.v()))
|
||||
+ r#""value":"0x9184e72a""#
|
||||
+ r#"}},"id":1}"#;
|
||||
|
|
|
@ -227,6 +227,7 @@ fn rpc_eth_sign_transaction() {
|
|||
+ &format!("\"s\":\"0x{:x}\",", U256::from(signature.s()))
|
||||
+ &format!("\"standardV\":\"0x{:x}\",", U256::from(t.standard_v()))
|
||||
+ r#""to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionIndex":null,"#
|
||||
+ r#""type":"0x0","#
|
||||
+ &format!("\"v\":\"0x{:x}\",", U256::from(t.v()))
|
||||
+ r#""value":"0x9184e72a""#
|
||||
+ r#"}},"id":1}"#;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "parity-version"
|
||||
# NOTE: this value is used for OpenEthereum version string (via env CARGO_PKG_VERSION)
|
||||
version = "3.3.1"
|
||||
version = "3.3.3"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
build = "build.rs"
|
||||
|
||||
|
|
Loading…
Reference in New Issue