Skip to content

Commit

Permalink
feat(relayer): big Gas price (#13492)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored Mar 28, 2023
1 parent c082848 commit cb3f7b9
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
export let show: boolean;
</script>

<TooltipModal title="Insufficient Balance" bind:isOpen={show}>
<TooltipModal title="Waiting for Relayer" bind:isOpen={show}>
<span slot="body">
<div class="text-left">
You have insufficient balance to claim this transaction.
<strong>
Please wait for the relayer to claim the transaction for you.
</strong>

This will happen automatically. Depending on network congestion, this can
take up to several hours.
</div>
</span>
</TooltipModal>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
: 'Taiko A2'} should be available to claim within minutes.
</li>
<li class="mb-2">
<strong>Claimable</strong>: Your asset is ready to be claimed on the
<strong>Claim</strong>: Your asset is ready to be claimed on the
destination chain and requires a transaction.
</li>
<li class="mb-2">
Expand Down
2 changes: 1 addition & 1 deletion packages/relayer/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func LogSkipper(c echo.Context) bool {
case "/metrics":
return true
default:
return false
return true
}
}

Expand Down
10 changes: 10 additions & 0 deletions packages/relayer/message/process_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/hex"
"fmt"
"math/big"
"strings"

"github.com/ethereum/go-ethereum/accounts/abi"
Expand Down Expand Up @@ -170,6 +171,15 @@ func (p *Processor) sendProcessMessageCall(
}
}

gasPrice, err := p.destEthClient.SuggestGasPrice(context.Background())
if err != nil {
return nil, errors.Wrap(err, "p.destBridge.SuggestGasPrice")
}

gasPrice = gasPrice.Mul(gasPrice, big.NewInt(2))

auth.GasPrice = gasPrice

// process the message on the destination bridge.
tx, err := p.destBridge.ProcessMessage(auth, event.Message, proof)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions packages/relayer/message/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package message
import (
"context"
"crypto/ecdsa"
"math/big"
"sync"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -17,6 +18,7 @@ type ethClient interface {
TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
BlockNumber(ctx context.Context) (uint64, error)
HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
SuggestGasPrice(ctx context.Context) (*big.Int, error)
}
type Processor struct {
eventRepo relayer.EventRepository
Expand Down
4 changes: 4 additions & 0 deletions packages/relayer/mock/eth_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ var (
type EthClient struct {
}

func (c *EthClient) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
return big.NewInt(100), nil
}

func (c *EthClient) ChainID(ctx context.Context) (*big.Int, error) {
return MockChainID, nil
}
Expand Down
11 changes: 7 additions & 4 deletions packages/starter-dapp/src/components/MessageStatusTooltip.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import TooltipModal from "./modals/TooltipModal.svelte";
import { showMessageStatusTooltip } from '../store/transactions';
import { showMessageStatusTooltip } from "../store/transactions";
</script>

<TooltipModal title="Message Status" bind:isOpen={$showMessageStatusTooltip}>
Expand All @@ -16,11 +16,14 @@
: "Ethereum A2"} bridging can take several hours before being ready.
{import.meta.env
? import.meta.env.VITE_MAINNET_CHAIN_NAME
: "Ethereum A2"} => {import.meta.env ? import.meta.env.VITE_TAIKO_CHAIN_NAME : "Taiko A2"} should be available to claim within minutes.
: "Ethereum A2"} => {import.meta.env
? import.meta.env.VITE_TAIKO_CHAIN_NAME
: "Taiko A2"} should be available to claim within minutes.
</li>
<li class="mb-2">
<strong>Claimable</strong>: Your asset is ready to be claimed on the
destination chain and requires a transaction.
<strong>Claim</strong>: Your asset is ready to be claimed on the
destination chain and requires a transaction, or if a processing fee
is set, relayer will pick it up.
</li>
<li class="mb-2">
<strong>Claimed</strong>: Your asset has finished bridging and is
Expand Down

0 comments on commit cb3f7b9

Please sign in to comment.