Skip to content

Commit

Permalink
feat(protocol): major protocol upgrade for alpha-3 testnet (#13640)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeffery Walsh <cyberhorsey@gmail.com>
Co-authored-by: David <david@taiko.xyz>
Co-authored-by: jeff <113397187+cyberhorsey@users.noreply.github.com>
Co-authored-by: dave | d1onys1us <13951458+d1onys1us@users.noreply.github.com>
Co-authored-by: Brecht Devos <Brechtp.Devos@gmail.com>
Co-authored-by: D <51912515+adaki2004@users.noreply.github.com>
Co-authored-by: Keszey Dániel <keszeyd@MacBook-Pro.local>
Co-authored-by: adaki2004 <keszeydani@gmail.com>
Co-authored-by: Daniel Wang <dong77@gmail.com>
Co-authored-by: Francisco Ramos <jscriptcoder@gmail.com>
  • Loading branch information
11 people committed May 3, 2023
1 parent 864151f commit 02552f2
Show file tree
Hide file tree
Showing 296 changed files with 129,157 additions and 18,331 deletions.
51 changes: 25 additions & 26 deletions .github/workflows/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,46 @@ jobs:

- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

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

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

- name: protocol - Integration Tests
working-directory: ./packages/protocol
run: pnpm test:integration

- name: protocol - Tokenomics Tests
working-directory: ./packages/protocol
run: pnpm test:tokenomics

- name: protocol - Bridge Tests
working-directory: ./packages/protocol
run: pnpm test:bridge

- name: protocol - Test Coverage
working-directory: ./packages/protocol
run: pnpm test:coverage
run: pnpm clean && pnpm compile:hardhat && pnpm test

- name: protocol - Generate Genesis
working-directory: ./packages/protocol
run: pnpm test:genesis

- name: protocol - Export ABIs
# TODO: CompilerError: Stack too deep
# - name: protocol - Test Coverage
# working-directory: ./packages/protocol
# run: pnpm test:coverage

- name: protocol - Run snapshot (foundry)
working-directory: ./packages/protocol
run: pnpm export:abi
run: pnpm snapshot

- name: protocol - Deploy L1 Contracts
working-directory: ./packages/protocol
run: pnpm deploy:hardhat

- name: protocol - Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
directory: ./packages/protocol/coverage
flags: protocol
run: |
anvil &
while ! nc -z localhost 8545; do
sleep 1
done
pnpm deploy:foundry
# - name: protocol - Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# directory: ./packages/protocol/coverage
# flags: protocol

post-merge:
if: github.event.pull_request.merged == true
Expand Down
16 changes: 16 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[submodule "packages/protocol/lib/solmate"]
path = packages/protocol/lib/solmate
url = https://github.com/rari-capital/solmate
branch = v1.5.0
[submodule "packages/protocol/lib/openzeppelin-contracts-upgradeable"]
path = packages/protocol/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
branch = v4.8.2
[submodule "packages/protocol/lib/openzeppelin-contracts"]
path = packages/protocol/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
branch = v4.8.2
[submodule "packages/protocol/lib/forge-std"]
path = packages/protocol/lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = chore/v1.5.1
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
[![Twitter Follow](https://img.shields.io/twitter/follow/taikoxyz?style=social)](https://twitter.com/taikoxyz)
[![Discord](https://img.shields.io/discord/984015101017346058?color=%235865F2&label=Discord&logo=discord&logoColor=%23fff)](https://discord.gg/taikoxyz)
[![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/taikoxyz/taiko-mono/badge)](https://www.gitpoap.io/gh/taikoxyz/taiko-mono)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/taikoxyz/taiko-mono/protocol.yml?branch=main&label=Protocol&logo=github)](https://github.com/taikoxyz/taiko-mono/actions/workflows/protocol.yml)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/taikoxyz/taiko-mono/relayer.yml?branch=main&label=Relayer&logo=github)](https://github.com/taikoxyz/taiko-mono/actions/workflows/relayer.yml)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/taikoxyz/taiko-mono/bridge-ui.yml?branch=main&label=Bridge%20UI&logo=github)](https://github.com/taikoxyz/taiko-mono/actions/workflows/bridge-ui.yml)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/taikoxyz/taiko-mono/website.yml?branch=main&label=Website&logo=github)](https://github.com/taikoxyz/taiko-mono/actions/workflows/website.yml)
[![License](https://img.shields.io/github/license/taikoxyz/taiko-mono)](https://github.com/taikoxyz/taiko-mono/blob/main/LICENSE.md)

</div>
Expand All @@ -41,7 +45,6 @@ taiko-mono/
│ ├── <a href="./packages/relayer">relayer</a>: Bridge backend relayer in Go
│ ├── <a href="./packages/starter-dapp">starter-dapp</a>: Template for Taiko dapps
│ ├── <a href="./packages/status-page">status-page</a>: Taiko protocol status page
│ ├── <a href="./packages/tokenomics">tokenomics</a>: Taiko tokenomics simulations
│ ├── <a href="./packages/website">website</a>: Main documentation website at taiko.xyz (https://taiko.xyz/)
│ └── <a href="./packages/whitepaper">whitepaper</a>: Whitepaper source files with automated publishing
...
Expand Down
16 changes: 7 additions & 9 deletions packages/bridge-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,18 @@

## [0.3.0](https://github.com/taikoxyz/taiko-mono/compare/bridge-ui-v0.2.0...bridge-ui-v0.3.0) (2023-03-15)


### Features

* **bridge-ui:** custom recipient address ([#13309](https://github.com/taikoxyz/taiko-mono/issues/13309)) ([56d8848](https://github.com/taikoxyz/taiko-mono/commit/56d884812b3f12a52895bc666cb25e6edbe6eba0))
* **bridge-ui:** fetch transactions from relayer api ([#13244](https://github.com/taikoxyz/taiko-mono/issues/13244)) ([9732cc0](https://github.com/taikoxyz/taiko-mono/commit/9732cc084ed99196a4cd2ccedf9187af4d289ed6))
* **bridge-ui:** support both bull and horse tokens on the bridge UI ([#13249](https://github.com/taikoxyz/taiko-mono/issues/13249)) ([f9f38bb](https://github.com/taikoxyz/taiko-mono/commit/f9f38bb075c02c7976e0d04c84e4b8b5ac255644))
* **bridge-ui:** support route param to directly open transactions tab ([#13281](https://github.com/taikoxyz/taiko-mono/issues/13281)) ([b4c31cd](https://github.com/taikoxyz/taiko-mono/commit/b4c31cd8566b834cbf83a434c705fb281d375d12))

- **bridge-ui:** custom recipient address ([#13309](https://github.com/taikoxyz/taiko-mono/issues/13309)) ([56d8848](https://github.com/taikoxyz/taiko-mono/commit/56d884812b3f12a52895bc666cb25e6edbe6eba0))
- **bridge-ui:** fetch transactions from relayer api ([#13244](https://github.com/taikoxyz/taiko-mono/issues/13244)) ([9732cc0](https://github.com/taikoxyz/taiko-mono/commit/9732cc084ed99196a4cd2ccedf9187af4d289ed6))
- **bridge-ui:** support both bull and horse tokens on the bridge UI ([#13249](https://github.com/taikoxyz/taiko-mono/issues/13249)) ([f9f38bb](https://github.com/taikoxyz/taiko-mono/commit/f9f38bb075c02c7976e0d04c84e4b8b5ac255644))
- **bridge-ui:** support route param to directly open transactions tab ([#13281](https://github.com/taikoxyz/taiko-mono/issues/13281)) ([b4c31cd](https://github.com/taikoxyz/taiko-mono/commit/b4c31cd8566b834cbf83a434c705fb281d375d12))

### Bug Fixes

* **bridge-ui:** minor transactions list fix ([#13266](https://github.com/taikoxyz/taiko-mono/issues/13266)) ([4e78865](https://github.com/taikoxyz/taiko-mono/commit/4e788655ebd508eca3e1665ecb50f3010d2f51af))
* **bridge-ui:** transaction and pendingTransaction refactor ([#13307](https://github.com/taikoxyz/taiko-mono/issues/13307)) ([9d215cf](https://github.com/taikoxyz/taiko-mono/commit/9d215cfe5ac6863405390444672a1e70e7501032))
* **website,bridge-ui:** broken docs link + remove deprecated note in docs ([#13259](https://github.com/taikoxyz/taiko-mono/issues/13259)) ([912c155](https://github.com/taikoxyz/taiko-mono/commit/912c15595d7b0e3e2b4ec62fbcebeaf9dbc9db66))
- **bridge-ui:** minor transactions list fix ([#13266](https://github.com/taikoxyz/taiko-mono/issues/13266)) ([4e78865](https://github.com/taikoxyz/taiko-mono/commit/4e788655ebd508eca3e1665ecb50f3010d2f51af))
- **bridge-ui:** transaction and pendingTransaction refactor ([#13307](https://github.com/taikoxyz/taiko-mono/issues/13307)) ([9d215cf](https://github.com/taikoxyz/taiko-mono/commit/9d215cfe5ac6863405390444672a1e70e7501032))
- **website,bridge-ui:** broken docs link + remove deprecated note in docs ([#13259](https://github.com/taikoxyz/taiko-mono/issues/13259)) ([912c155](https://github.com/taikoxyz/taiko-mono/commit/912c15595d7b0e3e2b4ec62fbcebeaf9dbc9db66))

## [0.2.0](https://github.com/taikoxyz/taiko-mono/compare/bridge-ui-v0.1.2...bridge-ui-v0.2.0) (2023-03-01)

Expand Down
1 change: 1 addition & 0 deletions packages/bridge-ui/src/bridge/ERC20Bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export class ERC20Bridge implements Bridge {
messageStatus === MessageStatus.Done ||
messageStatus === MessageStatus.Failed
) {
// TODO: should be throw a different error when status is Failed?
throw Error('message already processed');
}

Expand Down
6 changes: 6 additions & 0 deletions packages/bridge-ui/src/bridge/ETHBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,18 @@ export class ETHBridge implements Bridge {
throw Error('message already processed');
}

if (messageStatus === MessageStatus.Failed) {
throw Error('user can not process this, message has failed');
}

const signerAddress = await opts.signer.getAddress();

if (opts.message.owner.toLowerCase() !== signerAddress.toLowerCase()) {
throw Error('user can not process this, it is not their message');
}

// TODO: up to here we share same logic as ERC20Bridge

if (messageStatus === MessageStatus.New) {
const proofOpts = {
srcChain: opts.message.srcChainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import { LottiePlayer } from '@lottiefiles/svelte-lottie-player';
import { errorToast, successToast } from '../Toast.svelte';
import HeaderSyncABI from '../../constants/abi/HeaderSync';
import HeaderSyncABI from '../../constants/abi/ICrossChainSync';
import BridgeABI from '../../constants/abi/Bridge';
import ButtonWithTooltip from '../ButtonWithTooltip.svelte';
import TokenVaultABI from '../../constants/abi/TokenVault';
Expand Down Expand Up @@ -180,7 +180,7 @@
providers[chains[transaction.toChainId].id],
);
const latestSyncedHeader = await contract.getLatestSyncedHeader();
const latestSyncedHeader = await contract.getCrossChainBlockHash(0);
const srcBlock = await providers[
chains[transaction.fromChainId].id
].getBlock(latestSyncedHeader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,28 @@ export default [
{
indexed: false,
internalType: 'bytes32',
name: 'srcHash',
name: 'blockHash',
type: 'bytes32',
},
{
indexed: false,
internalType: 'bytes32',
name: 'signalRoot',
type: 'bytes32',
},
],
name: 'HeaderSynced',
name: 'CrossChainSynced',
type: 'event',
},
{
inputs: [],
name: 'getLatestSyncedHeader',
inputs: [
{
internalType: 'uint256',
name: 'number',
type: 'uint256',
},
],
name: 'getCrossChainBlockHash',
outputs: [
{
internalType: 'bytes32',
Expand All @@ -39,7 +51,7 @@ export default [
type: 'uint256',
},
],
name: 'getSyncedHeader',
name: 'getCrossChainSignalRoot',
outputs: [
{
internalType: 'bytes32',
Expand Down
8 changes: 3 additions & 5 deletions packages/bridge-ui/src/proof/ProofService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const mockProvider = {
};

const mockContract = {
getLatestSyncedHeader: jest.fn(),
getCrossChainBlockHash: jest.fn(),
};

jest.mock('ethers', () => ({
Expand Down Expand Up @@ -105,11 +105,9 @@ const invalidStorageProof2: EthGetProofResponse = {
};

const expectedProof =
'0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000380a7881266ca0a344c43cb24175d9dbd243b58d45d6ae6ad71310a273a3d1d3afb1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347000000000000000000000000ea674fdde714fd979de3edf0f56aa9716b898ec8c0dcf937b3f6136dd70a1ad11cc57b040fd410f3c49a5146f20c732895a3cc217273ade6b6ed865a9975ac281da23b90b141a8b607d874d2cd95e65e81336f8e74bb61e381e9238a08b169580f3cbf9b8b79d7d5ee708d3e286103eb291dfd0800000000000400000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000020000000000000000000000000000000000000000000000000100000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b0000000000000000000000000000000000000000000000000000000000000300f5ba25df1e92e89a09e0b32063b81795f631100801158f5fa733f2ba26843bd0000000000000000000000000000000000000000000000000000000000000007b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001265746865726d696e652d75732d7765737431000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022e1a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';

'0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000380a7881266ca0a344c43cb24175d9dbd243b58d45d6ae6ad71310a273a3d1d3afb1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347000000000000000000000000ea674fdde714fd979de3edf0f56aa9716b898ec8c0dcf937b3f6136dd70a1ad11cc57b040fd410f3c49a5146f20c732895a3cc217273ade6b6ed865a9975ac281da23b90b141a8b607d874d2cd95e65e81336f8e74bb61e381e9238a08b169580f3cbf9b8b79d7d5ee708d3e286103eb291dfd0800000000000400000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000020000000000000000000000000000000000000000000000000100000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b0000000000000000000000000000000000000000000000000000000000000300f5ba25df1e92e89a09e0b32063b81795f631100801158f5fa733f2ba26843bd0000000000000000000000000000000000000000000000000000000000000007b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001265746865726d696e652d75732d776573743100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022e1a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
const expectedProofWithBaseFee =
'0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000380a7881266ca0a344c43cb24175d9dbd243b58d45d6ae6ad71310a273a3d1d3afb1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347000000000000000000000000ea674fdde714fd979de3edf0f56aa9716b898ec8c0dcf937b3f6136dd70a1ad11cc57b040fd410f3c49a5146f20c732895a3cc217273ade6b6ed865a9975ac281da23b90b141a8b607d874d2cd95e65e81336f8e74bb61e381e9238a08b169580f3cbf9b8b79d7d5ee708d3e286103eb291dfd0800000000000400000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000020000000000000000000000000000000000000000000000000100000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b0000000000000000000000000000000000000000000000000000000000000300f5ba25df1e92e89a09e0b32063b81795f631100801158f5fa733f2ba26843bd0000000000000000000000000000000000000000000000000000000000000007b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001265746865726d696e652d75732d7765737431000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022e1a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';

'0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000380a7881266ca0a344c43cb24175d9dbd243b58d45d6ae6ad71310a273a3d1d3afb1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347000000000000000000000000ea674fdde714fd979de3edf0f56aa9716b898ec8c0dcf937b3f6136dd70a1ad11cc57b040fd410f3c49a5146f20c732895a3cc217273ade6b6ed865a9975ac281da23b90b141a8b607d874d2cd95e65e81336f8e74bb61e381e9238a08b169580f3cbf9b8b79d7d5ee708d3e286103eb291dfd0800000000000400000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000020000000000000000000000000000000000000000000000000100000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b0000000000000000000000000000000000000000000000000000000000000300f5ba25df1e92e89a09e0b32063b81795f631100801158f5fa733f2ba26843bd0000000000000000000000000000000000000000000000000000000000000007b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001265746865726d696e652d75732d776573743100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022e1a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
const srcChain = 167001;
const destChain = 31336;

Expand Down
Loading

0 comments on commit 02552f2

Please sign in to comment.