Skip to content

Commit

Permalink
feat(rpc): Implement WASM Client (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
distractedm1nd authored Jun 14, 2024
1 parent a20665f commit 163cefb
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 21 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: CI

on:
push:
branches:
Expand Down Expand Up @@ -130,6 +129,20 @@ jobs:
version: "23.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown

- name: Install wasm-pack
uses: taiki-e/cache-cargo-install-action@v1
with:
tool: [email protected]

- name: Install chromedriver # we don't specify chrome version to match whatever's installed
uses: nanasess/setup-chromedriver@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand All @@ -152,6 +165,11 @@ jobs:
"cache-from": ["type=gha,scope=bridge-0"],
"cache-to": ["type=gha,mode=max,scope=bridge-0"],
"output": ["type=docker"]
},
"bridge-1": {
"cache-from": ["type=gha,scope=bridge-1"],
"cache-to": ["type=gha,mode=max,scope=bridge-1"],
"output": ["type=docker"]
}
}
}
Expand All @@ -172,6 +190,10 @@ jobs:
- name: Run tests
run: cargo test

- name: Run rpc wasm test
run: wasm-pack test --headless --chrome rpc --features=wasm-bindgen



unused-deps:
runs-on: ubuntu-latest
Expand Down
51 changes: 51 additions & 0 deletions Cargo.lock

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

20 changes: 19 additions & 1 deletion ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
dockerfile: Dockerfile.validator
environment:
# provide amount of bridge nodes to provision (default: 1)
- BRIDGE_COUNT=1
- BRIDGE_COUNT=2
volumes:
- credentials:/credentials
- genesis:/genesis
Expand All @@ -28,6 +28,24 @@ services:
- credentials:/credentials
- genesis:/genesis

bridge-1:
image: bridge
platform: "linux/amd64"
build:
context: .
dockerfile: Dockerfile.bridge
environment:
# provide an id for the bridge node (default: 0)
# each node should have a next natural number starting from 0
- NODE_ID=1
# setting SKIP_AUTH to true disables the use of JWT for authentication
- SKIP_AUTH=true
ports:
- 36658:26658
volumes:
- credentials:/credentials
- genesis:/genesis

# Uncomment for another bridge node
# remember to adjust services.validator.command
# bridge-1:
Expand Down
2 changes: 2 additions & 0 deletions ci/run-bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -euo pipefail

# Name for this node or `bridge-0` if not provided
NODE_ID="${NODE_ID:-0}"
SKIP_AUTH="${SKIP_AUTH:-false}"
NODE_NAME="bridge-$NODE_ID"
# a private local network
P2P_NETWORK="private"
Expand Down Expand Up @@ -67,6 +68,7 @@ main() {
# Start the bridge node
echo "Configuration finished. Running a bridge node..."
celestia bridge start \
--rpc.skip-auth=$SKIP_AUTH \
--rpc.addr 0.0.0.0 \
--core.ip validator \
--keyring.accname "$NODE_NAME" \
Expand Down
9 changes: 6 additions & 3 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ tracing = "0.1.37"
http = "0.2.9"
jsonrpsee = { version = "0.20", features = ["http-client", "ws-client"] }

[dev-dependencies]
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
libp2p = { workspace = true, features = [
"tokio",
"macros",
"tcp",
"noise",
"yamux",
] }

anyhow = "1.0.71"
dotenvy = "0.15.7"
futures = "0.3.28"
Expand All @@ -47,10 +46,14 @@ rand = "0.8.5"
tokio = { version = "1.32.0", features = ["rt", "macros"] }
tracing = "0.1.37"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
getrandom = { version = "0.2", features = ["js"] }
wasm-bindgen-test = "0.3.0"

[features]
default = ["p2p"]
p2p = ["celestia-types/p2p"]
wasm-bindgen = ["celestia-types/wasm-bindgen"]
wasm-bindgen = ["celestia-types/wasm-bindgen", "jsonrpsee/wasm-client"]

[package.metadata.docs.rs]
features = ["p2p"]
Expand Down
Loading

0 comments on commit 163cefb

Please sign in to comment.