Skip to content

Commit

Permalink
Workaround for go-ethereum problem with gas estimation
Browse files Browse the repository at this point in the history
When estimating gas price in `go-ethereum` ABI, `tx.gasprice` is not
passed to the function doing the estimation. This leads to incorrect gas
estimates when code execution path depends on `tx.gasprice`.

This was fixed today in
ethereum/go-ethereum#20189

We need to make a workaround in the contract code before this fix will
be released.
  • Loading branch information
pdyraga committed Oct 21, 2019
1 parent c936e50 commit 7e27303
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion contracts/solidity/contracts/KeepRandomBeaconOperator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,14 @@ contract KeepRandomBeaconOperator {
* be returned to the DKG fee pool of the service contract which triggered the DKG.
*/
function reimburseDkgSubmitter() internal {
uint256 gasPrice = tx.gasprice < priceFeedEstimate ? tx.gasprice : priceFeedEstimate;
uint256 gasPrice = priceFeedEstimate;
// We need to check if tx.gasprice is non-zero as a workaround to a bug
// in go-ethereum:
// https://github.com/ethereum/go-ethereum/pull/20189
if (tx.gasprice > 0 && tx.gasprice < priceFeedEstimate) {
gasPrice = tx.gasprice;
}

uint256 reimbursementFee = dkgGasEstimate.mul(gasPrice);
address payable magpie = stakingContract.magpieOf(msg.sender);

Expand Down

0 comments on commit 7e27303

Please sign in to comment.