-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(relayer): estimate gas for tx, set gas to 2.5mil if not estimatab…
…le. works now. (#13271)
- Loading branch information
1 parent
7cd7787
commit 3913ca5
Showing
4 changed files
with
56 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package message | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"github.com/pkg/errors" | ||
"github.com/taikoxyz/taiko-mono/packages/relayer/contracts/bridge" | ||
) | ||
|
||
func (p *Processor) estimateGas( | ||
ctx context.Context, message bridge.IBridgeMessage, proof []byte) (uint64, *big.Int, error) { | ||
auth, err := bind.NewKeyedTransactorWithChainID(p.ecdsaKey, message.DestChainId) | ||
if err != nil { | ||
return 0, nil, errors.Wrap(err, "bind.NewKeyedTransactorWithChainID") | ||
} | ||
|
||
auth.NoSend = true | ||
|
||
auth.Context = ctx | ||
|
||
// estimate gas with auth.NoSend set to true | ||
tx, err := p.destBridge.ProcessMessage(auth, message, proof) | ||
if err != nil { | ||
return 0, nil, errors.Wrap(err, "p.destBridge.ProcessMessage") | ||
} | ||
|
||
return tx.Gas(), tx.Cost(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters