openware / peatio

Open-source crypto currency exchange software (https://openware.com)
https://www.openware.com
MIT License
1.04k stars 623 forks source link

Binance Smart Chain (BSC) support for geth #2875

Closed crackfoo closed 2 years ago

crackfoo commented 3 years ago

Hi,

Since BSC has a geth compliant full node, can support be added to peatio for it? It mostly works aside from withdraws. It seems the gas price/limits aren't being passed down to the geth client which results in the error:

<Peatio::Wallet::ClientError: transaction underpriced (-32000)>

And geth logs:

t=2021-03-25T17:09:35+0000 lvl=warn msg="Served personal_sendTransaction" conn=x.x.x.x:49940 reqid=1 t=979.229383ms err="transaction underpriced" X-Forwarded-For=nil

Thanks

calj commented 3 years ago

Thanks for testing! It should be working the same way as with geth. Maybe there is a difference in the gas estimations methods.

crackfoo commented 3 years ago

gas_limit seems to be sent to geth ok. If I set it too high, peatio/geth reports:

<Peatio::Wallet::ClientError: exceeds block gas limit (-32000)>
t=2021-03-25T18:18:57+0000 lvl=warn msg="Served personal_sendTransaction"       conn=x.x.x.x:39612 reqid=1 t=958.532005ms             err="exceeds block gas limit" X-Forwarded-For=nil

But even if I set the gas_price high, there's no change... just reports underpriced

calj commented 3 years ago

Can you search in the log of the withdraw daemon for "Current gas price" I suspect something is wrong in this function: https://github.com/openware/peatio/blob/master/lib/peatio/ethereum/wallet.rb#L203

crackfoo commented 3 years ago

I don't see any mention of gas in the logs when I attempt to "reprocess" the failed wd....

From the BSC geth console, gas price reports:

> eth.gasPrice
10000000000
> 
calj commented 3 years ago

we might have a problem here: https://github.com/openware/peatio/blob/master/lib/peatio/ethereum/wallet.rb#L101 https://github.com/openware/peatio/blob/master/lib/peatio/ethereum/wallet.rb#L140

Can you try to replace those lines with

if transaction.options.present? && transaction.options[:gas_price]
crackfoo commented 3 years ago

No change, and still no mention gas in logs...

Do I have to re-create the wd, or should reprocessing be enough?

crackfoo commented 3 years ago

Is it a problem that currency_id here is set to eth when there's now other currencies using geth?

https://github.com/openware/peatio/blob/master/lib/peatio/ethereum/wallet.rb#L124

martianatwork commented 3 years ago

@crackfoo Change the log level to debug.

Also what version are you using?

crackfoo commented 3 years ago

@martianatwork I'm currently running: Peatio: 2.6.44 Barong: 2.6.40

gas price shown now but the error follows immediately after:

withdraw_coin_1         | {"level":"INFO","time":"2021-03-28 15:56:46","message":"Received: {\"id\":65}"}
withdraw_coin_1         | {"worker":"/home/app/app/workers/amqp/withdraw_coin.rb","id":65,"message":"Received request for processing withdraw.","level":"WARN","time":"2021-03-28 15:56:46"}
withdraw_coin_1         | {"level":"DEBUG","time":"2021-03-28 15:56:46","message":"   (0.8ms)  SET NAMES utf8 COLLATE utf8_general_ci,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483"}
withdraw_coin_1         | {"level":"DEBUG","time":"2021-03-28 15:56:46","message":"  Withdraw Load (0.4ms)  SELECT  `withdraws`.* FROM `withdraws` WHERE `withdraws`.`id` = 65 LIMIT 1"}
withdraw_coin_1         | {"level":"DEBUG","time":"2021-03-28 15:56:46","message":"   (0.3ms)  BEGIN"}
withdraw_coin_1         | {"level":"DEBUG","time":"2021-03-28 15:56:46","message":"  Withdraws::Coin Load (0.5ms)  SELECT  `withdraws`.* FROM `withdraws` WHERE `withdraws`.`type` IN ('Withdraws::Coin') AND `withdraws`.`id` = 65 LIMIT 1 FOR UPDATE"}
withdraw_coin_1         | {"level":"DEBUG","time":"2021-03-28 15:56:46","message":"  Currency Load (0.4ms)  SELECT  `currencies`.* FROM `currencies` WHERE `currencies`.`id` = 'bsc' LIMIT 1"}
withdraw_coin_1         | {"worker":"/home/app/app/workers/amqp/withdraw_coin.rb","id":65,"amount":"0.499","fee":"0.001","currency":"BSC","rid":"0xbXXXXXXXXXXXXXXXXXXXXXX","message":"Sending witdraw.","level":"WARN","time":"2021-03-28 15:56:46"}
withdraw_coin_1         | {"level":"DEBUG","time":"2021-03-28 15:56:46","message":"  Wallet Load (0.5ms)  SELECT  `wallets`.* FROM `wallets` INNER JOIN `currencies_wallets` ON `currencies_wallets`.`wallet_id` = `wallets`.`id` INNER JOIN `currencies` ON `currencies`.`id` = `currencies_wallets`.`currency_id` WHERE `wallets`.`status` = 'active' AND `currencies`.`id` = 'bsc' AND `wallets`.`kind` = 310 LIMIT 1"}
withdraw_coin_1         | {"worker":"/home/app/app/workers/amqp/withdraw_coin.rb","id":65,"message":"Sending request to Wallet Service.","level":"WARN","time":"2021-03-28 15:56:46"}
withdraw_coin_1         | {"level":"INFO","time":"2021-03-28 15:56:46","message":"Current gas price 10000000000"}
withdraw_coin_1         | {"worker":"/home/app/app/workers/amqp/withdraw_coin.rb","id":65,"message":"Failed to process withdrawal. See exception details below.","level":"WARN","time":"2021-03-28 15:56:48"}
withdraw_coin_1         | {"level":"ERROR","time":"2021-03-28 15:56:48","message":"#<Peatio::Wallet::ClientError: transaction underpriced (-32000)>"}
withdraw_coin_1         | {"level":"ERROR","time":"2021-03-28 15:56:48","message":"/home/app/lib/peatio/ethereum/wallet.rb:49:in `rescue in create_transaction!'.... .... ....
crackfoo commented 3 years ago

anything else you want me to try?

crackfoo commented 3 years ago

is it required that geth run in as full node, or will lite node be sufficent?

bleachhun commented 2 years ago

is it required that geth run in as full node, or will lite node be sufficent?

Solution? My withdraw transaction underpriced (-32000)

BNB help.

crackfoo commented 2 years ago

no solutions. gave up and moved on