-
Notifications
You must be signed in to change notification settings - Fork 0
feat: ephemeral cranks #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Dodecahedr0x
wants to merge
35
commits into
main
Choose a base branch
from
dode/ephemeral-cranks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
fabb0e6
feat: multiple instructions per crank
Dodecahedr0x 924fab4
feat: ephemeral cranks
Dodecahedr0x 47639ad
test: e2e ephemeral
Dodecahedr0x 6c8a777
feat: remove magicsvm tests
Dodecahedr0x 13fa05d
feat: extend SDK
Dodecahedr0x db02270
feat: api expose both programs
Dodecahedr0x f3327a5
fix: make modules public
Dodecahedr0x 01b6c86
feat: move args out of client
Dodecahedr0x 09b3c8e
feat: relax version
Dodecahedr0x e80dba8
feat: split programs
Dodecahedr0x 1f24ace
feat: refund ephemeral cranks
Dodecahedr0x 7355686
test: exact funding
Dodecahedr0x 1250362
style: lint
Dodecahedr0x 139bb39
feat: remove unused lockfile
Dodecahedr0x a70d17a
feat: untrack lockfile
Dodecahedr0x 17e6a01
feat: unsafe mode
Dodecahedr0x dceaa48
fix: writability conflict tracking
Dodecahedr0x 001fb1f
fix: create account when unfunded
Dodecahedr0x 1da5ce5
Merge branch 'dode/multiple-instructions' into dode/ephemeral-cranks
Dodecahedr0x 15a6f76
fix: delegate cranker
Dodecahedr0x 8b4a5db
Merge branch 'main' into dode/ephemeral-cranks
Dodecahedr0x 76cf159
fix: conflicts
Dodecahedr0x cb62015
fix: account meta
Dodecahedr0x 25ab7a8
fix: divergent economics
Dodecahedr0x a3a2269
feat: gate ephemeral close
Dodecahedr0x 307f1fd
fix: remove obsolete error
Dodecahedr0x fd06710
feat: remove incompatible feature
Dodecahedr0x 213513b
fix: anchor example in CI
Dodecahedr0x fbbd432
docs: fix header
Dodecahedr0x bd29172
feat: use body_len
Dodecahedr0x cba4277
fix: client
Dodecahedr0x d5d68a4
feat: add makefile
Dodecahedr0x c3b10f2
fix: increase file limits
Dodecahedr0x 7e38e4a
fix: update validators
Dodecahedr0x 07d584a
feat: clean processes
Dodecahedr0x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| # Cancel superseded runs on the same ref to save runner minutes. | ||
| concurrency: | ||
| group: ci-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| RUSTFLAGS: -D warnings | ||
| # Pinned Solana/Agave toolchain that ships `cargo build-sbf`. | ||
| SOLANA_VERSION: stable | ||
|
|
||
| jobs: | ||
| # --------------------------------------------------------------------------- | ||
| # Formatting — covers all root workspace members, including `tests/e2e`. | ||
| # --------------------------------------------------------------------------- | ||
| fmt: | ||
| name: rustfmt | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust (rustfmt) | ||
| uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: 1.91.1 | ||
| components: rustfmt | ||
|
|
||
| - name: Check formatting | ||
| run: make fmt-check | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Default feature set: lint + tests with the `ephemeral` feature OFF. | ||
| # --------------------------------------------------------------------------- | ||
| default: | ||
| name: lint + test (default) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust (clippy) | ||
| uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: 1.91.1 | ||
| components: clippy,rustfmt | ||
|
|
||
| - name: Install Solana toolchain (build-sbf) | ||
| run: | | ||
| sh -c "$(curl -sSfL https://release.anza.xyz/${SOLANA_VERSION}/install)" | ||
| echo "$HOME/.local/share/solana/install/active_release/bin" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Install cargo-nextest | ||
| uses: taiki-e/install-action@nextest | ||
|
|
||
| - uses: Swatinem/rust-cache@v2 | ||
|
|
||
| - name: Default CI checks | ||
| run: make ci | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Live end-to-end: boots the real three-process stack (mb-test-validator + | ||
| # ephemeral-validator + hydra-cranker) and asserts ephemeral cranks fire on | ||
| # schedule. The validators ship as the `@magicblock-labs/ephemeral-validator` | ||
| # npm package (mb-test-validator wraps `solana-test-validator`, which the Anza | ||
| # toolchain provides). The `tests/e2e` crate is its own `[workspace]`. | ||
| # --------------------------------------------------------------------------- | ||
| e2e: | ||
| name: e2e (ephemeral cranks, live validators) | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| # Pin to the version the test was developed against. | ||
| EPHEMERAL_VALIDATOR_VERSION: 0.13.3 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust (clippy) | ||
| uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: 1.91.1 | ||
| components: clippy | ||
|
|
||
| - name: Install Solana toolchain (build-sbf + solana-test-validator) | ||
| run: | | ||
| sh -c "$(curl -sSfL https://release.anza.xyz/${SOLANA_VERSION}/install)" | ||
| echo "$HOME/.local/share/solana/install/active_release/bin" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Install Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Install MagicBlock validators (mb-test-validator + ephemeral-validator) | ||
| run: | | ||
| npm install -g "@magicblock-labs/ephemeral-validator@${EPHEMERAL_VALIDATOR_VERSION}" | ||
| mb-test-validator --version | ||
| ephemeral-validator --version | ||
|
|
||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| workspaces: | | ||
| . | ||
| tests/e2e | ||
|
|
||
| - name: Clippy — e2e crate | ||
| run: make lint-e2e | ||
|
|
||
| - name: Test — live ephemeral cranks | ||
| run: | | ||
| sudo prlimit --pid $$ --nofile=1048576:1048576 | ||
| sudo sysctl fs.inotify.max_user_instances=1280 | ||
| sudo sysctl fs.inotify.max_user_watches=655360 | ||
| make test-e2e | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| # Hydra — build & test commands. | ||
| # | ||
| # Quickstart: | ||
| # make build # compile the on-chain programs (needed before tests) | ||
| # make test # run the hydra-tests suite | ||
| # make ci # everything the default CI job runs, locally | ||
| # | ||
| # Run `make` or `make help` for the full list. | ||
| # | ||
| # Toolchain prerequisites: | ||
| # - Rust + `cargo build-sbf` (Solana/Anza toolchain) | ||
| # - cargo-nextest -> `make install-tools` | ||
| # - anchor CLI -> only for `make build-examples` | ||
| # - @magicblock-labs/ephemeral-validator (npm) -> only for `make test-e2e` | ||
|
|
||
| SHELL := /bin/bash | ||
| .DEFAULT_GOAL := help | ||
|
|
||
| # Manifests for the crates that live outside the default workspace build. | ||
| BASE_MANIFEST := programs/hydra/Cargo.toml | ||
| EPHEMERAL_MANIFEST := programs/hydra-ephemeral/Cargo.toml | ||
| NOOP_MANIFEST := tests/programs/noop/Cargo.toml | ||
| NATIVE_MANIFEST := examples/native/Cargo.toml | ||
| PINOCCHIO_MANIFEST := examples/pinocchio/Cargo.toml | ||
| ANCHOR_MANIFEST := examples/anchor/Cargo.toml | ||
| E2E_MANIFEST := tests/e2e/Cargo.toml | ||
|
|
||
| CLIPPY := --all-targets -- -D warnings | ||
|
|
||
| .PHONY: help | ||
| help: ## Show this help | ||
| @grep -hE '^[a-zA-Z0-9_-]+:.*?## ' $(MAKEFILE_LIST) \ | ||
| | awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-16s\033[0m %s\n", $$1, $$2}' | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Build — on-chain SBF programs (artifacts land in target/deploy/*.so). | ||
| # --------------------------------------------------------------------------- | ||
| .PHONY: build build-base build-ephemeral build-noop build-examples | ||
|
|
||
| build: build-base build-ephemeral ## build-sbf the base + ephemeral hydra programs | ||
|
|
||
| build-base: build-noop ## build-sbf the base hydra program | ||
| cargo build-sbf --manifest-path $(BASE_MANIFEST) | ||
|
|
||
| build-ephemeral: build-noop ## build-sbf the ephemeral-rollup hydra program | ||
| cargo build-sbf --manifest-path $(EPHEMERAL_MANIFEST) | ||
|
|
||
| build-noop: ## build-sbf the noop test program (target of scheduled ixs) | ||
| cargo build-sbf --manifest-path $(NOOP_MANIFEST) | ||
|
|
||
| build-examples: ## build-sbf the native + pinocchio example programs | ||
| cargo build-sbf --manifest-path $(NATIVE_MANIFEST) | ||
| cargo build-sbf --manifest-path $(PINOCCHIO_MANIFEST) | ||
| cd examples/anchor && anchor build | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Format & lint (mirrors the fmt + default CI jobs). | ||
| # --------------------------------------------------------------------------- | ||
| .PHONY: fmt fmt-check lint lint-e2e lint-ephemeral | ||
|
|
||
| fmt: ## Format the workspace | ||
| cargo fmt --all | ||
|
|
||
| fmt-check: ## Check formatting without writing (CI) | ||
| cargo fmt --all --check | ||
|
|
||
| lint: ## Clippy the workspace and check the excluded anchor example | ||
| cargo clippy --workspace $(CLIPPY) | ||
| cargo check --manifest-path $(ANCHOR_MANIFEST) --all-targets | ||
|
|
||
| lint-e2e: ## Clippy only the e2e crate | ||
| cargo clippy --manifest-path $(E2E_MANIFEST) $(CLIPPY) | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Test. `hydra-tests` and the example mollusk tests load the compiled .so | ||
| # files at runtime, so the build targets are prerequisites. | ||
| # --------------------------------------------------------------------------- | ||
| .PHONY: test test-examples test-e2e test-all bench cu-table | ||
|
|
||
| test: build-base ## Run the hydra-tests suite (unit + integration, via nextest) | ||
| cargo nextest run -p hydra-tests | ||
|
|
||
| test-examples: build-base build-examples ## Run the native + pinocchio example mollusk tests | ||
| cargo nextest run -p hydra-example-native -p hydra-example-pinocchio | ||
|
|
||
| test-e2e: build-ephemeral build-noop ## Live e2e: spawns validators + cranker (needs the ephemeral-validator npm pkg) | ||
| cargo test --manifest-path $(E2E_MANIFEST) -- --ignored --nocapture --test-threads=1 | ||
|
|
||
| test-all: test test-examples test-e2e ## Run hydra-tests, examples, and live e2e | ||
|
|
||
| bench: build-base ## Run the compute-unit benchmarks | ||
| cargo bench -p hydra-tests | ||
|
|
||
| cu-table: build-base ## Print the per-instruction CU table (the ignored cu_table test) | ||
| cargo test -p hydra-tests cu_table -- --ignored --nocapture | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Aggregate / housekeeping. | ||
| # --------------------------------------------------------------------------- | ||
| .PHONY: ci install-tools clean | ||
|
|
||
| ci: fmt-check lint build test ## Run the default CI job locally (fmt-check + lint + build + test) | ||
|
|
||
| install-tools: ## Install cargo-nextest (Solana/anchor/node toolchains are installed separately) | ||
| cargo install cargo-nextest --locked | ||
|
|
||
| clean: ## Remove Cargo build artifacts | ||
| cargo clean |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🔵 Trivial | ⚖️ Poor tradeoff
Consider pinning third-party actions to commit SHAs.
actions/checkout@v4,dtolnay/rust-toolchain@master,taiki-e/install-action@nextest,Swatinem/rust-cache@v2, andactions/setup-node@v4are all tag/branch refs, which are mutable. Pinning to a commit SHA hardens against supply-chain tampering, at the cost of manual bumps (particularly painful for@master).🧰 Tools
🪛 zizmor (1.26.1)
[warning] 27-27: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 45-45: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 80-80: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 41-72: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
[error] 27-27: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[error] 30-30: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[error] 45-45: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[error] 48-48: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[error] 59-59: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[error] 61-61: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[error] 80-80: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[error] 83-83: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[error] 94-94: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[error] 104-104: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
[info] 30-30: action functionality is already included by the runner (superfluous-actions): use
rustupand/orcargoin a script step(superfluous-actions)
[info] 48-48: action functionality is already included by the runner (superfluous-actions): use
rustupand/orcargoin a script step(superfluous-actions)
[info] 83-83: action functionality is already included by the runner (superfluous-actions): use
rustupand/orcargoin a script step(superfluous-actions)
[warning] 100-100: ad-hoc installation of packages (adhoc-packages): installs a package outside of a lockfile
(adhoc-packages)
🤖 Prompt for AI Agents
Source: Linters/SAST tools