Skip to content

Commit

Permalink
Merge branch 'main' into kunal/relayer-metadata-null
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunal Arora committed Jun 29, 2023
2 parents 60dad87 + aab8f19 commit 38c8f8b
Show file tree
Hide file tree
Showing 90 changed files with 4,818 additions and 822 deletions.
10 changes: 6 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ rust/ @mattiecnvr @tkporter @asaj
## SDK
typescript/sdk @yorhodes @jmrossy

## Token
typescript/token @yorhodes @jmrossy @tkporter

## Hello World
typescript/helloworld @yorhodes @nambrot

## Infra
typescript/infra @tkporter @asaj @mattiecnvr

## Submodules
typescript/token @yorhodes @jmrossy
typescript/helloworld @yorhodes
5 changes: 5 additions & 0 deletions .github/workflows/agent-release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
- name: ubuntu setup
if: ${{ matrix.OS == 'ubuntu-latest' }}
run: |
sudo apt-get update -qq
sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf
# some additional configuration for cross-compilation on linux
Expand Down Expand Up @@ -78,5 +79,9 @@ jobs:
name: ${{ matrix.TARGET }}-${{ needs.prepare.outputs.tag_sha }}-${{ needs.prepare.outputs.tag_date }}
path: |
rust/target/${{ matrix.TARGET }}/release/relayer
rust/target/${{ matrix.TARGET }}/release/relayer.exe
rust/target/${{ matrix.TARGET }}/release/scraper
rust/target/${{ matrix.TARGET }}/release/scraper.exe
rust/target/${{ matrix.TARGET }}/release/validator
rust/target/${{ matrix.TARGET }}/release/validator.exe
if-no-files-found: error
3 changes: 0 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ jobs:
with:
submodules: recursive

- name: remove submodule locks
run: git submodule foreach 'test -f yarn.lock && rm yarn.lock || echo "No yarn.lock file in this submodule"'

- name: setup rust
uses: actions-rs/toolchain@v1
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/monorepo-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ jobs:
with:
submodules: recursive

- name: remove submodule locks
run: git submodule foreach 'test -f yarn.lock && rm yarn.lock || echo "No yarn.lock file in this submodule"'
- name: Generate tag data
id: taggen
run: |
Expand Down
35 changes: 18 additions & 17 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ jobs:
with:
submodules: recursive

- name: remove submodule locks
run: git submodule foreach 'test -f yarn.lock && rm yarn.lock || echo "No yarn.lock file in this submodule"'

- name: yarn-cache
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -48,10 +45,7 @@ jobs:
submodules: recursive
- uses: actions/setup-node@v3
with:
node-version: 16

- name: remove submodule locks
run: git submodule foreach 'test -f yarn.lock && rm yarn.lock || echo "No yarn.lock file in this submodule"'
node-version: 18

- name: yarn-cache
uses: actions/cache@v3
Expand Down Expand Up @@ -82,8 +76,8 @@ jobs:
.yarn/cache
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('./yarn.lock') }}

- name: lint-ts
run: yarn lint-ts
- name: lint
run: yarn lint

- name: prettier
run: |
Expand All @@ -109,6 +103,13 @@ jobs:

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

- 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 Down Expand Up @@ -170,9 +171,6 @@ jobs:
- name: Unit tests
run: yarn workspace @hyperlane-xyz/core run test

- name: lint
run: yarn workspace @hyperlane-xyz/core run lint

- name: Run Slither
uses: crytic/slither-action@main
id: slither
Expand All @@ -189,7 +187,6 @@ jobs:
sarif_file: ${{ steps.slither.outputs.sarif }}

coverage-sol:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: [yarn-build]

Expand All @@ -211,8 +208,12 @@ jobs:
- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1

- name: Install dependencies
run: sudo apt-get install lcov

- name: Run tests with coverage
run: yarn workspace @hyperlane-xyz/core run coverage
run: yarn coverage
env:
NODE_OPTIONS: --max_old_space_size=4096

- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
8 changes: 0 additions & 8 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
[submodule "typescript/token"]
path = typescript/token
url = [email protected]:hyperlane-xyz/hyperlane-token.git
branch = main
[submodule "typescript/helloworld"]
path = typescript/helloworld
url = [email protected]:hyperlane-xyz/hyperlane-app-template.git
branch = main
[submodule "solidity/lib/forge-std"]
path = solidity/lib/forge-std
url = https://github.com/foundry-rs/forge-std
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
"private": true,
"scripts": {
"build": "yarn workspaces foreach --verbose --parallel --topological run build",
"build:e2e": "yarn workspaces foreach --verbose --parallel --exclude @hyperlane-xyz/monorepo --exclude @hyperlane-xyz/hyperlane-token --topological run build",
"clean": "yarn workspaces foreach --verbose --parallel run clean",
"sync-submodules": "./scripts/sync-submodules.sh",
"postinstall": "husky install",
"prettier": "yarn workspaces foreach --verbose --parallel run prettier",
"lint-ts": "eslint . --ext .ts",
"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"
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.

54 changes: 49 additions & 5 deletions rust/agents/relayer/src/msg/pending_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,36 @@ impl PendingOperation for PendingMessage {
fn _next_attempt_after(&self) -> Option<Instant> {
self.next_attempt_after
}

#[cfg(test)]
fn set_retries(&mut self, retries: u32) {
self.set_retries(retries);
}
}

impl PendingMessage {
/// Constructor that tries reading the retry count from the HyperlaneDB in order to recompute the `next_attempt_after`.
/// In case of failure, behaves like `Self::new(...)`.
pub fn from_persisted_retries(message: HyperlaneMessage, ctx: Arc<MessageContext>) -> Self {
let mut pm = Self::new(message, ctx);
match pm
.ctx
.origin_db
.retrieve_pending_message_retry_count_by_message_id(&pm.message.id())
{
Ok(Some(num_retries)) => {
let next_attempt_after = PendingMessage::calculate_msg_backoff(num_retries)
.map(|dur| Instant::now() + dur);
pm.num_retries = num_retries;
pm.next_attempt_after = next_attempt_after;
}
r => {
info!(message_id = ?pm.message.id(), result = ?r, "Failed to read retry count from HyperlaneDB for message.")
}
}
pm
}

fn on_reprepare(&mut self) -> PendingOperationResult {
self.inc_attempts();
self.submitted = false;
Expand Down Expand Up @@ -329,21 +356,37 @@ impl PendingMessage {
}

fn reset_attempts(&mut self) {
self.num_retries = 0;
self.set_retries(0);
self.next_attempt_after = None;
self.last_attempted_at = Instant::now();
}

fn inc_attempts(&mut self) {
self.num_retries += 1;
self.set_retries(self.num_retries + 1);
self.last_attempted_at = Instant::now();
self.next_attempt_after = PendingMessage::calculate_msg_backoff(self.num_retries)
.map(|dur| self.last_attempted_at + dur);
}

fn set_retries(&mut self, retries: u32) {
self.num_retries = retries;
self.persist_retries();
}

fn persist_retries(&self) {
if let Err(e) = self
.ctx
.origin_db
.store_pending_message_retry_count_by_message_id(&self.message.id(), &self.num_retries)
{
warn!(message_id = ?self.message.id(), err = %e, "Persisting the `num_retries` failed for message");
}
}

/// Get duration we should wait before re-attempting to deliver a message
/// given the number of retries.
fn calculate_msg_backoff(num_retries: u32) -> Option<Duration> {
/// `pub(crate)` for testing purposes
pub(crate) fn calculate_msg_backoff(num_retries: u32) -> Option<Duration> {
Some(Duration::from_secs(match num_retries {
i if i < 1 => return None,
// wait 10s for the first few attempts; this prevents thrashing
Expand All @@ -359,8 +402,9 @@ impl PendingMessage {

#[derive(Debug)]
pub struct MessageSubmissionMetrics {
last_known_nonce: IntGauge,
messages_processed: IntCounter,
// Fields are public for testing purposes
pub last_known_nonce: IntGauge,
pub messages_processed: IntCounter,
}

impl MessageSubmissionMetrics {
Expand Down
4 changes: 4 additions & 0 deletions rust/agents/relayer/src/msg/pending_operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ pub trait PendingOperation {
/// This is only used for sorting, the functions are responsible for
/// returning `NotReady` if it is too early and matters.
fn _next_attempt_after(&self) -> Option<Instant>;

#[cfg(test)]
/// Set the number of times this operation has been retried.
fn set_retries(&mut self, retries: u32);
}

/// A "dynamic" pending operation implementation which knows about the
Expand Down
Loading

0 comments on commit 38c8f8b

Please sign in to comment.