Compare commits

...

19 Commits

Author SHA1 Message Date
POA
73895aae88 Set eip1559BaseFeeMinValue for POA Core 2021-11-02 10:29:54 +03:00
POA
c5719983b2 Set eip1559BaseFeeInitialValue equal to eip1559BaseFeeMinValue for xDai 2021-11-02 09:34:53 +03:00
POA
f9b2db206a Replace eip1559BaseFeeFixedValue* spec options with eip1559BaseFeeMinValue and eip1559BaseFeeMinValueTransition 2021-11-01 13:20:58 +03:00
POA
437ba9b044 Add eip1559BaseFeeFixedValue and eip1559BaseFeeFixedValueTransition spec options and bump to v3.3.0-rc.14 2021-11-01 10:53:50 +03:00
uink45
98873fc0c0 EIP-4345 enabled (#561)
* EIP-4345 enabled

Co-authored-by: varasev <33550681+varasev@users.noreply.github.com>
2021-11-01 07:14:52 +03:00
POA
415a522429 POA Core London hard fork and bump to v3.3.0-rc.13 2021-10-29 16:37:12 +03:00
POA
646f49fdd0 xDai London hard fork and bump to v3.3.0-rc.12 2021-10-22 09:44:16 +03:00
POA
25ce4b2ec8 Enable GetNodeData for AuRa chains and bump to v3.3.0-rc.11 2021-10-19 11:25:32 +03:00
POA
ac30783c82 Add eip1559FeeCollector and eip1559FeeCollectorTransition spec options and bump to v3.3.0-rc.10 2021-10-14 16:14:38 +03:00
POA
5e9b4c58ae Bump to v3.3.0-rc.9 2021-10-04 10:43:30 +03:00
POA
74e709fd55 Fix MinGasPrice config option 2021-09-29 10:30:28 +03:00
POA
3413343caa Add service transactions support for EIP-1559 2021-09-29 10:30:28 +03:00
sunce86
8bb02dd479 small fixes 2021-09-29 10:30:27 +03:00
sunce86
79be8f1ab8 min_gas_price becomes min_effective_priority_fee (effective_gas_price - base_fee) 2021-09-29 10:30:27 +03:00
sunce86
a049baf6b2 added version 4 for TxPermission contract 2021-09-29 10:30:27 +03:00
sunce86
d8305c52ea Bump to v3.3.0-rc.8 2021-09-03 17:07:40 +02:00
Jochen Müller
239d790df1 Ignore GetNodeData requests (#519) 2021-09-03 16:43:33 +02:00
Jochen Müller
298a1a0ecc Bump to v3.3.0-rc.7 2021-08-23 14:03:36 +02:00
Jochen Müller
36b3f125a4 Fix wrong sync packet id (#514) 2021-08-23 13:54:25 +02:00
28 changed files with 624 additions and 59 deletions

View File

@@ -1,3 +1,51 @@
## OpenEthereum v3.3.0-rc.14
Enhancements:
* Add eip1559BaseFeeMinValue and eip1559BaseFeeMinValueTransition spec options
* Activate eip1559BaseFeeMinValue on xDai at London hardfork block (19040000), set it to 20 GWei
* Activate eip1559BaseFeeMinValue on POA Core at block 24199500 (November 8, 2021), set it to 10 GWei
* Delay difficulty bomb to June 2022 for Ethereum Mainnet (EIP-4345)
## OpenEthereum v3.3.0-rc.13
Enhancements:
* London hardfork block: POA Core (24090200)
## OpenEthereum v3.3.0-rc.12
Enhancements:
* London hardfork block: xDai (19040000)
## OpenEthereum v3.3.0-rc.11
Bug fixes:
* Ignore GetNodeData requests only for non-AuRa chains
## OpenEthereum v3.3.0-rc.10
Enhancements:
* Add eip1559FeeCollector and eip1559FeeCollectorTransition spec options
## OpenEthereum v3.3.0-rc.9
Bug fixes:
* Add service transactions support for EIP-1559
* Fix MinGasPrice config option for POSDAO and EIP-1559
Enhancements:
* min_gas_price becomes min_effective_priority_fee
* added version 4 for TxPermission contract
## OpenEthereum v3.3.0-rc.8
Bug fixes:
* Ignore GetNodeData requests (#519)
## OpenEthereum v3.3.0-rc.7
Bug fixes:
* GetPooledTransactions is sent in invalid form (wrong packet id)
## OpenEthereum v3.3.0-rc.6
Enhancements:

6
Cargo.lock generated
View File

@@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "addr2line"
version = "0.14.1"
@@ -2930,7 +2932,7 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "openethereum"
version = "3.3.0-rc.6"
version = "3.3.0-rc.14"
dependencies = [
"ansi_term 0.10.2",
"atty",
@@ -3280,7 +3282,7 @@ dependencies = [
[[package]]
name = "parity-version"
version = "3.3.0-rc.6"
version = "3.3.0-rc.14"
dependencies = [
"parity-bytes",
"rlp",

View File

@@ -2,7 +2,7 @@
description = "OpenEthereum"
name = "openethereum"
# NOTE Make sure to update util/version/Cargo.toml as well
version = "3.3.0-rc.6"
version = "3.3.0-rc.14"
license = "GPL-3.0"
authors = [
"OpenEthereum developers",

View File

@@ -680,7 +680,7 @@ usage! {
ARG arg_min_gas_price: (Option<u64>) = None, or |c: &Config| c.mining.as_ref()?.min_gas_price.clone(),
"--min-gas-price=[STRING]",
"Minimum amount of Wei per GAS to be paid for a transaction to be accepted for mining. Overrides --usd-per-tx.",
"Minimum amount of Wei per GAS to be paid for a transaction on top of base fee, to be accepted for mining. Overrides --usd-per-tx.",
ARG arg_gas_price_percentile: (usize) = 50usize, or |c: &Config| c.mining.as_ref()?.gas_price_percentile,
"--gas-price-percentile=[PCT]",

View File

@@ -188,6 +188,10 @@ impl txpool::VerifiedTransaction for VerifiedTransaction {
fn sender(&self) -> &Address {
&self.sender
}
fn is_service(&self) -> bool {
self.transaction.is_service()
}
}
impl ScoredTransaction for VerifiedTransaction {

View File

@@ -659,7 +659,10 @@ impl TransactionQueue {
Some(tx) => tx
.signed()
.effective_gas_price(self.options.read().block_base_fee),
None => self.options.read().minimal_gas_price,
None => {
self.options.read().minimal_gas_price
+ self.options.read().block_base_fee.unwrap_or_default()
}
}
}

View File

@@ -42,7 +42,7 @@ use super::{
/// Verification options.
#[derive(Debug, Clone, PartialEq)]
pub struct Options {
/// Minimal allowed gas price.
/// Minimal allowed gas price (actually minimal block producer reward = effective_priority_fee).
pub minimal_gas_price: U256,
/// Current block gas limit.
pub block_gas_limit: U256,
@@ -122,6 +122,24 @@ impl Transaction {
}
}
/// Return effective fee - part of the transaction fee that goes to the miner
pub fn effective_priority_fee(&self, block_base_fee: Option<U256>) -> U256 {
match *self {
Transaction::Unverified(ref tx) => tx.effective_priority_fee(block_base_fee),
Transaction::Retracted(ref tx) => tx.effective_priority_fee(block_base_fee),
Transaction::Local(ref tx) => tx.effective_priority_fee(block_base_fee),
}
}
/// Cheeck if transaction is service transaction
pub fn is_service(&self) -> bool {
match *self {
Transaction::Unverified(ref tx) => tx.is_service(),
Transaction::Retracted(ref tx) => tx.is_service(),
Transaction::Local(ref tx) => tx.is_service(),
}
}
fn transaction(&self) -> &transaction::TypedTransaction {
match *self {
Transaction::Unverified(ref tx) => &*tx,
@@ -225,24 +243,26 @@ impl<C: Client> txpool::Verifier<Transaction>
}
let is_own = tx.is_local();
let gas_price = tx.effective_gas_price(self.options.block_base_fee);
let is_service = tx.is_service();
// Quick exit for non-service and non-local transactions
//
// We're checking if the transaction is below configured minimal gas price
// or the effective minimal gas price in case the pool is full.
if !gas_price.is_zero() && !is_own {
if gas_price < self.options.minimal_gas_price {
if !is_service && !is_own {
let effective_priority_fee = tx.effective_priority_fee(self.options.block_base_fee);
if effective_priority_fee < self.options.minimal_gas_price {
trace!(
target: "txqueue",
"[{:?}] Rejected tx below minimal gas price threshold: {} < {}",
hash,
gas_price,
effective_priority_fee,
self.options.minimal_gas_price,
);
bail!(transaction::Error::InsufficientGasPrice {
minimal: self.options.minimal_gas_price,
got: gas_price,
got: effective_priority_fee,
});
}
@@ -252,7 +272,7 @@ impl<C: Client> txpool::Verifier<Transaction>
target: "txqueue",
"[{:?}] Rejected tx early, cause it doesn't have any chance to get to the pool: (gas price: {} < {})",
hash,
gas_price,
tx.effective_gas_price(self.options.block_base_fee),
vtx.transaction.effective_gas_price(self.options.block_base_fee),
);
return Err(transaction::Error::TooCheapToReplace {
@@ -260,7 +280,7 @@ impl<C: Client> txpool::Verifier<Transaction>
vtx.transaction
.effective_gas_price(self.options.block_base_fee),
),
new: Some(gas_price),
new: Some(tx.effective_gas_price(self.options.block_base_fee)),
});
}
}
@@ -297,9 +317,10 @@ impl<C: Client> txpool::Verifier<Transaction>
let sender = transaction.sender();
let account_details = self.client.account_details(&sender);
let gas_price = transaction.tx().gas_price;
let effective_priority_fee =
transaction.effective_priority_fee(self.options.block_base_fee);
if gas_price < self.options.minimal_gas_price {
if effective_priority_fee < self.options.minimal_gas_price {
let transaction_type = self.client.transaction_type(&transaction);
if let TransactionType::Service = transaction_type {
debug!(target: "txqueue", "Service tx {:?} below minimal gas price accepted", hash);
@@ -310,16 +331,18 @@ impl<C: Client> txpool::Verifier<Transaction>
target: "txqueue",
"[{:?}] Rejected tx below minimal gas price threshold: {} < {}",
hash,
gas_price,
effective_priority_fee,
self.options.minimal_gas_price,
);
bail!(transaction::Error::InsufficientGasPrice {
minimal: self.options.minimal_gas_price,
got: gas_price,
got: effective_priority_fee,
});
}
}
let gas_price = transaction.tx().gas_price;
if gas_price < transaction.max_priority_fee_per_gas() {
bail!(transaction::Error::InsufficientGasPrice {
minimal: transaction.max_priority_fee_per_gas(),

View File

@@ -138,7 +138,8 @@
"0x42ae50": "0x2dc6c0",
"0x6f1580": "0x1e8480",
"0x8c6180": "0x3d0900",
"0xc5d488": "0xaae60"
"0xc5d488": "0xaae60",
"0xd228c8": "0xf4240"
}
}
}

View File

@@ -47,7 +47,18 @@
"eip1884Transition": 12598600,
"eip2028Transition": 12598600,
"eip2929Transition": 21364900,
"eip2930Transition": 21364900
"eip2930Transition": 21364900,
"eip3198Transition": 24090200,
"eip3529Transition": 24090200,
"eip3541Transition": 24090200,
"eip1559Transition": 24090200,
"eip1559BaseFeeMaxChangeDenominator": "0x8",
"eip1559ElasticityMultiplier": "0x2",
"eip1559BaseFeeInitialValue": "0x3b9aca00",
"eip1559BaseFeeMinValue": "0x2540be400",
"eip1559BaseFeeMinValueTransition": 24199500,
"eip1559FeeCollector": "0x517F3AcfF3aFC2fb45e574718bca6F919b798e10",
"eip1559FeeCollectorTransition": 24090200
},
"genesis": {
"seal": {

View File

@@ -0,0 +1,65 @@
pragma solidity ^0.4.20;
// Adapted from https://gist.github.com/VladLupashevskyi/84f18eabb1e4afadf572cf92af3e7e7f
// and: https://github.com/poanetwork/posdao-contracts/blob/master/contracts/TxPermission.sol
contract TxPermission {
/// Allowed transaction types mask
uint32 constant None = 0;
uint32 constant All = 0xffffffff;
uint32 constant Basic = 0x01;
uint32 constant Call = 0x02;
uint32 constant Create = 0x04;
uint32 constant Private = 0x08;
/// Contract name
function contractName() public constant returns (string) {
return "TX_PERMISSION_CONTRACT";
}
/// Contract name hash
function contractNameHash() public constant returns (bytes32) {
return keccak256(contractName());
}
/// Contract version
function contractVersion() public constant returns (uint256) {
return 4;
}
/// @dev Defines the allowed transaction types which may be initiated by the specified sender with
/// the specified gas price and data. Used by node's engine each time a transaction is about to be
/// included into a block. See https://openethereum.github.io/Permissioning.html#how-it-works-1
/// @param _sender Transaction sender address.
/// @param _to Transaction recipient address. If creating a contract, the `_to` address is zero.
/// @param _value Transaction amount in wei.
/// @param _maxFeePerGas The `maxFeePerGas` in Wei for EIP-1559 transaction, or gas price for a legacy transaction.
/// @param _maxInclusionFeePerGas The `maxInclusionFeePerGas` in Wei for EIP-1559 transaction.
/// Equals to gas price for a legacy transaction.
/// @param _gasLimit Gas limit for the transaction.
/// @param _data Transaction data.
/// @return `uint32 typesMask` - Set of allowed transactions for `_sender` depending on tx `_to` address,
/// `_gasPrice`, and `_data`. The result is represented as a set of flags:
/// 0x01 - basic transaction (e.g. ether transferring to user wallet);
/// 0x02 - contract call;
/// 0x04 - contract creation;
/// 0x08 - private transaction.
/// `bool cache` - If `true` is returned, the same permissions will be applied from the same
/// `_sender` without calling this contract again.
function allowedTxTypes(
address _sender,
address _to,
uint256 _value,
uint256 _maxFeePerGas, // equals to gasPrice for legacy transactions
uint256 _maxInclusionFeePerGas, // equals to gasPrice for legacy transactions
uint256 _gasLimit,
bytes memory _data
)
public
view
returns(uint32 typesMask, bool cache)
{
if (_maxFeePerGas > 0 || _data.length < 4) return (All, false);
return (None, false);
}
}

View File

@@ -0,0 +1,44 @@
{
"name": "TestNodeFilterContract",
"engine": {
"authorityRound": {
"params": {
"stepDuration": 1,
"startStep": 2,
"validators": {
"contract": "0x0000000000000000000000000000000000000000"
}
}
}
},
"params": {
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x69",
"gasLimitBoundDivisor": "0x0400",
"transactionPermissionContract": "0xAB5b100cf7C8deFB3c8f3C48474223997A50fB13",
"transactionPermissionContractTransition": "1"
},
"genesis": {
"seal": {
"generic": "0xc180"
},
"difficulty": "0x20000",
"author": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x222222"
},
"accounts": {
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
"0xAB5b100cf7C8deFB3c8f3C48474223997A50fB13": {
"balance": "1",
"constructor": "608060405234801561001057600080fd5b50610370806100206000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063469ab1e31461006757806375d0c0dc1461009a578063a0a8e4601461012a578063e4e3b5e514610155575b600080fd5b34801561007357600080fd5b5061007c610251565b60405180826000191660001916815260200191505060405180910390f35b3480156100a657600080fd5b506100af6102c2565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100ef5780820151818401526020810190506100d4565b50505050905090810190601f16801561011c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013657600080fd5b5061013f6102ff565b6040518082815260200191505060405180910390f35b34801561016157600080fd5b50610224600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610308565b604051808363ffffffff1663ffffffff168152602001821515151581526020019250505060405180910390f35b600061025b6102c2565b6040518082805190602001908083835b602083101515610290578051825260208201915060208101905060208303925061026b565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020905090565b60606040805190810160405280601681526020017f54585f5045524d495353494f4e5f434f4e545241435400000000000000000000815250905090565b60006004905090565b600080600086118061031b575060048351105b156103305763ffffffff600091509150610338565b600080915091505b975097955050505050505600a165627a7a72305820592b45ee74cc856b6c84f99ed8ddd4790d844a9065a07c7bbfc5dfa05cc394c50029"
}
}
}

View File

@@ -56,6 +56,17 @@
"eip2028Transition": 7298030,
"eip2929Transition": 16101500,
"eip2930Transition": 16101500,
"eip3198Transition": 19040000,
"eip3529Transition": 19040000,
"eip3541Transition": 19040000,
"eip1559Transition": 19040000,
"eip1559BaseFeeMaxChangeDenominator": "0x8",
"eip1559ElasticityMultiplier": "0x2",
"eip1559BaseFeeInitialValue": "0x4a817c800",
"eip1559BaseFeeMinValue": "0x4a817c800",
"eip1559BaseFeeMinValueTransition": 19040000,
"eip1559FeeCollector": "0x6BBe78ee9e474842Dbd4AB4987b3CeFE88426A92",
"eip1559FeeCollectorTransition": 19040000,
"registrar": "0x6B53721D4f2Fb9514B85f5C49b197D857e36Cf03",
"transactionPermissionContract": "0x7Dd7032AA75A37ea0b150f57F899119C7379A78b",
"transactionPermissionContractTransition": 9186425

View File

@@ -0,0 +1,91 @@
[
{
"constant": true,
"inputs": [],
"name": "contractNameHash",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "contractName",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "contractVersion",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "sender",
"type": "address"
},
{
"name": "to",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "maxFeePerGas",
"type": "uint256"
},
{
"name": "maxPriorityFeePerGas",
"type": "uint256"
},
{
"name": "gasLimit",
"type": "uint256"
},
{
"name": "data",
"type": "bytes"
}
],
"name": "allowedTxTypes",
"outputs": [
{
"name": "",
"type": "uint32"
},
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]

View File

@@ -1955,7 +1955,7 @@ impl Call for Client {
gas_used: U256::default(),
gas_limit: U256::max_value(),
//if gas pricing is not defined, force base_fee to zero
base_fee: if transaction.effective_gas_price(header.base_fee()) == 0.into() {
base_fee: if transaction.effective_gas_price(header.base_fee()).is_zero() {
Some(0.into())
} else {
header.base_fee()
@@ -1988,7 +1988,7 @@ impl Call for Client {
for &(ref t, analytics) in transactions {
//if gas pricing is not defined, force base_fee to zero
if t.effective_gas_price(header.base_fee()) == 0.into() {
if t.effective_gas_price(header.base_fee()).is_zero() {
env_info.base_fee = Some(0.into());
} else {
env_info.base_fee = header.base_fee()
@@ -2020,7 +2020,7 @@ impl Call for Client {
last_hashes: self.build_last_hashes(header.parent_hash()),
gas_used: U256::default(),
gas_limit: max,
base_fee: if t.effective_gas_price(header.base_fee()) == 0.into() {
base_fee: if t.effective_gas_price(header.base_fee()).is_zero() {
Some(0.into())
} else {
header.base_fee()
@@ -2234,6 +2234,11 @@ 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

View File

@@ -258,6 +258,9 @@ 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>;

View File

@@ -1207,7 +1207,7 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
}
// ensure that the user was willing to at least pay the base fee
if t.tx().gas_price < self.info.base_fee.unwrap_or_default() {
if t.tx().gas_price < self.info.base_fee.unwrap_or_default() && !t.is_service() {
return Err(ExecutionError::GasPriceLowerThanBaseFee {
gas_price: t.tx().gas_price,
base_fee: self.info.base_fee.unwrap_or_default(),
@@ -1516,18 +1516,20 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
// Up until now, fees_value is calculated for each type of transaction based on their gas prices
// Now, if eip1559 is activated, burn the base fee
// miner only receives the inclusion fee; note that the base fee is not given to anyone (it is burned)
let fees_value = fees_value.saturating_sub(if schedule.eip1559 {
let (base_fee, overflow_3) =
let burnt_fee = if schedule.eip1559 && !t.is_service() {
let (fee, overflow_3) =
gas_used.overflowing_mul(self.info.base_fee.unwrap_or_default());
if overflow_3 {
return Err(ExecutionError::TransactionMalformed(
"U256 Overflow".to_string(),
));
}
base_fee
fee
} else {
U256::from(0)
});
};
let fees_value = fees_value.saturating_sub(burnt_fee);
trace!("exec::finalize: t.gas={}, sstore_refunds={}, suicide_refunds={}, refunds_bound={}, gas_left_prerefund={}, refunded={}, gas_left={}, gas_used={}, refund_value={}, fees_value={}\n",
t.tx().gas, sstore_refunds, suicide_refunds, refunds_bound, gas_left_prerefund, refunded, gas_left, gas_used, refund_value, fees_value);
@@ -1552,6 +1554,17 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
substate.to_cleanup_mode(&schedule),
)?;
if burnt_fee > U256::from(0)
&& self.machine.params().eip1559_fee_collector.is_some()
&& self.info.number >= self.machine.params().eip1559_fee_collector_transition
{
self.state.add_balance(
&self.machine.params().eip1559_fee_collector.unwrap(),
&burnt_fee,
substate.to_cleanup_mode(&schedule),
)?;
};
// perform suicides
for address in &substate.suicides {
self.state.kill_account(address);

View File

@@ -376,7 +376,7 @@ impl EthereumMachine {
header: &Header,
) -> Result<SignedTransaction, transaction::Error> {
// ensure that the user was willing to at least pay the base fee
if t.tx().gas_price < header.base_fee().unwrap_or_default() {
if t.tx().gas_price < header.base_fee().unwrap_or_default() && !t.is_service() {
return Err(transaction::Error::GasPriceLowerThanBaseFee {
gas_price: t.tx().gas_price,
base_fee: header.base_fee().unwrap_or_default(),
@@ -466,15 +466,32 @@ impl EthereumMachine {
/// Base fee is calculated based on the parent header (last block in blockchain / best block).
///
/// Introduced by EIP1559 to support new market fee mechanism.
///
/// Modified for xDai chain to have an ability to set min base fee
/// through eip1559BaseFeeMinValue spec option. The modification made
/// in v3.3.0-rc.14
pub fn calc_base_fee(&self, parent: &Header) -> Option<U256> {
// Block eip1559_transition - 1 has base_fee = None
if parent.number() + 1 < self.params().eip1559_transition {
return None;
}
let base_fee_min_value =
if parent.number() + 1 >= self.params().eip1559_base_fee_min_value_transition {
match self.params().eip1559_base_fee_min_value {
None => panic!("Base fee min value must be set in spec."),
Some(min_value) => min_value,
}
} else {
U256::zero()
};
// Block eip1559_transition has base_fee = self.params().eip1559_base_fee_initial_value
if parent.number() + 1 == self.params().eip1559_transition {
return Some(self.params().eip1559_base_fee_initial_value);
return Some(max(
self.params().eip1559_base_fee_initial_value,
base_fee_min_value,
));
}
// Block eip1559_transition + 1 has base_fee = calculated
@@ -492,21 +509,23 @@ impl EthereumMachine {
panic!("Can't calculate base fee if parent gas target is zero.");
}
if parent.gas_used() == &parent_gas_target {
Some(parent_base_fee)
let result = if parent.gas_used() == &parent_gas_target {
parent_base_fee
} else if parent.gas_used() > &parent_gas_target {
let gas_used_delta = parent.gas_used() - parent_gas_target;
let base_fee_per_gas_delta = max(
parent_base_fee * gas_used_delta / parent_gas_target / base_fee_denominator,
U256::from(1),
);
Some(parent_base_fee + base_fee_per_gas_delta)
parent_base_fee + base_fee_per_gas_delta
} else {
let gas_used_delta = parent_gas_target - parent.gas_used();
let base_fee_per_gas_delta =
parent_base_fee * gas_used_delta / parent_gas_target / base_fee_denominator;
Some(max(parent_base_fee - base_fee_per_gas_delta, U256::zero()))
}
max(parent_base_fee - base_fee_per_gas_delta, U256::zero())
};
Some(max(result, base_fee_min_value))
}
}

View File

@@ -183,6 +183,14 @@ pub struct CommonParams {
pub eip1559_elasticity_multiplier: U256,
/// Default value for the block base fee
pub eip1559_base_fee_initial_value: U256,
/// Min value for the block base fee.
pub eip1559_base_fee_min_value: Option<U256>,
/// Block at which the min value for the base fee starts to be used.
pub eip1559_base_fee_min_value_transition: BlockNumber,
/// Address where EIP-1559 burnt fee will be accrued to.
pub eip1559_fee_collector: Option<Address>,
/// Block at which the fee collector should start being used.
pub eip1559_fee_collector_transition: BlockNumber,
}
impl CommonParams {
@@ -459,6 +467,14 @@ impl From<ethjson::spec::Params> for CommonParams {
eip1559_base_fee_initial_value: p
.eip1559_base_fee_initial_value
.map_or_else(U256::zero, Into::into),
eip1559_base_fee_min_value: p.eip1559_base_fee_min_value.map(Into::into),
eip1559_base_fee_min_value_transition: p
.eip1559_base_fee_min_value_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip1559_fee_collector: p.eip1559_fee_collector.map(Into::into),
eip1559_fee_collector_transition: p
.eip1559_fee_collector_transition
.map_or_else(BlockNumber::max_value, Into::into),
}
}
}
@@ -734,6 +750,8 @@ impl Spec {
params.kip6_transition,
params.max_code_size_transition,
params.transaction_permission_contract_transition,
params.eip1559_fee_collector_transition,
params.eip1559_base_fee_min_value_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

@@ -39,6 +39,7 @@ use_contract!(
transact_acl_gas_price,
"res/contracts/tx_acl_gas_price.json"
);
use_contract!(transact_acl_1559, "res/contracts/tx_acl_1559.json");
const MAX_CACHE_SIZE: usize = 4096;
@@ -104,6 +105,8 @@ impl TransactionFilter {
let sender = transaction.sender();
let value = transaction.tx().value;
let gas_price = transaction.tx().gas_price;
let max_priority_fee_per_gas = transaction.max_priority_fee_per_gas();
let gas_limit = transaction.tx().gas;
let key = (*parent_hash, sender);
if let Some(permissions) = permission_cache.get_mut(&key) {
@@ -161,6 +164,25 @@ impl TransactionFilter {
(tx_permissions::NONE, true)
})
}
4 => {
trace!(target: "tx_filter", "Using filter with maxFeePerGas and maxPriorityFeePerGas and data");
let (data, decoder) = transact_acl_1559::functions::allowed_tx_types::call(
sender,
to,
value,
gas_price,
max_priority_fee_per_gas,
gas_limit,
transaction.tx().data.clone(),
);
client.call_contract(BlockId::Hash(*parent_hash), contract_address, data)
.and_then(|value| decoder.decode(&value).map_err(|e| e.to_string()))
.map(|(p, f)| (p.low_u32(), f))
.unwrap_or_else(|e| {
error!(target: "tx_filter", "Error calling tx permissions contract: {:?}", e);
(tx_permissions::NONE, true)
})
}
_ => {
error!(target: "tx_filter", "Unknown version of tx permissions contract is used");
(tx_permissions::NONE, true)
@@ -201,7 +223,9 @@ mod test {
use std::{str::FromStr, sync::Arc};
use tempdir::TempDir;
use test_helpers;
use types::transaction::{Action, Transaction, TypedTransaction};
use types::transaction::{
AccessListTx, Action, EIP1559TransactionTx, Transaction, TypedTransaction,
};
/// Contract code: https://gist.github.com/VladLupashevskyi/84f18eabb1e4afadf572cf92af3e7e7f
#[test]
@@ -438,7 +462,7 @@ mod test {
));
}
/// Contract code: res/tx_permission_tests/contract_ver_3.sol
/// Contract code: res/chainspec/test/contract_ver_3.sol
#[test]
fn transaction_filter_ver_3() {
let spec_data = include_str!("../res/chainspec/test/contract_ver_3_genesis.json");
@@ -506,6 +530,145 @@ mod test {
));
}
/// Contract code: res/chainspec/test/contract_ver_4.sol
#[test]
fn transaction_filter_ver_4_legacy() {
let spec_data = include_str!("../res/chainspec/test/contract_ver_4_genesis.json");
let db = test_helpers::new_db();
let tempdir = TempDir::new("").unwrap();
let spec = Spec::load(&tempdir.path(), spec_data.as_bytes()).unwrap();
let client = Client::new(
ClientConfig::default(),
&spec,
db,
Arc::new(Miner::new_for_tests(&spec, None)),
IoChannel::disconnected(),
)
.unwrap();
let key1 = KeyPair::from_secret(
Secret::from_str("0000000000000000000000000000000000000000000000000000000000000001")
.unwrap(),
)
.unwrap();
// The only difference to version 2 is that the contract now knows the transaction's gas price and data.
// So we only test those: The contract allows only transactions with either nonzero gas price or short data.
let filter = TransactionFilter::from_params(spec.params()).unwrap();
let mut tx = TypedTransaction::Legacy(Transaction::default());
tx.tx_mut().action =
Action::Call(Address::from_str("0000000000000000000000000000000000000042").unwrap());
tx.tx_mut().data = b"01234567".to_vec();
tx.tx_mut().gas_price = 0.into();
let genesis = client.block_hash(BlockId::Latest).unwrap();
let block_number = 1;
// Data too long and gas price zero. This transaction is not allowed.
assert!(!filter.transaction_allowed(
&genesis,
block_number,
&tx.clone().sign(key1.secret(), None),
&*client
));
// But if we either set a nonzero gas price or short data or both, it is allowed.
tx.tx_mut().gas_price = 1.into();
assert!(filter.transaction_allowed(
&genesis,
block_number,
&tx.clone().sign(key1.secret(), None),
&*client
));
tx.tx_mut().data = b"01".to_vec();
assert!(filter.transaction_allowed(
&genesis,
block_number,
&tx.clone().sign(key1.secret(), None),
&*client
));
tx.tx_mut().gas_price = 0.into();
assert!(filter.transaction_allowed(
&genesis,
block_number,
&tx.clone().sign(key1.secret(), None),
&*client
));
}
/// Contract code: res/chainspec/test/contract_ver_4.sol
#[test]
fn transaction_filter_ver_4_1559() {
let spec_data = include_str!("../res/chainspec/test/contract_ver_4_genesis.json");
let db = test_helpers::new_db();
let tempdir = TempDir::new("").unwrap();
let spec = Spec::load(&tempdir.path(), spec_data.as_bytes()).unwrap();
let client = Client::new(
ClientConfig::default(),
&spec,
db,
Arc::new(Miner::new_for_tests(&spec, None)),
IoChannel::disconnected(),
)
.unwrap();
let key1 = KeyPair::from_secret(
Secret::from_str("0000000000000000000000000000000000000000000000000000000000000001")
.unwrap(),
)
.unwrap();
// The only difference to version 2 is that the contract now knows the transaction's gas price and data.
// So we only test those: The contract allows only transactions with either nonzero gas price or short data.
let filter = TransactionFilter::from_params(spec.params()).unwrap();
let mut tx = TypedTransaction::EIP1559Transaction(EIP1559TransactionTx {
transaction: AccessListTx::new(Transaction::default(), vec![]),
max_priority_fee_per_gas: U256::from(0),
});
tx.tx_mut().action =
Action::Call(Address::from_str("0000000000000000000000000000000000000042").unwrap());
tx.tx_mut().data = b"01234567".to_vec();
tx.tx_mut().gas_price = 0.into();
let genesis = client.block_hash(BlockId::Latest).unwrap();
let block_number = 1;
// Data too long and gas price zero. This transaction is not allowed.
assert!(!filter.transaction_allowed(
&genesis,
block_number,
&tx.clone().sign(key1.secret(), None),
&*client
));
// But if we either set a nonzero gas price or short data or both, it is allowed.
tx.tx_mut().gas_price = 1.into();
assert!(filter.transaction_allowed(
&genesis,
block_number,
&tx.clone().sign(key1.secret(), None),
&*client
));
tx.tx_mut().data = b"01".to_vec();
assert!(filter.transaction_allowed(
&genesis,
block_number,
&tx.clone().sign(key1.secret(), None),
&*client
));
tx.tx_mut().gas_price = 0.into();
assert!(filter.transaction_allowed(
&genesis,
block_number,
&tx.clone().sign(key1.secret(), None),
&*client
));
}
/// Contract code: https://gist.github.com/arkpar/38a87cb50165b7e683585eec71acb05a
#[test]
fn transaction_filter_deprecated() {

View File

@@ -86,7 +86,7 @@ mod tests {
|| ethereum::new_foundation(&String::new()),
vec![
1_150_000, 1_920_000, 2_463_000, 2_675_000, 4_370_000, 7_280_000, 9_069_000,
9_200_000, 12_244_000, 12_965_000,
9_200_000, 12_244_000, 12_965_000, 13_773_000,
],
)
}

View File

@@ -124,7 +124,7 @@ impl SyncRequester {
io,
peer_id,
PeerAsking::PooledTransactions,
PooledTransactionsPacket,
GetPooledTransactionsPacket,
rlp.out(),
)
}

View File

@@ -351,29 +351,36 @@ impl SyncSupplier {
}
fn return_node_data(io: &dyn SyncIo, rlp: &Rlp, peer_id: PeerId) -> RlpResponseResult {
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);
}
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 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 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)))
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)
}
}
fn return_receipts(io: &dyn SyncIo, rlp: &Rlp, peer_id: PeerId) -> RlpResponseResult {

View File

@@ -651,6 +651,22 @@ impl TypedTransaction {
}
}
pub fn effective_priority_fee(&self, block_base_fee: Option<U256>) -> U256 {
self.effective_gas_price(block_base_fee)
.checked_sub(block_base_fee.unwrap_or_default())
.unwrap_or_default()
}
pub fn is_service(&self) -> bool {
match self {
Self::EIP1559Transaction(tx) => {
tx.tx().gas_price.is_zero() && tx.max_priority_fee_per_gas.is_zero()
}
Self::AccessList(tx) => tx.tx().gas_price.is_zero(),
Self::Legacy(tx) => tx.gas_price.is_zero(),
}
}
fn decode_new(tx: &[u8]) -> Result<UnverifiedTransaction, DecoderError> {
if tx.is_empty() {
// at least one byte needs to be present

View File

@@ -158,6 +158,14 @@ pub struct Params {
pub eip1559_elasticity_multiplier: Option<Uint>,
/// Default value for the block base fee
pub eip1559_base_fee_initial_value: Option<Uint>,
/// Min value for the block base fee.
pub eip1559_base_fee_min_value: Option<Uint>,
/// Block at which the min value for the base fee starts to be used.
pub eip1559_base_fee_min_value_transition: Option<Uint>,
/// Address where EIP-1559 burnt fee will be accrued to.
pub eip1559_fee_collector: Option<Address>,
/// Block at which the fee collector should start being used.
pub eip1559_fee_collector_transition: Option<Uint>,
}
#[cfg(test)]

View File

@@ -113,4 +113,7 @@ pub trait VerifiedTransaction: fmt::Debug {
/// Transaction sender
fn sender(&self) -> &Self::Sender;
/// Is it a service transaction?
fn is_service(&self) -> bool;
}

View File

@@ -650,7 +650,9 @@ where
match self.ready.is_ready(&tx) {
Readiness::Ready => {
//return transaction with score higher or equal to desired
if score >= &self.includable_boundary {
if score >= &self.includable_boundary
|| tx.transaction.is_service()
{
return Some(tx.transaction.clone());
}
}
@@ -737,7 +739,9 @@ where
if tx_state == Readiness::Ready {
//return transaction with score higher or equal to desired
if best.score >= self.includable_boundary {
if best.score >= self.includable_boundary
|| best.transaction.transaction.is_service()
{
return Some(best.transaction.transaction);
}
}

View File

@@ -50,6 +50,9 @@ impl VerifiedTransaction for Transaction {
fn sender(&self) -> &Address {
&self.sender
}
fn is_service(&self) -> bool {
false
}
}
pub type SharedTransaction = Arc<Transaction>;

View File

@@ -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.0-rc.6"
version = "3.3.0-rc.14"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"