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()),
 | 
			
		||||
            gas_used: U256::default(),
 | 
			
		||||
            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();
 | 
			
		||||
 | 
			
		||||
@ -1982,6 +1987,13 @@ impl Call for Client {
 | 
			
		||||
        let machine = self.engine.machine();
 | 
			
		||||
 | 
			
		||||
        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)?;
 | 
			
		||||
            env_info.gas_used = ret.cumulative_gas_used;
 | 
			
		||||
            results.push(ret);
 | 
			
		||||
@ -2008,7 +2020,11 @@ impl Call for Client {
 | 
			
		||||
                last_hashes: self.build_last_hashes(header.parent_hash()),
 | 
			
		||||
                gas_used: U256::default(),
 | 
			
		||||
                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)
 | 
			
		||||
 | 
			
		||||
@ -53,29 +53,22 @@ pub fn sign_call(request: CallRequest) -> Result<SignedTransaction, Error> {
 | 
			
		||||
            ))
 | 
			
		||||
        }
 | 
			
		||||
        Some(TypedTxId::EIP1559Transaction) => {
 | 
			
		||||
            if let Some(max_fee_per_gas) = request.max_fee_per_gas {
 | 
			
		||||
                tx_legacy.gas_price = max_fee_per_gas;
 | 
			
		||||
            } else {
 | 
			
		||||
                return Err(Error::new(ErrorCode::InvalidParams));
 | 
			
		||||
            }
 | 
			
		||||
            tx_legacy.gas_price = request.max_fee_per_gas.unwrap_or_default();
 | 
			
		||||
 | 
			
		||||
            if let Some(max_priority_fee_per_gas) = request.max_priority_fee_per_gas {
 | 
			
		||||
                let transaction = AccessListTx::new(
 | 
			
		||||
                    tx_legacy,
 | 
			
		||||
                    request
 | 
			
		||||
                        .access_list
 | 
			
		||||
                        .unwrap_or_default()
 | 
			
		||||
                        .into_iter()
 | 
			
		||||
                        .map(Into::into)
 | 
			
		||||
                        .collect(),
 | 
			
		||||
                );
 | 
			
		||||
                TypedTransaction::EIP1559Transaction(EIP1559TransactionTx {
 | 
			
		||||
                    transaction,
 | 
			
		||||
                    max_priority_fee_per_gas,
 | 
			
		||||
                })
 | 
			
		||||
            } else {
 | 
			
		||||
                return Err(Error::new(ErrorCode::InvalidParams));
 | 
			
		||||
            }
 | 
			
		||||
            let transaction = AccessListTx::new(
 | 
			
		||||
                tx_legacy,
 | 
			
		||||
                request
 | 
			
		||||
                    .access_list
 | 
			
		||||
                    .unwrap_or_default()
 | 
			
		||||
                    .into_iter()
 | 
			
		||||
                    .map(Into::into)
 | 
			
		||||
                    .collect(),
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            TypedTransaction::EIP1559Transaction(EIP1559TransactionTx {
 | 
			
		||||
                transaction,
 | 
			
		||||
                max_priority_fee_per_gas: request.max_priority_fee_per_gas.unwrap_or_default(),
 | 
			
		||||
            })
 | 
			
		||||
        }
 | 
			
		||||
        _ => return Err(Error::new(ErrorCode::InvalidParams)),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user