Skip to content

Commit

Permalink
Merge branch 'main' into taikoon-ui-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bearni95 committed Apr 26, 2024
2 parents a816b7c + b392911 commit b0de72e
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 181 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/taikoon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:

- name: Unit Tests
working-directory: ./packages/taikoon
run: pnpm clean && pnpm compile && pnpm test
run: pnpm test
3 changes: 0 additions & 3 deletions packages/relayer/pkg/proof/block_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package proof

import (
"context"
"log/slog"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand All @@ -27,8 +26,6 @@ func (p *Prover) blockHeader(
return encoding.BlockHeader{}, errors.Wrap(err, "blocker.BlockByNumber")
}
} else {
slog.Info("getting block by hash", "blockHash", blockHash.Hex())

b, err = blocker.BlockByHash(ctx, blockHash)
if err != nil {
return encoding.BlockHeader{}, errors.Wrap(err, "blocker.BlockByHash")
Expand Down
8 changes: 0 additions & 8 deletions packages/relayer/pkg/proof/encoded_signal_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"math/big"

"log/slog"

"github.com/taikoxyz/taiko-mono/packages/relayer"
"github.com/taikoxyz/taiko-mono/packages/relayer/pkg/encoding"

Expand Down Expand Up @@ -89,12 +87,6 @@ func (p *Prover) getProof(
) (*StorageProof, error) {
var ethProof StorageProof

slog.Info("getting proof",
"signalServiceAddress", signalServiceAddress.Hex(),
"key", key,
"blockNum", blockNumber,
)

err := c.CallContext(ctx,
&ethProof,
"eth_getProof",
Expand Down
13 changes: 9 additions & 4 deletions packages/relayer/processor/is_profitable.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import (

"log/slog"

"github.com/pkg/errors"
"github.com/taikoxyz/taiko-mono/packages/relayer"
)

var (
errImpossible = errors.New("impossible to process")
)

// isProfitable determines whether a message is profitable or not. It should
// check the processing fee, if one does not exist at all, it is definitely not
// profitable. Otherwise, we compare it to the estimated cost.
Expand All @@ -26,13 +31,13 @@ func (p *Processor) isProfitable(
"gasLimit", gasLimit,
)

return shouldProcess, nil
return shouldProcess, errImpossible
}

// if processing fee is higher than baseFee * gasLimit,
// we should process.
res := (destChainBaseFee + gasTipCap) * uint64(gasLimit)
if fee > res {
estimatedOnchainFee := (destChainBaseFee + gasTipCap) * uint64(gasLimit)
if fee > estimatedOnchainFee {
shouldProcess = true
}

Expand All @@ -41,7 +46,7 @@ func (p *Processor) isProfitable(
"destChainBaseFee", destChainBaseFee,
"gasLimit", gasLimit,
"shouldProcess", shouldProcess,
"result", res,
"estimatedOnchainFee", estimatedOnchainFee,
)

if !shouldProcess {
Expand Down
2 changes: 1 addition & 1 deletion packages/relayer/processor/is_profitable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Test_isProfitable(t *testing.T) {
1,
1,
false,
nil,
errImpossible,
},
{
"profitable",
Expand Down
21 changes: 4 additions & 17 deletions packages/relayer/processor/process_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,10 @@ func (p *Processor) processMessage(
return false, nil
}

slog.Info("waiting for confirmations",
"msgHash", common.BytesToHash(msgBody.Event.MsgHash[:]).Hex(),
)

if err := p.waitForConfirmations(ctx, msgBody.Event.Raw.TxHash, msgBody.Event.Raw.BlockNumber); err != nil {
return false, err
}

slog.Info("done waiting for confirmations",
"msgHash", common.BytesToHash(msgBody.Event.MsgHash[:]).Hex(),
)

encodedSignalProof, err := p.generateEncodedSignalProof(ctx, msgBody.Event)
if err != nil {
return false, err
Expand Down Expand Up @@ -314,11 +306,6 @@ func (p *Processor) sendProcessMessageCall(
return nil, err
}

slog.Info("message received on dest chain",
"received", received,
"srcTxHash", event.Raw.TxHash.Hex(),
)

// message will fail when we try to process it
if !received {
slog.Warn("Message not received on dest chain",
Expand Down Expand Up @@ -360,6 +347,10 @@ func (p *Processor) sendProcessMessageCall(
gasTipCap.Uint64(),
)
if err != nil || !profitable {
if err == errImpossible {
return nil, errImpossible
}

return nil, relayer.ErrUnprofitable
}
// now simulate the transaction and lets confirm
Expand Down Expand Up @@ -519,9 +510,5 @@ func (p *Processor) getBaseFee(ctx context.Context) (*big.Int, error) {
baseFee = eip1559.CalcBaseFee(cfg, blk.Header())
}

slog.Info("destChain base fee",
"baseFee", baseFee.String(),
)

return baseFee, nil
}
5 changes: 5 additions & 0 deletions packages/taikoon/contracts/MerkleWhitelist.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ contract MerkleWhitelist is ContextUpgradeable {

uint256[48] private __gap;

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

/// @notice Contract initializer
/// @param _root Merkle Tree root
function initialize(bytes32 _root) external initializer {
Expand Down
2 changes: 1 addition & 1 deletion packages/taikoon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"eslint": "pnpm exec eslint --ignore-path .eslintignore --ext .js,.ts .",
"fmt:sol": "forge fmt",
"lint:sol": "forge fmt && pnpm solhint 'contracts/**/*.sol'",
"test": "forge test --match-path 'test/*.t.sol' -vvv",
"test": "pnpm clean && pnpm compile && forge test --match-path 'test/*.t.sol' -vvv",
"node": "anvil",
"merkle": "node script/js/generate-merkle-tree.js",
"deploy:localhost": "forge clean && pnpm compile && forge script script/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast",
Expand Down
Loading

0 comments on commit b0de72e

Please sign in to comment.