Testing ETH Contract Deployment using the `eth` Ruby gem against provider endpoints

Chainstack support just send me an email with some excellent advice and they also submitted an issue over at the eth gem repo. This is outstanding!

Chainstack Guidance

I checked out the eth.rb gem and how it works. And checked out all the issues that you reported there as well (and your post).

There are two issues in general.

Already known

For the "Already known" issue — What I assume happens is you send the contract creation transaction and it enters the pending state in the mempool (standard Ethereum transaction lifecycle). Looking at your failed transactions, I see that they all have the max_priority_fee_per_gas setting at 0, which gives the miners no incentive to pick the transaction right away, so the transaction ends up sitting in the mempool for some time. This is probably the time when you feel the contract creation transaction is stuck and you re-initiate the contract creation transaction. However, an attempt to resend the exact same transaction with the exact same nonce get rejected as the transaction with the exact same parameters (gas, bytecode, nonce) is already in the pool. Hence, you get the "Already known" message as the transaction is already known to the mempool.

Out of gas

When the transaction eventually goes through and is picked up by the miner, it eats up the gas and then reverts on reaching the gas limit. This seems to be an issue with the gem—I reported it now, please have a look for details #119.

The deployment of the hello world contract is always assigned the gas_limit value of 57100 by the eth gem for some reason no matter the value you actually provide to it.

Gas 57,100 is not enough to write your hello world to the state as it requires at least 135,091 of gas. Hence, it fails half way through and reverts.

Hopefully this helps it.

Let me know if you have other issues or need help.

Reply to the Chainstack Support Team

Thank you for your response and excellent support / explanation and thanks for submitting an issue to the eth gem.

Out of all the providers I have tested to date and queried about this issue, your support has been the best to date and much appreciated.

I will review (again) your reply, make changes to my test configuration, and try again.

Thank you !

I am hopeful that I can make progress based on the excellent Chainstack guidance and will get back to this test either today or tomorrow.

With this reply, Chainstack takes the lead in the analysis shoot-out at this point in time.

  1. Chainstack
  2. Infura
  3. Alchemy
  4. Quicknode (removed from analysis as described earlier)
  5. GetBlock (removed from analysis as described earlier)

This is interesting.

I have been attempting to bypass a reported bug in the eth gem related to gas, and have also been "cancelling" (according to the docs) transactions by sending 0 test ETH from and to the same address.

Just did this here:

Transfer Status: 0xa9d67b68e40e065fc4a8086074aec67e535fb9f4021356d67d17343f5c08c443

Which shows a successful transfer of 0 ETH on Ropsten:

So, I should not get "already know" according to the discussions on the net, but I do:

METAMASK_ADDRESS: 0xE179C056024150d56A4e94af9C5A36BCC0B4e502
BALANCE is 3.040098415068835e+20 GWEI Nonce: 47
ETH ERROR: infura_ropsten contract deployment failed: already known

But in the scanner, the error is:

 Warning! Error encountered during contract execution [out of gas] 

https://ropsten.etherscan.io/address/0xe179c056024150d56a4e94af9c5a36bcc0b4e502

This detective work is starting to get interesting.

I am starting to "think" the bug is in the eth gem, as others have pointed out, because, according to the scanner, even when I set a max to a whopping 600,000 GWEI

Gas Fees:
Base: 0.000000007 Gwei |Max: 600,000 Gwei |Max Priority: 1.6 Gwei

The transaction fails with a small GWEI gas price:

Gas Price:  0.000000001600000007 Ether (1.600000007 Gwei)

This may be related to this:

Or maybe this:

Anyway, I need to get back to sanding our teak wood floors for a while.....

Then, will put more debugging statements into the eth gem and try to find out where the potential bug is, if any.

More later.

More testing and more help from Infura and Chainstack support have moved Hello World deployment to this error, "invalid argument 0: hex string has length 40, want 64 for common.Hash":

{"jsonrpc":"2.0","id":29,"error":{"code":-32602,"message":"invalid argument 0: hex string has length 40, want 64 for common.Hash"}}

Chainstack kindly provided a gas configuration which seems to get past the other issues I was facing.

Infura found a nonce error in my debugging code for the eth gem.

Have searched the net for clues for the above error, but did not find anything useful, so perhaps Chainstack or Infura with be able to figure this one out.

Excellent support from both blockchain endpoint providers. Thank you.

Note: I this the exact same error for all these contracts, so the issue does not appear to be related to the contract:

  • hello_world.sol
  • hi_there.sol
  • greeter.sol

Submitted this issue to the eth gem:

There seems to be something broken with the Ethereum Virtual Machine (EVM), but then what does an ETH novice like me know.

I keep getting this error trying to deploy "Hello World" :

/Users/tim/rails/ethgem/vendor/bundle/ruby/3.0.0/gems/eth-0.5.5/lib/eth/client.rb:471:in `send_command': invalid argument 0: hex string has length 40, want 64 for common.Hash (IOError)

But when I review the scanner for the contract address in error, "0x200E5595Fd9bC634F0FAe4847337ca9ff0C2BB61" is shows 'out of gas' even though miners charged me

Transaction Fee:
22.8400000000003997 Ether ($0.00)

This is crazy. If this was not test ETH, this failed transaction on the main network would have cost roughly $23,000 USD.

Something is seriously wrong with the EVM, it seems to me!

So, test miners just made $23,000 work of bogus test ETH, over 22 ETH, for a failed transaction with an error somewhere in the EVM returning an IOError:

invalid argument 0: hex string has length 40, want 64 for common.Hash (IOError)

I am very glad this is test ETH not at real ETH! I would have just lost over $23K at todays depressed ETH value if this was on the mainnet. This is really bazaar. Before this failed transactions, MetaMask shows I had close to 304 rETH. Now... :frowning:

Screen Shot 2022-06-22 at 7.51.16 AM

Crazy stuff. Lucky miners (if this was ETH and not rETH) :slight_smile:

There seems to be some things amiss with the eth Ruby gem.

Unfortunately, I do not have the time to do down the rabbit hole with the eth gem and it seems that gem does not have a lot of development / bug fix activity at this time either. I am not confident the bugs are going to be addressed by anyone anytime soon.

So, instead of going deeper down this eth gem rabbit hole; I am going to shift my analysis to a different crypto project.

Stay tuned. Let me so some sniffing around and see what other dApp blockchain protocol has a "working" Ruby gem.

Frankly, I was disappoint to see a failed "Hello World" transaction yesterday using this eth gem having a transaction fee of nearly 23 rETH.

See Also:

This error was caused by a bug in my test code, which was found by Chris @ Infura.

Thanks Chris!

https://infura.io/

See also:

Summary

After many days of evaluating the Ruby eth gem by deploying the most simple "Hello World" Ethereum contract possible, I have concluded that this gem has some serious issues.

I have tested this gem with a handful of blockchain providers and Ethereum test networks. In every case the deployment fails due to gas issues. In one test, the deployment failed with transaction fees of nearly 23 rETH.

This issue was the "straw which broken the camel's back" for me; because if this had of been on the main Ethereum network and not on the test net, a single "hello world" deployment failure due to "out of gas" errors would have cost around $23,000 USD at todays very cheap crypto prices. There is a reason why we cannot find a working "Hello World" contract deployment using this eth gem, and considering the Initial commit was on May 16, 2016, one would think that after seven years, a trivial "Hello World" contract deployment would work without all this hassle.

This many also explain why no Ethereum blockchain provider I can find supports Ruby in their docs, except QuickNode, and QuickNode does not have a working Ethereum "Hello World" contract deployment with this gem. Most of their tutorials are deprecated and only the most trivial methods work.

This concludes my evaluation of this Ruby eth gem vis-a-vis a handful of Ethereum blockchain service providers. Sorry not to have better results to report, as I never expected deploying "Hello World" on Ethereum would be unsuccessful after nearly 10 days, including feedback from many engineers and developers.

HTH