You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are three validators. The number of required signatures is 3.
The bridge has X coins locked on the Home side and X tokens minted on the Foreign side.
The account A owns Y (X>Y) tokens on the Foreign side.
There is the account B which has no incoming transactions and that's why it has zero balance in the Home network. The account B has some funds in the Foreign network.
Actions:
The account A sends Y tokens to the account B.
The account B sends Y tokens to the Foreign Bridge address.
The affirmation event it is emitted by the bridge contract, 3 validators sings the transaction with confirmation and send them to the Home network.
Results:
When the third validator's transaction included in the block, it is running out of gas.
Analysis:
Most probably all three transactions are being prepared by the validators in the same time - for the same state of the blockchain. So, when all three token bridge instances estimate the gas usage for the transaction to send the confirmation they use the same state which assumes that no confirmations are sent yet that is why gas estimation returns a value which is less than a value which could be received for the case when 2 of 3 confirmations are already sent.
Even if we increase gas limit on some value in https://github.com/poanetwork/token-bridge/blob/7069ef9fb20cf9959057737af5666915ec837787/src/sender.js#L116, it is still not enough.
It is due to the fact that value returned by gas estimation method is around 100000 gas. When the value is increased by the formula above it will be near to 125000. Whereas the transaction to unlock funds requires much more.
And the situation is even worse for the case when the account to receive funds does not exist yet - to create this account 25000 gas is required additionally.
Soluttion:
One of possible solution is to increase EXTRA_GAS_PERCENTAGE.
Another solution could be to take values from the gas consumption report and integrate them into the token bridge code to make sure that the estimated gas value is less or equal of possible maximum identified during the tests.
The text was updated successfully, but these errors were encountered:
I suggest the following solution:
At this moment we close the issue by increasing EXTRA_GAS_PERCENTAGE up to 2.0.
We create another issue in the contracts and the token bride repos to improve the functionality:
Measure the gas usage for all scenarios for every bridge mode.
Introduce new methods in the contracts returning maximum gas consumption. The values in the methods should be updated every time the code of the contracts is modified. Every bridge mode will return its own set of values.
The token bridge will read these values when it is started. The gas consumption values read from the contracts will be used to submit corresponding transactions to the chain.
Consider the following scenario:
Pre-requisites:
native-to-erc20
modeActions:
Results:
When the third validator's transaction included in the block, it is running out of gas.
Analysis:
Most probably all three transactions are being prepared by the validators in the same time - for the same state of the blockchain. So, when all three token bridge instances estimate the gas usage for the transaction to send the confirmation they use the same state which assumes that no confirmations are sent yet that is why gas estimation returns a value which is less than a value which could be received for the case when 2 of 3 confirmations are already sent.
Even if we increase gas limit on some value in https://github.com/poanetwork/token-bridge/blob/7069ef9fb20cf9959057737af5666915ec837787/src/sender.js#L116, it is still not enough.
It is due to the fact that value returned by gas estimation method is around 100000 gas. When the value is increased by the formula above it will be near to 125000. Whereas the transaction to unlock funds requires much more.
And the situation is even worse for the case when the account to receive funds does not exist yet - to create this account 25000 gas is required additionally.
Soluttion:
One of possible solution is to increase
EXTRA_GAS_PERCENTAGE
.Another solution could be to take values from the gas consumption report and integrate them into the token bridge code to make sure that the estimated gas value is less or equal of possible maximum identified during the tests.
The text was updated successfully, but these errors were encountered: