forked from taikoxyz/taiko-mono
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 1a94184 Author: 1xDeFi <[email protected]> Date: Tue Dec 13 16:56:11 2022 +0100 Squashed commit of the following: commit a8b1c49 Author: 1xDeFi <[email protected]> Date: Mon Dec 12 14:15:36 2022 +0100 remove internal variables and functions Removed from: https://taiko.xyz/docs/reference/smart-contracts/bridge/BridgedERC20 commit 235b685 Author: 1xDeFi <[email protected]> Date: Tue Dec 13 16:56:00 2022 +0100 Squashed commit of the following: commit 1fdf217 Merge: 4ae3dbc 788e162 Author: 1xDeFi <[email protected]> Date: Tue Dec 13 16:24:24 2022 +0100 Merge branch 'main' into patch-5 commit 4ae3dbc Author: 1xDeFi <[email protected]> Date: Mon Dec 12 14:14:20 2022 +0100 remove internal variables and functions Removed from: https://taiko.xyz/docs/reference/smart-contracts/bridge/ commit 1a28290 Author: 1xDeFi <[email protected]> Date: Tue Dec 13 16:55:46 2022 +0100 Squashed commit of the following: commit 5bdd441 Author: 1xDeFi <[email protected]> Date: Mon Dec 12 14:10:58 2022 +0100 remove internal variables and functions Removed for: https://taiko.xyz/docs/reference/smart-contracts/L1/TaikoL1 commit 9e219bd Author: 1xDeFi <[email protected]> Date: Tue Dec 13 16:55:23 2022 +0100 Squashed commit of the following: commit 19525cb Author: 1xDeFi <[email protected]> Date: Mon Dec 12 14:08:55 2022 +0100 remove internal variables and functions Removed from: https://taiko.xyz/docs/reference/smart-contracts/L1/TkoToken commit e443de4 Merge: bc54a67 788e162 Author: 1xDeFi <[email protected]> Date: Tue Dec 13 16:26:26 2022 +0100 Merge branch 'taikoxyz:main' into patch-2 commit 788e162 Author: Daniel Wang <[email protected]> Date: Tue Dec 13 06:44:16 2022 +0800 chore(website): publish website when contract code changes on main (taikoxyz#413) commit b5d8180 Author: jeff <[email protected]> Date: Mon Dec 12 07:43:45 2022 -0800 feat(relayer): only process profitable transactions (taikoxyz#408) commit bc54a67 Author: 1xDeFi <[email protected]> Date: Mon Dec 12 14:07:20 2022 +0100 remove internal variables and functions Removed from: https://taiko.xyz/docs/reference/smart-contracts/L2/TaikoL2
- Loading branch information
Showing
28 changed files
with
447 additions
and
124 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
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
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
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 |
---|---|---|
|
@@ -27,3 +27,5 @@ var ( | |
) | ||
|
||
type HTTPOnly bool | ||
|
||
type ProfitableOnly bool |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package message | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
) | ||
|
||
func (p *Processor) getLatestNonce(ctx context.Context, auth *bind.TransactOpts) error { | ||
pendingNonce, err := p.destEthClient.PendingNonceAt(ctx, p.relayerAddr) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if pendingNonce > p.destNonce { | ||
p.setLatestNonce(pendingNonce) | ||
} | ||
|
||
auth.Nonce = big.NewInt(int64(p.destNonce)) | ||
|
||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package message | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/taikoxyz/taiko-mono/packages/relayer/mock" | ||
) | ||
|
||
func Test_getLatestNonce(t *testing.T) { | ||
p := newTestProcessor(true) | ||
|
||
err := p.getLatestNonce(context.Background(), &bind.TransactOpts{}) | ||
assert.Nil(t, err) | ||
|
||
assert.Equal(t, p.destNonce, mock.PendingNonce) | ||
} |
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,41 @@ | ||
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" | ||
) | ||
|
||
func (p *Processor) isProfitable(ctx context.Context, message contracts.IBridgeMessage, proof []byte) (bool, error) { | ||
processingFee := message.ProcessingFee | ||
|
||
if processingFee == nil || processingFee.Cmp(big.NewInt(0)) != 1 { | ||
return false, nil | ||
} | ||
|
||
auth, err := bind.NewKeyedTransactorWithChainID(p.ecdsaKey, message.DestChainId) | ||
if err != nil { | ||
return false, 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 false, errors.Wrap(err, "p.destBridge.ProcessMessage") | ||
} | ||
|
||
cost := tx.Cost() | ||
|
||
if processingFee.Cmp(cost) != 1 { | ||
return false, nil | ||
} | ||
|
||
return true, nil | ||
} |
Oops, something went wrong.