Skip to content

Commit

Permalink
V3 Internal Review (#2733)
Browse files Browse the repository at this point in the history
### Description

Merges v3 feature branch to main

### Backward compatibility

No

### Testing

All

---------
Co-authored-by: Kunal Arora <55632507+aroralanuk@users.noreply.github.com>
Co-authored-by: Daniel Savu <23065004+daniel-savu@users.noreply.github.com>
Co-authored-by: Trevor Porter <trkporter@ucdavis.edu>
Co-authored-by: Mattie Conover <git@mconover.dev>
Co-authored-by: Guillaume Bouvignies <guillaume.bouvignies@kurtosistech.com>
Co-authored-by: Nam Chu Hoai <nambrot@googlemail.com>
Co-authored-by: J M Rossy <jm.rossy@gmail.com>
Co-authored-by: OttBunn <132830906+ottbunn@users.noreply.github.com>
Co-authored-by: Rohan Shrothrium <shrothriumrohan@gmail.com>
  • Loading branch information
yorhodes authored Nov 16, 2023
1 parent 9c39d68 commit 3208796
Show file tree
Hide file tree
Showing 642 changed files with 39,103 additions and 29,384 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
typescript/sdk/src/cw-types/*.types.ts linguist-generated=true
rust/chains/hyperlane-ethereum/abis/*.abi.json linguist-generated=true
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typescript/token @yorhodes @jmrossy @tkporter @aroralanuk
typescript/helloworld @yorhodes @nambrot

## CLI
typescript/cli @jmrossy @yorhodes
typescript/cli @jmrossy @yorhodes @aroralanuk

## Infra
typescript/infra @tkporter @nambrot
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches: [main]
pull_request:
branches: '*'
workflow_dispatch:

concurrency:
Expand Down
21 changes: 5 additions & 16 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ name: node
on:
# Triggers the workflow on push or pull request against main
push:
branches: [main]
branches: [v3]
pull_request:
branches: [main]

branches: [v3]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand Down Expand Up @@ -50,9 +49,6 @@ jobs:
with:
node-version: 18

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

- name: yarn-cache
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -102,9 +98,6 @@ jobs:
with:
submodules: recursive

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

- uses: actions/cache@v3
with:
path: ./*
Expand All @@ -116,9 +109,6 @@ jobs:
- name: helloworld
run: yarn workspace @hyperlane-xyz/helloworld run test

- name: token
run: yarn workspace @hyperlane-xyz/hyperlane-token run test

- name: infra
run: yarn workspace @hyperlane-xyz/infra run test

Expand All @@ -145,10 +135,9 @@ jobs:
runs-on: ubuntu-latest
needs: [yarn-build]
strategy:
fail-fast: false
matrix:
environment: [testnet3, mainnet2]
module: [ism, core, igp, ica, helloworld]
environment: [testnet4, mainnet3]
module: [ism, core, helloworld]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -200,7 +189,7 @@ jobs:
- name: Unit tests
run: yarn workspace @hyperlane-xyz/core run test

- name: Run Slither
- name: Static analysis
uses: crytic/slither-action@v0.3.0
id: slither
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust-skipped.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: rust

on:
pull_request:
branches: [main]
branches: [main, v3]
paths-ignore:
- 'rust/**'

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ yarn-error.log
**/*.ignore
.vscode

tsconfig.editor.json
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "solidity/lib/forge-std"]
path = solidity/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "typescript/token/lib/forge-std"]
path = typescript/token/lib/forge-std
url = https://github.com/foundry-rs/forge-std
6 changes: 3 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"explicitTypes": "always"
"bracketSpacing": false
}
}
],
"importOrder": ["^@hyperlane-xyz/(.*)$", "^../(.*)$", "^./(.*)$"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true
"importOrderSortSpecifiers": true,
"plugins": ["prettier-plugin-solidity", "@trivago/prettier-plugin-sort-imports"]
}
785 changes: 0 additions & 785 deletions .yarn/releases/yarn-3.2.0.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.1.cjs

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
compressionLevel: mixed

enableGlobalCache: false

enableScripts: false

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-outdated.cjs
spec: "https://mskelton.dev/yarn-outdated/v3"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"

yarnPath: .yarn/releases/yarn-3.2.0.cjs
yarnPath: .yarn/releases/yarn-4.0.1.cjs
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM node:16-alpine
FROM node:18-alpine

WORKDIR /hyperlane-monorepo

RUN apk add --update --no-cache git g++ make py3-pip

RUN yarn set version 3.2.0
RUN yarn plugin import workspace-tools
RUN yarn set version 4.0.1

# Copy package.json and friends
COPY package.json yarn.lock .yarnrc.yml ./
Expand All @@ -14,7 +13,6 @@ COPY .yarn/releases ./.yarn/releases
COPY typescript/utils/package.json ./typescript/utils/
COPY typescript/sdk/package.json ./typescript/sdk/
COPY typescript/helloworld/package.json ./typescript/helloworld/
COPY typescript/token/package.json ./typescript/token/
COPY typescript/cli/package.json ./typescript/cli/
COPY typescript/infra/package.json ./typescript/infra/
COPY solidity/package.json ./solidity/
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@

## Versioning

Note this is the branch for Hyperlane v2.
Note this is the branch for Hyperlane v3.

V1 has since been deprecated in favor of V2, but if you are looking for code relating to the existing V1 deployments of the `testnet2` or `mainnet` environments, refer to the [v1](https://github.com/hyperlane-xyz/hyperlane-monorepo/tree/v1) branch.
V2 is still in operation but is not being actively developed. The code for V2 can be found in the [v2](https://github.com/hyperlane-xyz/hyperlane-monorepo/tree/v2) branch.

V1 has since been deprecated in favor of V2, but if you are looking for code relating to the existing V1 deployments, refer to the [v1](https://github.com/hyperlane-xyz/hyperlane-monorepo/tree/v1) branch.

## Overview

Expand Down
31 changes: 31 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
comment:
layout: "header, diff, flags, components" # show component info in the PR comment

component_management:
default_rules: # default rules that will be inherited by all components
statuses:
- type: project # in this case every component that doens't have a status defined will have a project type one
target: auto
branches:
- "!main"
individual_components:
- component_id: module_core
name: core
paths:
- solidity/contracts/Mailbox.sol
- component_id: module_hooks
name: hooks
paths:
- solidity/contracts/hooks/**
- component_id: module_isms
name: isms
paths:
- solidity/contracts/isms/**
- component_id: module_token
name: token
paths:
- solidity/contracts/token/**
- component_id: module_middlewares
name: middlewares
paths:
- solidity/contracts/middleware/**
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A yarn workspace of core Hyperlane packages",
"version": "0.0.0",
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@trivago/prettier-plugin-sort-imports": "^4.2.1",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.43.0",
Expand All @@ -12,19 +12,19 @@
"lint-staged": "^12.4.3",
"prettier": "^2.8.8"
},
"packageManager": "yarn@3.2.0",
"packageManager": "yarn@4.0.1",
"private": true,
"scripts": {
"build": "yarn workspaces foreach --verbose --parallel --topological run build",
"clean": "yarn workspaces foreach --verbose --parallel run clean",
"build": "yarn workspaces foreach --all --parallel --topological run build",
"clean": "yarn workspaces foreach --all --parallel run clean",
"prettier": "yarn workspaces foreach --all --parallel run prettier",
"lint": "yarn workspaces foreach --all --parallel run lint",
"test": "yarn workspaces foreach --all --parallel run test",
"coverage": "yarn workspaces foreach --all --parallel run coverage",
"version:prepare": "yarn workspaces foreach --all --no-private --topological version --immediate",
"publish:all": "yarn workspaces foreach --all --no-private --topological npm publish --access public",
"postinstall": "husky install",
"prettier": "yarn workspaces foreach --verbose --parallel run prettier",
"lint": "yarn workspaces foreach --verbose --parallel run lint",
"test": "yarn workspaces foreach --verbose --parallel run test",
"coverage": "yarn workspaces foreach --verbose --parallel run coverage",
"version:check": "yarn version check --interactive",
"version:prepare": "yarn workspaces foreach --no-private --verbose --topological version --immediate",
"publish:all": "yarn workspaces foreach --no-private --verbose --topological npm publish --access public"
"version:check": "yarn version check --interactive"
},
"workspaces": [
"solidity",
Expand Down
1 change: 1 addition & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ kubectl cp testnet3/fuji-hyperlane-agent-validator-0:/usr/share/hyperlane /tmp/f
Configure additional env variables appropriately:

```bash
HYP_BASE_DB=/tmp/fuji-validator-db
HYP_DB=/tmp/fuji-validator-db
CONFIG_FILES=./config/testnet_config.json
HYP_BASE_TRACING_FMT=pretty
HYP_TRACING_FMT=pretty
DATABASE_URL=<READ_REPLICA_POSTGRES_URL> # for scraper
```

Expand Down
1 change: 1 addition & 0 deletions rust/agents/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ version.workspace = true
[dependencies]
async-trait.workspace = true
config.workspace = true
convert_case.workspace = true
derive-new.workspace = true
derive_more.workspace = true
enum_dispatch.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion rust/agents/relayer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ use hyperlane_base::agent_main;

use crate::relayer::Relayer;

mod merkle_tree_builder;
mod merkle_tree;
mod msg;
mod processor;
mod prover;
mod relayer;
mod settings;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::fmt::Display;

use eyre::Result;
use eyre::{Context, Result};
use tracing::{debug, error, instrument};

use hyperlane_base::db::{DbError, HyperlaneRocksDB};
use hyperlane_base::db::DbError;
use hyperlane_core::{
accumulator::{incremental::IncrementalMerkle, merkle::Proof},
ChainCommunicationError, H256,
Expand All @@ -14,7 +14,6 @@ use crate::prover::{Prover, ProverError};
/// Struct to sync prover.
#[derive(Debug)]
pub struct MerkleTreeBuilder {
db: HyperlaneRocksDB,
prover: Prover,
incremental: IncrementalMerkle,
}
Expand Down Expand Up @@ -50,12 +49,6 @@ pub enum MerkleTreeBuilderError {
/// Root of the incremental merkle tree
incremental_root: H256,
},
/// Nonce was not found in DB, despite batch providing messages after
#[error("Nonce was not found {nonce:?}")]
UnavailableNonce {
/// Root of prover's local merkle tree
nonce: u32,
},
/// MerkleTreeBuilder attempts Prover operation and receives ProverError
#[error(transparent)]
ProverError(#[from] ProverError),
Expand All @@ -68,13 +61,12 @@ pub enum MerkleTreeBuilderError {
}

impl MerkleTreeBuilder {
pub fn new(db: HyperlaneRocksDB) -> Self {
pub fn new() -> Self {
let prover = Prover::default();
let incremental = IncrementalMerkle::default();
Self {
prover,
incremental,
db,
}
}

Expand All @@ -86,49 +78,25 @@ impl MerkleTreeBuilder {
) -> Result<Proof, MerkleTreeBuilderError> {
self.prover
.prove_against_previous(leaf_index as usize, root_index as usize)
.map_err(Into::into)
}

fn ingest_nonce(&mut self, nonce: u32) -> Result<(), MerkleTreeBuilderError> {
match self.db.retrieve_message_id_by_nonce(&nonce) {
Ok(Some(leaf)) => {
debug!(nonce, "Ingesting leaf");
self.prover.ingest(leaf).expect("!tree full");
self.incremental.ingest(leaf);
assert_eq!(self.prover.root(), self.incremental.root());
Ok(())
}
Ok(None) => {
error!("We should not arrive here");
Err(MerkleTreeBuilderError::UnavailableNonce { nonce })
}
Err(e) => Err(e.into()),
}
.map_err(MerkleTreeBuilderError::from)
}

pub fn count(&self) -> u32 {
self.prover.count() as u32
}

#[instrument(err, skip(self), level = "debug")]
pub async fn update_to_index(&mut self, index: u32) -> Result<(), MerkleTreeBuilderError> {
if index >= self.count() {
let starting_index = self.prover.count() as u32;
for i in starting_index..=index {
self.db.wait_for_message_nonce(i).await?;
self.ingest_nonce(i)?;
}

let prover_root = self.prover.root();
let incremental_root = self.incremental.root();
if prover_root != incremental_root {
return Err(MerkleTreeBuilderError::MismatchedRoots {
prover_root,
incremental_root,
});
}
pub async fn ingest_message_id(&mut self, message_id: H256) -> Result<()> {
const CTX: &str = "When ingesting message id";
debug!(?message_id, "Ingesting leaf");
self.prover.ingest(message_id).expect("tree full");
self.incremental.ingest(message_id);
match self.prover.root().eq(&self.incremental.root()) {
true => Ok(()),
false => Err(MerkleTreeBuilderError::MismatchedRoots {
prover_root: self.prover.root(),
incremental_root: self.incremental.root(),
}),
}

Ok(())
.context(CTX)
}
}
Loading

0 comments on commit 3208796

Please sign in to comment.