Skip to content

Commit 03f892f

Browse files
committed
Merge branch 'main' into http_outcall_fix
2 parents 26a1373 + 86314ae commit 03f892f

26 files changed

Lines changed: 510 additions & 86 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Block Extractor Workflow
2+
3+
on:
4+
workflow_dispatch: {}
5+
schedule:
6+
- cron: '*/10 * * * *' # every 10 minutes
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
RUST_LOG: info
14+
GCP_BLOCK_EXTRACTOR_SA_KEY: ${{ secrets.GCP_BLOCK_EXTRACTOR_SA_KEY }}
15+
16+
jobs:
17+
backup-blocks:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
database: [postgres, bigquery] # This matrix is used to run the workflow for both postgres and bigquery
22+
network: [mainnet, testnet] # This matrix is used to run the workflow for both mainnet and testnet
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v2
27+
28+
- name: Compile evm-block-extractor
29+
run: cargo build --release -p evm-block-extractor --bin evm-block-extractor
30+
31+
- name: Move binary to root
32+
run: mv target/release/evm-block-extractor evm-block-extractor
33+
34+
- name: Make binary executable
35+
run: chmod +x evm-block-extractor
36+
37+
- name: Set Up Environment Variables
38+
run: |
39+
if [ "${{ matrix.network }}" = "mainnet" ]; then
40+
echo "RPC_URL=https://mainnet.bitfinity.network" >> $GITHUB_ENV
41+
elif [ "${{ matrix.network }}" = "testnet" ]; then
42+
echo "RPC_URL=https://testnet.bitfinity.network" >> $GITHUB_ENV
43+
fi
44+
45+
# Only run the following steps if the database is BigQuery and the network is mainnet or testnet
46+
- name: Run evm-block-extractor for BigQuery
47+
if: matrix.database == 'bigquery'
48+
run: |
49+
./evm-block-extractor \
50+
--rpc-url ${{ env.RPC_URL }} \
51+
--bigquery \
52+
--project-id ${{ secrets.BIGQUERY_PROJECT_ID }} \
53+
--dataset-id ${{ matrix.network }} \
54+
${{ matrix.network == 'testnet' && '--reset_db_on_state_change' || '' }}
55+
56+
# Only run the following steps if the network is mainnet and the database is postgres
57+
- name: Run evm-block-extractor for Postgres
58+
if: matrix.database == 'postgres' && matrix.network == 'mainnet'
59+
run: |
60+
./evm-block-extractor \
61+
--rpc-url ${{ env.RPC_URL }} \
62+
--postgres \
63+
--username ${{ secrets.POSTGRES_USERNAME }} \
64+
--password ${{ secrets.POSTGRES_PASSWORD }} \
65+
--database-name ${{ secrets.POSTGRES_DATABASE_NAME }} \
66+
--database-url ${{ secrets.POSTGRES_DATABASE_URL }} \
67+
--database-port ${{ secrets.POSTGRES_DATABASE_PORT }}
68+
69+
notify-slack:
70+
runs-on: ubuntu-22.04
71+
needs: [backup-blocks]
72+
if: needs.backup-blocks.result == 'failure'
73+
steps:
74+
- name: Slack Notification
75+
id: slack
76+
uses: slackapi/slack-github-action@v1.17.0
77+
with:
78+
channel-id: 'alerts-block-extractor'
79+
slack-message: 'EVM extractor failed to backup the blocks. Check the CI action here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
80+
81+
env:
82+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/build-test.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,32 @@ on:
1212
paths-ignore:
1313
- '**/README.md'
1414

15-
jobs:
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
1618

19+
jobs:
1720
build-test:
1821
name: Build and Test
1922
runs-on: ubuntu-latest
2023
steps:
2124
- uses: actions/checkout@v4
22-
25+
2326
- name: Install rust toolchain
2427
uses: dtolnay/rust-toolchain@stable
2528
with:
2629
components: clippy, rustfmt
27-
targets: wasm32-unknown-unknown
30+
targets: wasm32-unknown-unknown, i686-unknown-linux-gnu
2831

2932
- name: test
3033
run: |
31-
export RUST_BACKTRACE="full"
3234
cargo install ic-wasm
3335
./scripts/build.sh
3436
./scripts/test.sh
37+
- name: test i686-unknown-linux-gnu
38+
run: |
39+
sudo apt install gcc-multilib
40+
./scripts/test.sh --target i686-unknown-linux-gnu
3541
3642
build-dfx-test:
3743
if: ${{github.ref_type != 'tag'}}

.github/workflows/publish-evm-block-extractor.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,36 @@ concurrency:
1414
jobs:
1515
publishing-image:
1616
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
network: [mainnet, testnet]
1720

1821
steps:
1922
- name: Set up QEMU
20-
uses: docker/setup-qemu-action@v2
23+
uses: docker/setup-qemu-action@v3
2124

2225
- name: Set up Docker Buildx
23-
uses: docker/setup-buildx-action@v2
26+
uses: docker/setup-buildx-action@v3
2427

2528
- name: Login to GCP Registry
26-
uses: docker/login-action@v2
29+
uses: docker/login-action@v3
2730
with:
2831
registry: us-east4-docker.pkg.dev
2932
username: _json_key
3033
password: ${{ secrets.GCP_DOCKER_KEY }}
3134

32-
- uses: actions/checkout@v3
35+
- name: Checkout
36+
uses: actions/checkout@v3
3337

34-
- name: Building CloudRun image
35-
uses: docker/build-push-action@v4
38+
- name: Building CloudRun image for BigQuery
39+
uses: docker/build-push-action@v5
3640
with:
3741
push: true
3842
context: .
3943
file: ./src/evm-block-extractor/Dockerfile
4044
tags: |
41-
us-east4-docker.pkg.dev/bitfinity-evm/evm-block-extractor-repo/evm-block-extractor:latest
45+
us-east4-docker.pkg.dev/extractor-410310/block-extractor-repo/evm-block-extractor-server:${{ matrix.network }}-latest
46+
build-args: |
47+
PROJECT_ID=${{ secrets.BIGQUERY_PROJECT_ID }}
48+
DATASET=${{ matrix.network }}
49+
GCP_BLOCK_EXTRACTOR_SA_KEY=${{ secrets.GCP_BLOCK_EXTRACTOR_SA_KEY }}

Cargo.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ repository = "https://github.com/bitfinity-network/bitfinity-evm-sdk"
2626
version = "0.10.0"
2727

2828
[workspace.dependencies]
29-
alloy-primitives = { version = "0.4", default-feures = false }
29+
alloy-primitives = { version = "0.6", default-feures = false }
3030
anyhow = "1.0"
3131
async-trait = "0.1"
3232
bincode = "1.3"
3333
bytes = "1.3"
3434
candid = "0.9"
3535
clap = { version = "4", features = ["derive", "env"] }
3636
derive_more = "0.99"
37-
env_logger = { version = "0.10.0", default-features = false }
37+
env_logger = { version = "0.11.0", default-features = false }
3838
ethereum-types = "0.14"
3939
ethers-core = "2.0"
4040
futures = { version = "0.3", default-features = false }
@@ -62,9 +62,16 @@ serde_bytes = "0.11"
6262
serde_json = "1.0"
6363
sha2 = "0.10"
6464
sha3 = "0.10"
65-
sqlx = { version = "0.7", default-features = false, features = ["macros", "migrate", "json", "runtime-tokio"] }
65+
sqlx = { version = "0.7", default-features = false, features = [
66+
"macros",
67+
"migrate",
68+
"json",
69+
"runtime-tokio",
70+
] }
6671
tempfile = "3"
67-
testcontainers = { package = "testcontainers-modules", version = "0.3", features = ["postgres"] }
72+
testcontainers = { package = "testcontainers-modules", version = "0.3", features = [
73+
"postgres",
74+
] }
6875
thiserror = "1.0"
6976
tokio = { version = "1.24", features = ["macros", "rt", "signal"] }
7077
wiremock = "0.5"

scripts/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22
set -e
3+
set -x #echo on
4+
35
export RUST_BACKTRACE=full
46
export WASM_DIR=./target/artifact
57

scripts/dfx_deploy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
set -e
3+
set -x #echo on
34

45
export WASM_DIR=./target/artifact
56

scripts/dfx_test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22
set -e
3+
set -x #echo on
4+
35
export RUST_BACKTRACE=full
46

57
test_ic_sign_test_canister() {

scripts/test.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env sh
2-
32
set -e
3+
set -x #echo on
4+
45
export RUST_BACKTRACE=full
56

67
# before testing, the build.sh script should be executed
7-
cargo test
8-
cargo test --all-features
8+
cargo test $@
9+
cargo test $@ --all-features

src/did/src/build.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use candid::CandidType;
2+
use serde::{Deserialize, Serialize};
3+
4+
/// Contains the build data.
5+
#[derive(Debug, Clone, Serialize, Deserialize, CandidType)]
6+
pub struct BuildData {
7+
pub cargo_target_triple: String,
8+
pub cargo_features: String,
9+
pub pkg_name: String,
10+
pub pkg_version: String,
11+
pub rustc_semver: String,
12+
pub build_timestamp: String,
13+
pub cargo_debug: String,
14+
pub git_branch: String,
15+
pub git_sha: String,
16+
pub git_commit_timestamp: String,
17+
}

src/did/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! This module contains submodules for each of the types that we have implemented.
55
66
pub mod block;
7+
pub mod build;
78
pub mod bytes;
89
pub mod codec;
910
pub mod constant;

0 commit comments

Comments
 (0)