Skip to content

Commit

Permalink
dev: cleaning (#1239)
Browse files Browse the repository at this point in the history
* remove max fee from `to_starknet_transaction`

* remove Error suffix

* rename + add `EthereumBlockStore`

* clean provider

* fix tests

* fix deno CI

* update rust github action

* update CI

* update CI

* comments + adjust hive test timings

* fix naming to `block_hash_or_number`
  • Loading branch information
greged93 authored Jun 26, 2024
1 parent a451b94 commit 80bbd9b
Show file tree
Hide file tree
Showing 20 changed files with 311 additions and 269 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/deno_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
name: deno test

on:
workflow_call:

jobs:
formatting:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v4
with:
sparse-checkout: indexer
- uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x
- name: Run formatting
run: deno fmt --check indexer/

test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
# Checkout target branch and run tests
- name: Run Tests with Coverage on target branch
run: KAKAROT_ADDRESS=0x1 deno test --allow-env --coverage=cov_profile
- name: Generate Coverage Report on target branch
run: deno coverage cov_profile --html
- name: Install bc
run: |
sudo apt-get update
sudo apt-get install -y bc
- name: Extract coverage percentage from HTML for the target branch
run: |
cat cov_profile/html/index.html
coverage_percentage=$(grep -A 3 "<div class='fl pad1y space-right2'>" cov_profile/html/index.html | grep "<span class='strong'>" | awk -F'[<>]' '{gsub("%","",$3); print $3}')
echo $coverage_percentage > curr_coverage_percentage.txt
# Checkout base branch and run tests
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
clean: false
- name: Run Tests with Coverage on base branch
run: KAKAROT_ADDRESS=0x1 deno test --allow-env --coverage=cov_profile_main
- name: Generate HTML report from for the base branch
run: deno coverage cov_profile_main --html
- name: Extract coverage percentage from HTML for the base branch
run: |
coverage_percentage_main=$(grep -A 3 "<div class='fl pad1y space-right2'>" cov_profile_main/html/index.html | grep "<span class='strong'>" | awk -F'[<>]' '{gsub("%","",$3); print $3}')
echo $coverage_percentage_main > coverage_percentage_main.txt
- name: Compare coverage percentage
run: |
previous_coverage=$(awk '{print $2}' coverage_percentage_main.txt)
echo "Previous coverage percentage was $previous_coverage%"
current_coverage=$(awk '{print $2}' curr_coverage_percentage.txt)
echo "Current coverage percentage is $current_coverage%"
change=$(echo "$previous_coverage - $current_coverage" | bc)
echo "Coverage change is $change%"
if (( $(echo "$change > 5.0" | bc -l) )); then
echo "Coverage dropped by more than 5%!"
exit 1
fi
20 changes: 0 additions & 20 deletions .github/workflows/indexer_formatting.yml

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
name: Spell check
uses: ./.github/workflows/spell_check.yml

tests:
rust-tests:
name: Rust tests
uses: ./.github/workflows/test.yml
uses: ./.github/workflows/rust_test.yml

indexer_formatting:
name: Deno formatting
uses: ./.github/workflows/indexer_formatting.yml
deno-tests:
name: Deno tests
uses: ./.github/workflows/deno_test.yml
6 changes: 3 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
name: Spell check
uses: ./.github/workflows/spell_check.yml

indexer_formatting:
name: Deno formatting
uses: ./.github/workflows/indexer_formatting.yml
deno-tests:
name: Deno tests
uses: ./.github/workflows/deno_test.yml
61 changes: 4 additions & 57 deletions .github/workflows/test.yml → .github/workflows/rust_test.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,19 @@
---
name: test
name: rust test

on:
workflow_call:

jobs:
test-deno:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
# Checkout target branch and run tests
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Run Tests with Coverage on target branch
run: KAKAROT_ADDRESS=0x1 deno test --allow-env --coverage=cov_profile
- name: Generate Coverage Report on target branch
run: deno coverage cov_profile --html
- name: Install bc
run: |
sudo apt-get update
sudo apt-get install -y bc
- name: Extract coverage percentage from HTML for the target branch
run: |
cat cov_profile/html/index.html
coverage_percentage=$(grep -A 3 "<div class='fl pad1y space-right2'>" cov_profile/html/index.html | grep "<span class='strong'>" | awk -F'[<>]' '{gsub("%","",$3); print $3}')
echo $coverage_percentage > curr_coverage_percentage.txt
# Checkout base branch and run tests
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
clean: false
- name: Run Tests with Coverage on base branch
run: KAKAROT_ADDRESS=0x1 deno test --allow-env --coverage=cov_profile_main
- name: Generate HTML report from for the base branch
run: deno coverage cov_profile_main --html
- name: Extract coverage percentage from HTML for the base branch
run: |
coverage_percentage_main=$(grep -A 3 "<div class='fl pad1y space-right2'>" cov_profile_main/html/index.html | grep "<span class='strong'>" | awk -F'[<>]' '{gsub("%","",$3); print $3}')
echo $coverage_percentage_main > coverage_percentage_main.txt
- name: Compare coverage percentage
run: |
previous_coverage=$(awk '{print $2}' coverage_percentage_main.txt)
echo "Previous coverage percentage was $previous_coverage%"
current_coverage=$(awk '{print $2}' curr_coverage_percentage.txt)
echo "Current coverage percentage is $current_coverage%"
change=$(echo "$previous_coverage - $current_coverage" | bc)
echo "Coverage change is $change%"
if (( $(echo "$change > 5.0" | bc -l) )); then
echo "Coverage dropped by more than 5%!"
exit 1
fi
test-rust:
test:
runs-on: ubuntu-latest-16-cores
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup rust env
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
components: llvm-tools-preview, rustfmt, clippy
override: true
components: rustfmt, clippy
toolchain: 1.76.0
- name: Retrieve cached dependencies
uses: Swatinem/rust-cache@v2
Expand Down
2 changes: 1 addition & 1 deletion docker/hive/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ ENV ALLOW_NET=""
### Port 8545: https://github.com/ethereum/hive/blob/master/simulators/ethereum/rpc/helper.go#L50
ENV KAKAROT_RPC_URL=0.0.0.0:8545
ENV STARKNET_NETWORK=http://localhost:5050
ENV RUST_LOG=kakarot_rpc=info
ENV RUST_LOG=info
ENV MAX_FELTS_IN_CALLDATA=30000
ENV TRANSACTION_MAX_RETRIES=10
ENV MAX_LOGS=10000
Expand Down
4 changes: 2 additions & 2 deletions docker/hive/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ echo "Launching mongo..."
mongod --bind_ip 0.0.0.0 --noauth &
## DNA
echo "Launching DNA..."
starknet start --rpc=http://localhost:5050 --wait-for-rpc --head-refresh-interval-ms=500 --data=/data &
starknet start --rpc=http://localhost:5050 --wait-for-rpc --head-refresh-interval-ms=300 --data=/data &
# ## Indexer
echo "Launching indexer..."
sink-mongo run /usr/src/app/code/indexer/src/main.ts &

### 3.5. Await the Indexer to be healthy
echo "Waiting for the indexer to start..."
sleep 8
sleep 9

# 4. Start the Kakarot RPC service
echo "Launching Kakarot RPC..."
Expand Down
2 changes: 1 addition & 1 deletion src/bin/hive_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async fn main() -> eyre::Result<()> {

for transaction in body.transactions {
let signer = transaction.recover_signer().ok_or_eyre("failed to recover signer")?;
let starknet_tx = to_starknet_transaction(&transaction, signer, u64::MAX, 0)?;
let starknet_tx = to_starknet_transaction(&transaction, signer, 0)?;

let nonce = match &starknet_tx {
BroadcastedInvokeTransaction::V1(starknet_tx) => starknet_tx.nonce,
Expand Down
Loading

0 comments on commit 80bbd9b

Please sign in to comment.