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

eth/contract Testing ETH Contract Deployment using the eth Ruby gem against provider endpoints #116

Closed
unixneo opened this issue Jun 15, 2022 · 25 comments
Labels
question Further information is requested

Comments

@unixneo
Copy link

unixneo commented Jun 15, 2022

Hope this helps.

I summarized some eth issues found when testing with four different blockchain endpoint providers here:

https://community.unix.com/t/testing-eth-contract-deployment-using-the-eth-ruby-gem-against-provider-endpoints/387004

Not sure the best was to continue reporting these issues, as I do not wish to be a pain and inundate anyone with these various issues encountered with testing various endpoints.

Kindly let me know how to proceed without being annoying. Thanks.

@q9f q9f added the question Further information is requested label Jun 15, 2022
@unixneo
Copy link
Author

unixneo commented Jun 15, 2022

Update:

Tried this, using `sender_key'

   key = Eth::Key.new priv: ENV['ETH_CONTRACT_SENDERS_PRIVATE_KEY']
   chain.deploy_and_wait(contract,sender_key:key)

Results:

Waiting / stuck here:

irb(main):002:0> EthGem::Core.contract("hello_world","alchemy_goerli")
Balance is 1.1e+18              
FILE: /Users/tim/rails/eth/lib/assets/contracts/hello_world.sol

# hangs..... 

not sure how long this should take, being new at this; but it just hangs.

However, if I try it on the mainnet, looks OK ( I have no ETH on mainnet, only on test nets)

irb(main):003:0> EthGem::Core.contract("hello_world","alchemy_mainnet")
Balance is 0.0                  
FILE: /Users/tim/rails/eth/lib/assets/contracts/hello_world.sol
/Users/tim/rails/eth/vendor/bundle/ruby/3.0.0/gems/eth-0.5.5/lib/eth/client.rb:454:in `send_command': insufficient funds for gas * price + value (IOError)

Not sure why I hangs on test net since I have more than enough ETH on all testnets.

@q9f
Copy link
Owner

q9f commented Jun 15, 2022

It waits for the contract to be deployed. You will get either a transaction ID or a TimeoutError.

@unixneo
Copy link
Author

unixneo commented Jun 15, 2022

It waits for the contract to be deployed. You will get either a transaction ID or a TimeoutError.

OK, I am trying again.. and waiting... will let you know the results on "alchemy_goerli"

Thanks

@unixneo
Copy link
Author

unixneo commented Jun 15, 2022

Update:

Twice, it times out, as follows:

/Users/tim/rails/eth/vendor/bundle/ruby/3.0.0/gems/eth-0.5.5/lib/eth/client.rb:378:in `block in wait_for_tx': Timeout::Error (Timeout::Error)

@q9f
Copy link
Owner

q9f commented Jun 15, 2022

In that case, you need to increase gas fees.

@unixneo
Copy link
Author

unixneo commented Jun 15, 2022

OK. Thanks. Waiting again, after:

irb(main):008:0> chain.gas_limit
=> 21000
irb(main):009:0> chain.gas_limit=500000
=> 500000

@q9f
Copy link
Owner

q9f commented Jun 15, 2022

not the limit, the fee (price)

@unixneo
Copy link
Author

unixneo commented Jun 15, 2022

Thanks.

This one, correct?

irb(main):005:0> chain.max_fee_per_gas
=> 0.2e11

Increase this?

@unixneo
Copy link
Author

unixneo commented Jun 15, 2022

I tried again on "chainstack_ropsten", and it worked, finally (with default settings)

irb(main):002:0> EthGem::Core.contract("hello_world","chainstack_ropsten")
Balance is 1.0400990549999952e+20         
FILE: /Users/tim/rails/eth/lib/assets/contracts/hello_world.sol                    
=> "0xb9554BF515750AD073Ec197AD415aEc5b69483D6"
irb(main):003:0> 

Yea! :)

@unixneo
Copy link
Author

unixneo commented Jun 15, 2022

Now, I just need to figure out how to set the gas fee for eth clients, as I could not find it here:

Screen Shot 2022-06-15 at 8 13 16 PM

Nor here:

Screen Shot 2022-06-15 at 8 13 40 PM

Is it "max_fee_per_gas" (in GWEI) ?

@unixneo
Copy link
Author

unixneo commented Jun 15, 2022

Also, FWIW, I checked the transaction above (the "successful" one), and it seems it failed for gas reasons as well:

Screen Shot 2022-06-15 at 9 10 25 PM

Being new to this, I'm confused why gas is such an issue on test networks and why these errors are not being returned to the eth client, but they show up on the scanner.

@unixneo
Copy link
Author

unixneo commented Jun 15, 2022

Also, I just tested another endpoint "infura_ropstend" and the results with eth were:

irb(main):002:0> EthGem::Core.contract("hello_world","infura_ropsten")
Endpoint: https://ropsten.infura.io/v3/a8cc835a18a64a0b904193ccb2e29ccf
METAMASK_ETH_ADDRESS: 0xE179C056024150d56A4e94af9C5A36BCC0B4e502
Balance is 2.040099054999991e+20
FILE: /Users/tim/rails/eth/lib/assets/contracts/hello_world.sol
Gas Max Fee: 20000000000.0      
=> "0x9E65a2b45B1b3d4304457ad1146f6112f6149bbD"

But the scanner shows it failed out of gas.

https://ropsten.etherscan.io/tx/0x4af02dd71e31f9e05405b2afb5f335504717f5668f824a6031e302187cefeffb

Shouldn't eth return this failure? It returns the transaction id, but not the status.

What am I missing?

Thanks.

@q9f
Copy link
Owner

q9f commented Jun 15, 2022

Is it "max_fee_per_gas" (in GWEI) ?

Please read up on EIP 1559. You need to set both, priority and gas fee.

it seems it failed for gas reasons as well

yes, this is a known issue #111 - I'll make a release shortly.

It returns the transaction id, but not the status.

Yes, #99

@unixneo
Copy link
Author

unixneo commented Jun 15, 2022

Please read up on EIP 1559. You need to set both, priority and gas fee.

Yes, I have...

The problem I am having is that when I read up on these topics on the net, and also in stackexchange and other sites and in other docs, the methods often do not match the methods in the eth gem.

Sorry you are getting frustrated with my questions. but I am only trying to understand how this eth gem works and the documentation is not clear and the return values are not providing info.

The best way so far today is for me to just edit the gem and start printing.

For example, you told me that "the gas fees were too low" and that is why I keep getting timeout errors. However, I checked the client code, and the timeout was hard coded to 300 seconds. It is typical for low gas fee transactions to take a lot longer than 5 minutes, but this timeout value of 300 seconds is hardcoded into the client.

Again, sorry you are getting frustrated with my questions. Honestly, I am simply trying to get this gem to submit a "hello world" contract on Ropsten, Goerli, and Rinkeby test networks and it has been days and I have not got a single simple "hello world" transaction to work.

I don't think it's my fault and it is not for a lack of trying. I'm not doing anything complex and I have plenty of ETH for all these test networks.

Again, sorry you are frustrated with my questions.

@q9f
Copy link
Owner

q9f commented Jun 15, 2022

I'm not frustrated :)

@unixneo
Copy link
Author

unixneo commented Jun 16, 2022

That's nice to hear. I am worried that my testing and debugging is annoying you :)

So, today I added some debug prints to the gem and have increased gas prices like so:

        chain = Eth::Client.create Endpoint::Provider.get(network_provider)
        gas_pump = 1.2
        chain.gas_limit=70000
        gas_price =  chain.max_fee_per_gas
        chain.max_fee_per_gas = gas_price *  gas_pump
        gas_limit=chain.gas_limit
        chain.gas_limit = gas_limit *  gas_pump
        puts "PUMPED UP GAS: chain.max_fee_per_gas=#{chain.max_fee_per_gas} & chain.gas_limit=#{chain.gas_limit}"

However, this results in the "replacement underpriced" error:

/Users/tim/rails/ethgem/vendor/bundle/ruby/3.0.0/bundler/gems/eth.rb-fe8f91718d62/lib/eth/client.rb:462:in `send_command': replacement transaction underprice

So, I increased gas like this:

     gas_pump = 1.25

and that results in the "already known" error (which I think is nonce related?), as follows:

/Users/tim/rails/ethgem/vendor/bundle/ruby/3.0.0/bundler/gems/eth.rb-fe8f91718d62/lib/eth/client.rb:462:in `send_command': already known (IOError)

Maybe you can help me out and explain to me how to fix this and move past this (nonce related?) issue so I can actually deploy Hello World ?

Thanks!

@q9f
Copy link
Owner

q9f commented Jun 16, 2022

I'll try to give you a more elaborate answer within the next days, please don't give up yet :)

@unixneo
Copy link
Author

unixneo commented Jun 16, 2022

Thank you @q9f

Today I took a detour and tried to get this eth gem to work with a Binance Smart Chain endpoint, since BSC is an ethereum clone. I was able to do the basic "get_balance" query, but when I tried to deploy "Hello World" I got a "transaction not supported" error and decided to avoid that rabbit hole completely

Looking forward to your next code / explanation to get me past "Hello World" on normal eth test chains! No hurry, I'm hand sanding a very hard teak wood floor with a 5" random orbital sander; so I generally alternate between sanding very hard teak wood and doing Hello World with eth.rb :) :)

FYI only using BSC

{"jsonrpc"=>"2.0",
 "id"=>5,
 "error"=>{"code"=>-32000, "message"=>"transaction type not supported"}}
/Users/tim/rails/ethgem/vendor/bundle/ruby/3.0.0/bundler/gems/eth.rb-cfa68b506df6/lib/eth/client.rb:463:in `send_command': transaction type not supported (IOError)

Screen Shot 2022-06-16 at 8 33 51 PM

@unixneo
Copy link
Author

unixneo commented Jun 18, 2022

Here is a quick public version of the code to test this Hello World contract:

https://github.com/unixneo/ethtest.git

Hope this helps.

@unixneo
Copy link
Author

unixneo commented Jun 18, 2022

Update:

Now I get this error:

OUTPUT BELOW
{"jsonrpc"=>"2.0",
 "id"=>7,
 "error"=>
  {"code"=>-32000, "message"=>"insufficient funds for gas * price + value"}}
ETH ERROR: contract deployment failed: insufficient funds for gas * price + value

And when I look for an answer via google, nothing I change helps to get past this roadblock. The account I am using has over 300 rETH (not GWEI, ETH) and the signing key for the transactions is the same private key as the address.

Is there a method to simply read what the EVM wants so we can give it want it wants?

Also, I read this, as folks advise, but I cannot find the solution in this document only more confusion:

https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md

@unixneo
Copy link
Author

unixneo commented Jun 18, 2022

Trying yet another way, the error changes again:

OUTPUT BELOW
{"jsonrpc"=>"2.0",
 "id"=>6,
 "error"=>{"code"=>-32000, "message"=>"already known"}}
ETH ERROR: infura_ropsten contract deployment failed: already known

Seems like the protocol and / or the gem should have methods to deal with this, right?

These seems to be standard errors and the solution would come from information in the EVM, so it seems when these errors occur, either:

  1. The EVM should return "what it wants" or
  2. The gem should query the EVM on error and return "what the EVM" wants.

Or, three, what is a method to do this because searching the net has not yielded any fruit.

@unixneo
Copy link
Author

unixneo commented Jun 21, 2022

Chainstack and Infura provided "working" gas params. Thanks.

@unixneo unixneo closed this as completed Jun 21, 2022
@gith-u-b
Copy link

unixneo

hi, How did you solve it in the end?

@unixneo

This comment was marked as outdated.

@q9f
Copy link
Owner

q9f commented Sep 26, 2022

Sorry to see you gave up.

Responded to all your questions here: https://community.unix.com/t/creating-a-hello-world-contract-with-ruby-ethereum/388145

Edit: neo decided to delete my response, so I will lock this thread to avoid further distractions.

Repository owner locked as too heated and limited conversation to collaborators Oct 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants