Skip to content

Commit

Permalink
rm lefthook
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed May 7, 2024
2 parents 9e5631b + 8532b77 commit d1b8f0e
Show file tree
Hide file tree
Showing 24 changed files with 440 additions and 314 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,23 @@ jobs:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-2cb875799419c907cc3709e586ece2559e6b340e
uses: foundry-rs/foundry-toolchain@v1.2.0

- name: Install pnpm dependencies
uses: ./.github/actions/install-pnpm-dependencies

- name: Check formatting
working-directory: ./packages/protocol
run: forge fmt --check

- name: Unit tests
working-directory: ./packages/protocol
run: pnpm clean && pnpm test

- name: Generate contract layout table
- name: Format solidity && update contract layout table
working-directory: ./packages/protocol
run: pnpm layout
run: pnpm layout && forge fmt

- name: Commit contract layout table
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Add contract layout table"
commit_message: "forge fmt & update contract layout table"

- name: Generate genesis
working-directory: ./packages/protocol
Expand Down
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ARG PACKAGE=eventindexer

FROM golang:1.21.0 as builder

ARG PACKAGE=eventindexer
ARG PACKAGE

RUN apt install git curl

Expand All @@ -12,16 +14,17 @@ COPY . .

RUN go mod download

WORKDIR /taiko-mono/packages/$PACKAGE
WORKDIR /taiko-mono/packages/${PACKAGE}

RUN CGO_ENABLED=0 GOOS=linux go build -o /taiko-mono/packages/$PACKAGE/bin/${PACKAGE} /taiko-mono/packages/$PACKAGE/cmd/main.go
RUN CGO_ENABLED=0 GOOS=linux go build -o /taiko-mono/packages/${PACKAGE}/bin/${PACKAGE} /taiko-mono/packages/${PACKAGE}/cmd/main.go

FROM alpine:latest

ARG PACKAGE
ENV PACKAGE=${PACKAGE}

RUN apk add --no-cache ca-certificates

COPY --from=builder /taiko-mono/packages/$PACKAGE/bin/$PACKAGE /usr/local/bin/
COPY --from=builder /taiko-mono/packages/${PACKAGE}/bin/${PACKAGE} /usr/local/bin/

ENTRYPOINT ["$PACKAGE"]
ENTRYPOINT /usr/local/bin/${PACKAGE}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/stretchr/testify v1.9.0
github.com/swaggo/swag v1.16.3
github.com/testcontainers/testcontainers-go v0.30.0
github.com/urfave/cli/v2 v2.27.1
github.com/urfave/cli/v2 v2.27.2
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3
golang.org/x/sync v0.7.0
gopkg.in/go-playground/assert.v1 v1.2.1
Expand Down Expand Up @@ -76,7 +76,7 @@ require (
github.com/containerd/containerd v1.7.12 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
Expand Down Expand Up @@ -186,7 +186,7 @@ require (
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
github.com/yosssi/ace v0.0.5 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E=
github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ=
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs=
github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA=
Expand Down Expand Up @@ -643,8 +643,8 @@ github.com/tursodatabase/libsql-client-go v0.0.0-20240220085343-4ae0eb9d0898 h1:
github.com/tursodatabase/libsql-client-go v0.0.0-20240220085343-4ae0eb9d0898/go.mod h1:9bKuHS7eZh/0mJndbUOrCx8Ej3PlsRDszj4L7oVYMPQ=
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U=
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.22.0/go.mod h1:0mw2RjXGOzxf4NL2jni3gUQ7LfjjUSiG5sskOUUSEpU=
Expand All @@ -671,8 +671,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240126124512-dbb0e1720dbf h1:ckwNHVo4bv2tqNkgx3W3HANh3ta1j6TR5qw08J1A7Tw=
Expand Down
3 changes: 0 additions & 3 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
pre-commit:
parallel: true
commands:
bridge-ui:
glob: "packages/bridge-ui/**.{js,ts,css,svelte}"
run: pnpm -F bridge-ui svelte:check && pnpm -F bridge-ui lint:fix && git add {staged_files}
protocol_sol:
glob: "packages/protocol/**.{sol}"
run: pnpm -F protocol lint:sol && git add {staged_files}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
</div>

<!-- Token Dropdown -->
<TokenDropdown combined class="min-w-[151px] z-20 " {tokens} bind:value={$selectedToken} bind:disabled />
<TokenDropdown combined class="min-w-[151px] z-20" {tokens} bind:value={$selectedToken} bind:disabled />
</div>

<div class="flex mt-[8px] min-h-[24px]">
Expand All @@ -242,9 +242,9 @@
>{$t('recipient.label')} <ProcessingFee textOnly class="text-tertiary-content" bind:hasEnoughEth /></span>
</div>
{:else if showInsufficientBalanceAlert}
<FlatAlert type="error" message={$t('bridge.errors.insufficient_balance.title')} class="relative " />
<FlatAlert type="error" message={$t('bridge.errors.insufficient_balance.title')} class="relative" />
{:else if showInvalidTokenAlert}
<FlatAlert type="error" message={$t('bridge.errors.custom_token.not_found.message')} class="relative " />
<FlatAlert type="error" message={$t('bridge.errors.custom_token.not_found.message')} class="relative" />
{:else}
<LoadingText mask="" class="w-1/2" />
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
<li
role="menuitem"
tabindex="0"
class=" h-[64px] rounded-[10px]
{disabled ? 'opacity-50 ' : 'hover:bg-primary-brand cursor-pointer'}"
class="h-[64px] rounded-[10px] text-primary-content
{disabled ? 'opacity-50' : 'hover:bg-primary-brand hover:text-white'}"
aria-disabled={disabled}>
<label class="f-row items-center w-full h-full p-[16px] text-primary-content hover:text-white">
<label class="f-row items-center w-full h-full p-[16px] {disabled ? 'cursor-not-allowed' : 'cursor-pointer'}">
<input
type="radio"
name="nft-radio"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
menuOpen = false;
};
const openMenu = (event: Event) => {
event.stopPropagation();
const openMenu = () => {
menuOpen = true;
};
Expand Down Expand Up @@ -201,7 +200,7 @@
aria-expanded={menuOpen}
class="f-between-center w-full h-full px-[20px] py-[14px] input-box bg-neutral-background border-0 shadow-none outline-none
{combined ? '!rounded-l-[0px] !rounded-r-[10px]' : '!rounded-[10px]'}"
on:click={openMenu}>
on:click|stopPropagation={openMenu}>
<div class="space-x-2">
{#if !value || disabled}
<span class="title-subsection-bold text-base text-secondary-content">{$t('token_dropdown.label')}</span>
Expand Down
7 changes: 3 additions & 4 deletions packages/bridge-ui/src/components/Tooltip/Tooltip.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
}, ms);
}
function openTooltip(event: Event) {
event.stopPropagation();
function openTooltip() {
tooltipOpen = true;
}
Expand All @@ -45,8 +44,8 @@
aria-haspopup="dialog"
aria-controls={tooltipId}
aria-expanded={tooltipOpen}
on:click={openTooltip}
on:focus={openTooltip}
on:click|stopPropagation={openTooltip}
on:focus|stopPropagation={openTooltip}
on:mouseenter={openTooltip}
bind:this={triggerElem}>
<Icon type="question-circle" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
let openStatusDialog = false;
let tooltipOpen = false;
const openToolTip = (event: Event) => {
event.stopPropagation();
const openToolTip = () => {
tooltipOpen = !tooltipOpen;
};
let dialogId = `dialog-${uid()}`;
Expand Down Expand Up @@ -119,7 +118,7 @@
<li class="f-between-center">
<h4 class="text-secondary-content">
<div class="f-items-center space-x-1">
<button on:click={openToolTip}>
<button on:click|stopPropagation={openToolTip}>
<span>{$t('transactions.header.status')}</span>
</button>
<button on:click={handleStatusDialog} class="flex justify-start content-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@
<h4 class={classes.headline}>{$t('transactions.status.failed.name')}</h4>
{$t('transactions.status.failed.description')}
</div>

<!-- We catch key events aboe -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div role="button" tabindex="0" class="overlay-backdrop" on:click={closeModalIfClickedOutside} />
</div>
<!-- We catch key events aboe -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div role="button" tabindex="0" class="overlay-backdrop" on:click={closeModalIfClickedOutside} />
</dialog>
2 changes: 1 addition & 1 deletion packages/eventindexer/indexer/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func filterFunc(

err = i.saveTransitionProvedEvents(ctx, chainID, transitionProvedEvents)
if err != nil {
return errors.Wrap(err, "i.saveBlockProvenEvents")
return errors.Wrap(err, "i.saveTransitionProvedEvents")
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion packages/eventindexer/indexer/index_nft_transfers.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (i *Indexer) saveERC1155Transfer(ctx context.Context, chainID *big.Int, vLo
}

transfers = append(transfers, t)
} else if vLog.Topics[0].Hex() != transferBatchSignatureHash.Hex() {
} else if vLog.Topics[0].Hex() == transferBatchSignatureHash.Hex() {
var t []transfer

err = erc1155ABI.UnpackIntoInterface(&t, "TransferBatch", []byte(vLog.Data))
Expand Down
54 changes: 28 additions & 26 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ library LibProving {
ITierProvider.Tier tier;
bytes32 metaHash;
address assignedProver;
uint96 livenessBond;
uint64 slot;
uint64 blockId;
uint32 tid;
Expand Down Expand Up @@ -201,26 +200,8 @@ library LibProving {
}

local.isTopTier = local.tier.contestBond == 0;
IERC20 tko = IERC20(_resolver.resolve(LibStrings.B_TAIKO_TOKEN, false));

local.livenessBond = blk.livenessBond;
if (local.isTopTier) {
if (local.livenessBond != 0) {
if (
local.inProvingWindow
|| (
_proof.data.length == 32
&& bytes32(_proof.data) == LibStrings.H_RETURN_LIVENESS_BOND
)
) {
tko.safeTransfer(local.assignedProver, local.livenessBond);
}
blk.livenessBond = 0;
local.livenessBond = 0;
}
}

local.sameTransition = _tran.blockHash == ts.blockHash && _tran.stateRoot == ts.stateRoot;
IERC20 tko = IERC20(_resolver.resolve(LibStrings.B_TAIKO_TOKEN, false));

if (_proof.tier > ts.tier) {
// Handles the case when an incoming tier is higher than the current transition's tier.
Expand Down Expand Up @@ -403,6 +384,8 @@ library LibProving {
uint256 reward; // reward to the new (current) prover

if (_ts.contester != address(0)) {
// assert(_blk.livenessBond == 0);

if (_local.sameTransition) {
// The contested transition is proven to be valid, contester loses the game
reward = _rewardAfterFriction(_ts.contestBond);
Expand All @@ -424,14 +407,19 @@ library LibProving {
// - 2) the transition is contested.
reward = _rewardAfterFriction(_ts.validityBond);

if (_local.livenessBond != 0) {
if (_local.assignedProver == msg.sender && _local.inProvingWindow) {
unchecked {
reward += _local.livenessBond;
uint256 livenessBond = _blk.livenessBond;
if (livenessBond != 0) {
// After the first proof, the block's liveness bond will always be reset to 0.
// This means liveness bond will be handled only once for any given block.
_blk.livenessBond = 0;

if (_returnLivenessBond(_local, _proof.data)) {
if (_blk.assignedProver == msg.sender) {
reward += livenessBond;
} else {
_tko.safeTransfer(_blk.assignedProver, livenessBond);
}
}
_blk.livenessBond = 0;
_local.livenessBond = 0;
}
}

Expand Down Expand Up @@ -459,4 +447,18 @@ library LibProving {
function _rewardAfterFriction(uint256 _amount) private pure returns (uint256) {
return _amount == 0 ? 0 : (_amount * 7) >> 3;
}

/// @dev Returns if the liveness bond shall be returned.
function _returnLivenessBond(
Local memory _local,
bytes memory _proofData
)
private
pure
returns (bool)
{
return _local.inProvingWindow && _local.tid == 1
|| _local.isTopTier && _proofData.length == 32
&& bytes32(_proofData) == LibStrings.H_RETURN_LIVENESS_BOND;
}
}
2 changes: 1 addition & 1 deletion packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ contract Bridge is EssentialContract, IBridge {
// Check if the destination chain is enabled.
(bool destChainEnabled,) = isDestChainEnabled(_message.destChainId);

// Verify destination chain and to address.
// Verify destination chain.
if (!destChainEnabled) revert B_INVALID_CHAINID();

// Ensure the sent value matches the expected amount.
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/tokenvault/BridgedERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract BridgedERC20 is EssentialContract, IBridgedERC20, ERC20Upgradeable {
initializer
{
// Check if provided parameters are valid
LibBridgedToken.validateInputs(_srcToken, _srcChainId, _symbol, _name);
LibBridgedToken.validateInputs(_srcToken, _srcChainId);
__Essential_init(_owner, _addressManager);
__ERC20_init(_name, _symbol);

Expand Down
15 changes: 0 additions & 15 deletions packages/protocol/contracts/tokenvault/LibBridgedToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@ library LibBridgedToken {
}
}

function validateInputs(
address _srcToken,
uint256 _srcChainId,
string memory _symbol,
string memory _name
)
internal
view
{
validateInputs(_srcToken, _srcChainId);
if (bytes(_symbol).length == 0 || bytes(_name).length == 0) {
revert BTOKEN_INVALID_PARAMS();
}
}

function checkToAddress(address _to) internal view {
if (_to == address(this)) revert BTOKEN_INVALID_TO_ADDR();
}
Expand Down
Loading

0 comments on commit d1b8f0e

Please sign in to comment.