Skip to content

Commit

Permalink
Merge branch 'main' into superfluffy/bech32-addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperFluffy committed Jun 4, 2024
2 parents 7615490 + 67dacb7 commit d8346b8
Show file tree
Hide file tree
Showing 97 changed files with 3,417 additions and 690 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,37 @@ jobs:
- name: Run tests
timeout-minutes: 20
run: |
cargo nextest run --archive-file=archive.tar.zst -- --include-ignored
cargo nextest run --archive-file=archive.tar.zst
rust-ethereum:
runs-on: buildjet-8vcpu-ubuntu-2204
needs: run_checker
if: needs.run_checker.outputs.run_tests == 'true'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.76.0
- uses: Swatinem/rust-cache@v2.7.3
with:
cache-provider: "buildjet"
- name: Install nextest
uses: taiki-e/install-action@nextest
- uses: arduino/setup-protoc@v3
with:
version: "24.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install python and solc
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Run tests
timeout-minutes: 20
run: |
pip install solc-select
solc-select install 0.8.21
solc-select use 0.8.21
cargo nextest run --package astria-bridge-withdrawer -- --include-ignored
doctest:
runs-on: buildjet-8vcpu-ubuntu-2204
Expand Down Expand Up @@ -153,7 +183,7 @@ jobs:
- name: run pedantic clippy on workspace crates
run: |
cargo clippy --all-targets --all-features \
-- --warn clippy::pedantic --deny warnings
-- --warn clippy::pedantic --warn clippy::arithmetic-side-effects --deny warnings
- name: run pedantic clippy on tools/protobuf-compiler
run: |
cargo clippy --manifest-path tools/protobuf-compiler/Cargo.toml \
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "crates/astria-bridge-withdrawer/ethereum/lib/forge-std"]
path = crates/astria-bridge-withdrawer/ethereum/lib/forge-std
url = https://github.com/foundry-rs/forge-std
34 changes: 34 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
exclude = ["tools/protobuf-compiler"]

members = [
"crates/astria-bridge-withdrawer",
"crates/astria-build-info",
"crates/astria-cli",
"crates/astria-composer",
Expand All @@ -24,6 +25,7 @@ members = [
# Specify default members so that cargo invocations in github actions will
# not act on lints
default-members = [
"crates/astria-bridge-withdrawer",
"crates/astria-build-info",
"crates/astria-cli",
"crates/astria-composer",
Expand Down Expand Up @@ -67,6 +69,7 @@ itertools = "0.12.1"
itoa = "1.0.10"
jsonrpsee = { version = "0.20" }
once_cell = "1.17.1"
pin-project-lite = "0.2.13"
sha2 = "0.10"
serde = "1"
serde_json = "1"
Expand Down
2 changes: 1 addition & 1 deletion charts/evm-rollup/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.18.4
version: 0.18.6

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
2 changes: 1 addition & 1 deletion charts/sequencer-relayer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.8.1
version: 0.8.3

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 2 additions & 2 deletions charts/sequencer-relayer/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{- if and .Values.serviceMonitor.enabled .Values.config.sequencer.metrics.enabled }}
{{- if and .Values.serviceMonitor.enabled .Values.config.relayer.metrics.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: sequencer-relayer-metrics
labels:
{{- include "sequencer.labels" . | nindent 4 }}
app: sequencer-relayer
{{- with .Values.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
6 changes: 3 additions & 3 deletions charts/sequencer/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: sequencer-relayer
repository: file://../sequencer-relayer
version: 0.8.1
digest: sha256:aea57e7ee44fd5bf1c851792b6a540a222d76a91518948f2b609966a65f694c4
generated: "2024-05-24T10:23:31.097578-07:00"
version: 0.8.3
digest: sha256:5299fcd71b8cac0aa3929a00830fa682d04d239700664a644b3010980704e867
generated: "2024-05-28T13:16:38.413956-07:00"
4 changes: 2 additions & 2 deletions charts/sequencer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.15.1
version: 0.15.3

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand All @@ -25,7 +25,7 @@ appVersion: "0.13.0"

dependencies:
- name: sequencer-relayer
version: "0.8.1"
version: "0.8.3"
repository: "file://../sequencer-relayer"
condition: sequencer-relayer.enabled

Expand Down
55 changes: 55 additions & 0 deletions crates/astria-bridge-withdrawer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[package]
name = "astria-bridge-withdrawer"
version = "0.1.0"
edition = "2021"
rust-version = "1.73"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/astriaorg/astria"
homepage = "https://astria.org"

[[bin]]
name = "astria-bridge-withdrawer"

[dependencies]
http = "0.2.9"

axum = { workspace = true }
futures = { workspace = true }
hex = { workspace = true }
ethers = { workspace = true, features = ["ethers-solc", "ws"] }
hyper = { workspace = true }
humantime = { workspace = true }
ibc-types = { workspace = true }
metrics = { workspace = true }
pin-project-lite = { workspace = true }
prost = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
sha2 = { workspace = true }
tendermint = { workspace = true }
tracing = { workspace = true }
tryhard = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "signal"] }
tokio-util = { workspace = true }

astria-build-info = { path = "../astria-build-info", features = ["runtime"] }
astria-core = { path = "../astria-core", features = ["serde", "server"] }
astria-eyre = { path = "../astria-eyre" }
config = { package = "astria-config", path = "../astria-config" }
sequencer-client = { package = "astria-sequencer-client", path = "../astria-sequencer-client", features = [
"http",
] }
telemetry = { package = "astria-telemetry", path = "../astria-telemetry", features = [
"display",
] }

[dev-dependencies]
astria-core = { path = "../astria-core", features = ["server", "test-utils"] }
astria-grpc-mock = { path = "../astria-grpc-mock" }
config = { package = "astria-config", path = "../astria-config", features = [
"tests",
] }

[build-dependencies]
astria-build-info = { path = "../astria-build-info", features = ["build"] }
4 changes: 4 additions & 0 deletions crates/astria-bridge-withdrawer/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
astria_build_info::emit("bridge-withdrawer-v")?;
Ok(())
}
14 changes: 14 additions & 0 deletions crates/astria-bridge-withdrawer/ethereum/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
38 changes: 38 additions & 0 deletions crates/astria-bridge-withdrawer/ethereum/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# astria-bridge-withdrawer

Forge project for the bridge withdrawer contract.

Requirements:

- foundry

Build:

```sh
forge build
```

Copy the example .env: `cp local.example.env .env`

Put your private key in `.env` and `source .env`.

Deploy `AstriaWithdrawer.sol`:

```sh
forge script script/AstriaWithdrawer.s.sol:AstriaWithdrawerScript \
--rpc-url $RPC_URL --broadcast --sig "deploy()" -vvvv
```

Call `withdrawToSequencer` in `AstriaWithdrawer.sol`:

```sh
forge script script/AstriaWithdrawer.s.sol:AstriaWithdrawerScript \
--rpc-url $RPC_URL --broadcast --sig "withdrawToSequencer()" -vvvv
```

Call `withdrawToOriginChain` in `AstriaWithdrawer.sol`:

```sh
forge script script/AstriaWithdrawer.s.sol:AstriaWithdrawerScript \
--rpc-url $RPC_URL --broadcast --sig "withdrawToOriginChain()" -vvvv
```
6 changes: 6 additions & 0 deletions crates/astria-bridge-withdrawer/ethereum/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[profile.default]
src = "src"
out = "out"
libs = ["lib"]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 1 addition & 0 deletions crates/astria-bridge-withdrawer/ethereum/lib/forge-std
Submodule forge-std added at 978ac6
20 changes: 20 additions & 0 deletions crates/astria-bridge-withdrawer/ethereum/local.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# private key to submit txs with
PRIVATE_KEY=0x

# default local rpc url
RPC_URL="http://localhost:8545"

# divide withdrawn values by 10^ASSET_WITHDRAWAL_DECIMALS
ASSET_WITHDRAWAL_DECIMALS=12

# contract address
ASTRIA_WITHDRAWER=0x5FbDB2315678afecb367f032d93F642f64180aa3

# destination chain address to withdraw to on the sequencer
SEQUENCER_DESTINATION_CHAIN_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

# destination chain address to withdraw to on the origin chain
ORIGIN_DESTINATION_CHAIN_ADDRESS="astring"

# amount to withdraw
AMOUNT=1000000000

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console} from "forge-std/Script.sol";
import {AstriaWithdrawer} from "../src/AstriaWithdrawer.sol";

contract AstriaWithdrawerScript is Script {
function setUp() public {}

function deploy() public {
uint32 assetWithdrawalDecimals = uint32(vm.envUint("ASSET_WITHDRAWAL_DECIMALS"));
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
AstriaWithdrawer astriaWithdrawer = new AstriaWithdrawer(assetWithdrawalDecimals);
console.logAddress(address(astriaWithdrawer));
vm.stopBroadcast();
}

function withdrawToSequencer() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

address contractAddress = vm.envAddress("ASTRIA_WITHDRAWER");
AstriaWithdrawer astriaWithdrawer = AstriaWithdrawer(contractAddress);

address destinationChainAddress = vm.envAddress("SEQUENCER_DESTINATION_CHAIN_ADDRESS");
uint256 amount = vm.envUint("AMOUNT");
astriaWithdrawer.withdrawToSequencer{value: amount}(destinationChainAddress);

vm.stopBroadcast();
}

function withdrawToOriginChain() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

address contractAddress = vm.envAddress("ASTRIA_WITHDRAWER");
AstriaWithdrawer astriaWithdrawer = AstriaWithdrawer(contractAddress);

string memory destinationChainAddress = vm.envString("ORIGIN_DESTINATION_CHAIN_ADDRESS");
uint256 amount = vm.envUint("AMOUNT");
astriaWithdrawer.withdrawToOriginChain{value: amount}(destinationChainAddress, "");

vm.stopBroadcast();
}
}
Loading

0 comments on commit d8346b8

Please sign in to comment.