Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Estimate tx gas #50

Merged
merged 21 commits into from
May 4, 2020
Merged

Estimate tx gas #50

merged 21 commits into from
May 4, 2020

Conversation

cag
Copy link
Contributor

@cag cag commented Apr 16, 2020

Edit notes:

Discovered that eth_call is totally unspecified for error cases, which is why the --noVMErrorsOnRPCResponse got set on Ganache. Here's a summary of what is happening:

  • Regular Ganache runs return a VM error with eth_call, and Ganache will attempt to decode the revert reason data as a UTF-8 string to send as part of the error. There is raw "return" data, but I think it is actually just the original calldata echoed back and it's an ABI-encoded Error.
  • Ganache using --noVMErrorsOnRPCResponse and Geth will return the data supplied to revert call as the response. There's no distinguishing this from a regular return. Our use case depends on this behavior, as buggy as it feels to me.
  • Parity/OpenEthereum will return a "VM execution error." Similar to the regular Ganache, there's raw "return" data which is actually just the calldata echoed back, so there isn't a way to use Parity to do a gas estimate through the requiredTxGas method.

Edit 2: Found that it's not the calldata echoed back, but actually ABI-encoded Error(string) data: https://solidity.readthedocs.io/en/latest/control-structures.html#revert

This also explains the .substring(138) that I didn't understand.

In any case, it is a matter of getting that data now.

Edit 3: works with OpenEthereum now. Tested with the following:

parity --config dev --unlock 0x00a329c0648769a73afac7f9381e08fb43dbea72 --password <(echo '')

@cag cag force-pushed the estimate-tx-gas-2 branch from 44a1490 to fcfae55 Compare April 24, 2020 19:12
@cag cag changed the base branch from estimate-tx-gas to master April 24, 2020 19:12
@cag cag marked this pull request as ready for review April 28, 2020 15:58
@cag cag requested a review from germartinez April 28, 2020 15:58
@cag
Copy link
Contributor Author

cag commented Apr 28, 2020

Reference to batching transactions issue: ethers-io/ethers.js#62

sendOptions: {
gasLimit?: number | string;
}
): Promise<EthersTransactionResult>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EthersTransactionResult | Web3TransactionResult

@@ -192,6 +237,17 @@ class CPKEthersProvider implements CPKProvider {
getSendOptions(options: object, ownerAccount: string): object {
return options;
}

async getGasPrice(): Promise<number> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed

@@ -173,6 +266,15 @@ class CPKWeb3Provider implements CPKProvider {
...(options || {}),
};
}

getGasPrice() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed

@germartinez
Copy link
Member

I just saw that this is fixed in the next PR

@germartinez germartinez merged commit 695de4a into master May 4, 2020
@germartinez germartinez deleted the estimate-tx-gas-2 branch May 4, 2020 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants