Skip to content

Commit

Permalink
GasPriceOracle & Prover (#341)
Browse files Browse the repository at this point in the history
Co-authored-by: ryanmorphl2 <163962984+ryanmorphl2@users.noreply.github.com>
Co-authored-by: vincent <vincent.ch.cn@gmail.com>
  • Loading branch information
3 people authored May 29, 2024
1 parent 2add9e0 commit f7b7db6
Show file tree
Hide file tree
Showing 59 changed files with 11,169 additions and 5,427 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/gas-oracle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Gas-oracle

on:
push:
branches:
- main
paths:
- "gas-oracle/**"
- ".github/workflows/gas-oracle.yaml"
pull_request:
paths:
- "gas-oracle/**"
- ".github/workflows/gas-oracle.yaml"

defaults:
run:
working-directory: "gas-oracle"

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run build
run: make build
- name: Run tests
run: make test
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rust-analyzer.linkedProjects": ["gas-oracle/app/Cargo.toml", "prover/Cargo.toml"]
}
6 changes: 4 additions & 2 deletions gas-oracle/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ GAS_ORACLE_L2_RPC = "http://127.0.0.1:8545/"
GAS_THRESHOLD = 5 # 5%
INTERVAL = 2000 #2s
OVERHEAD_SWITCH = false
MAX_OVERHEAD = 200000
LOG_DIR = "/data/logs/morph-gas-oracle"

OVERHEAD_THRESHOLD = 100 # 100Gas
OVERHEAD_INTERVAL = 10
TXN_PER_BLOCK = 0.5
TXN_PER_BATCH = 50.0
TXN_PER_BLOCK = 1
TXN_PER_BATCH = 50

L1_ROLLUP = "0xC5386CBDa4864aE1F86Ed5840D370855F64Bcd3c"
L2_GAS_PRICE_ORACLE = "0x5FbDB2315678afecb367f032d93F642f64180aa3"
Expand Down
39 changes: 37 additions & 2 deletions gas-oracle/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# Run cargo build with release tag
build:
cd app&&cargo build --release
cd app && cargo build --release

# Generate bin file and run
run:build
./app/target/release/app
./app/target/release/app

# Run the formatter but don't change any files.
fmt:
cd app && cargo +nightly fmt --all -- --check

# Run the formatter and update files with style changes
lint:
cd app && cargo +nightly fmt --all

# Run clippy
clippy:
cd app && cargo +nightly clippy --all-targets -- -D warnings

# Run all tests
test:
cd app && cargo test
.PHONY: test

# Clean the builds
clean:
cd app && cargo clean

# Generate the help message
help:
@echo "usage: make [target]"
@echo ""
@echo "fmt: Run the formatter but don't change any files."
@echo "lint: Run the formatter and update files with style changes"
@echo "clippy: Run clippy"
@echo "test: Run all tests"
@echo "clean: Clean the builds"
@echo "help: Show this help message"
@echo ""
29 changes: 27 additions & 2 deletions gas-oracle/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
# gas oracle

### build
## Development

### Prerequisites

Make sure you have Rust installed. We recommend using [rustup](https://rustup.rs/). On top of the stable version of Rust, you will also need to install the nightly version of Rust, since the nightly version is used for some of the build and test scripts.

```bash
rustup toolchain install nightly
```

### Makefile

The Makefile contains various commands for building, testing, and linting the files. A list of the commands can be found by running `make help`.

### Testing

To run all tests, run `make test`.

### Linting

To run a format check but not actually format the code, run `make fmt`. To run a format check and format the code, run `make lint`. To run a clippy check, run `make clippy`.

### Build

`make build`
### run

### Run

`make run`
Loading

0 comments on commit f7b7db6

Please sign in to comment.