forcing base fee to zero if gas pricing is omitted (#460)
* forcing base fee to zero if gas pricing is omitted * force base fee to zero for estimate_gas
This commit is contained in:
parent
287409f9f5
commit
eec38b30e3
@ -1954,7 +1954,12 @@ impl Call for Client {
|
|||||||
last_hashes: self.build_last_hashes(header.parent_hash()),
|
last_hashes: self.build_last_hashes(header.parent_hash()),
|
||||||
gas_used: U256::default(),
|
gas_used: U256::default(),
|
||||||
gas_limit: U256::max_value(),
|
gas_limit: U256::max_value(),
|
||||||
base_fee: header.base_fee(),
|
//if gas pricing is not defined, force base_fee to zero
|
||||||
|
base_fee: if transaction.effective_gas_price(header.base_fee()) == 0.into() {
|
||||||
|
Some(0.into())
|
||||||
|
} else {
|
||||||
|
header.base_fee()
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let machine = self.engine.machine();
|
let machine = self.engine.machine();
|
||||||
|
|
||||||
@ -1982,6 +1987,13 @@ impl Call for Client {
|
|||||||
let machine = self.engine.machine();
|
let machine = self.engine.machine();
|
||||||
|
|
||||||
for &(ref t, analytics) in transactions {
|
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() {
|
||||||
|
env_info.base_fee = Some(0.into());
|
||||||
|
} else {
|
||||||
|
env_info.base_fee = header.base_fee()
|
||||||
|
}
|
||||||
|
|
||||||
let ret = Self::do_virtual_call(machine, &env_info, state, t, analytics)?;
|
let ret = Self::do_virtual_call(machine, &env_info, state, t, analytics)?;
|
||||||
env_info.gas_used = ret.cumulative_gas_used;
|
env_info.gas_used = ret.cumulative_gas_used;
|
||||||
results.push(ret);
|
results.push(ret);
|
||||||
@ -2008,7 +2020,11 @@ impl Call for Client {
|
|||||||
last_hashes: self.build_last_hashes(header.parent_hash()),
|
last_hashes: self.build_last_hashes(header.parent_hash()),
|
||||||
gas_used: U256::default(),
|
gas_used: U256::default(),
|
||||||
gas_limit: max,
|
gas_limit: max,
|
||||||
base_fee: header.base_fee(),
|
base_fee: if t.effective_gas_price(header.base_fee()) == 0.into() {
|
||||||
|
Some(0.into())
|
||||||
|
} else {
|
||||||
|
header.base_fee()
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
(init, max, env_info)
|
(init, max, env_info)
|
||||||
|
@ -53,13 +53,8 @@ pub fn sign_call(request: CallRequest) -> Result<SignedTransaction, Error> {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
Some(TypedTxId::EIP1559Transaction) => {
|
Some(TypedTxId::EIP1559Transaction) => {
|
||||||
if let Some(max_fee_per_gas) = request.max_fee_per_gas {
|
tx_legacy.gas_price = request.max_fee_per_gas.unwrap_or_default();
|
||||||
tx_legacy.gas_price = max_fee_per_gas;
|
|
||||||
} else {
|
|
||||||
return Err(Error::new(ErrorCode::InvalidParams));
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(max_priority_fee_per_gas) = request.max_priority_fee_per_gas {
|
|
||||||
let transaction = AccessListTx::new(
|
let transaction = AccessListTx::new(
|
||||||
tx_legacy,
|
tx_legacy,
|
||||||
request
|
request
|
||||||
@ -69,13 +64,11 @@ pub fn sign_call(request: CallRequest) -> Result<SignedTransaction, Error> {
|
|||||||
.map(Into::into)
|
.map(Into::into)
|
||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
|
|
||||||
TypedTransaction::EIP1559Transaction(EIP1559TransactionTx {
|
TypedTransaction::EIP1559Transaction(EIP1559TransactionTx {
|
||||||
transaction,
|
transaction,
|
||||||
max_priority_fee_per_gas,
|
max_priority_fee_per_gas: request.max_priority_fee_per_gas.unwrap_or_default(),
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
return Err(Error::new(ErrorCode::InvalidParams));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => return Err(Error::new(ErrorCode::InvalidParams)),
|
_ => return Err(Error::new(ErrorCode::InvalidParams)),
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user