-
Notifications
You must be signed in to change notification settings - Fork 38
feat: Add support for Midnight network #257
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
shahnami
wants to merge
15
commits into
main
Choose a base branch
from
plat-6527-midnight-support
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
15 commits
Select commit
Hold shift + click to select a range
6ae45f1
chore: Add midnight to supported networks
shahnami 242c338
chore: Merge from main
shahnami 7a8165a
feat: Add models and configuration parsing (#258)
shahnami ca267d7
chore: Resolve merge conflicts with main
shahnami ef68b44
fix: Yamlfix
shahnami 366284f
test: Fix midnight tests
shahnami c8f4536
test: Add tests for Midnight (#354)
shahnami 885087e
docs: Add midnight docs (#357)
shahnami 0a799fb
chore: Use --example flag for fixtures
shahnami 596861a
chore: Pull from main
shahnami 97eb3a4
Update config/config.example.json
shahnami 6d20927
docs: Add docker example
shahnami adc0fbf
fix: Add status reason
shahnami 5c52c94
fix: Cargo
shahnami e91a8f3
chore: Apply review suggestions
shahnami 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,93 @@ | ||
# Base image | ||
FROM --platform=${BUILDPLATFORM} cgr.dev/chainguard/rust:latest-dev@sha256:faf49718aaa95c798ed1dfdf3e4edee2cdbc3790c8994705ca6ef35972128459 AS base | ||
|
||
USER root | ||
RUN apk update && apk --no-cache add \ | ||
openssl-dev \ | ||
perl \ | ||
libsodium-dev \ | ||
git \ | ||
curl | ||
|
||
ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig | ||
|
||
WORKDIR /usr/app | ||
|
||
# Configure git to use credentials for private repos | ||
# TEMPORARY: GitHub credentials are only required until Midnight repositories are open-sourced | ||
# Once the repos are public, this authentication step can be removed entirely | ||
# Credentials are provided via Docker secrets for security (not exposed in logs) | ||
RUN --mount=type=secret,id=github_user,mode=0400 \ | ||
--mount=type=secret,id=github_pat,mode=0400 \ | ||
if [ ! -f /run/secrets/github_user ] || [ ! -f /run/secrets/github_pat ]; then \ | ||
echo "ERROR: GitHub credentials must be provided as Docker secrets" && \ | ||
echo "Please ensure GITHUB_USER and GITHUB_PAT are set in your .env file" && \ | ||
echo "Note: This is temporary until Midnight repositories are open-sourced" && \ | ||
exit 1; \ | ||
fi && \ | ||
GITHUB_USER=$(cat /run/secrets/github_user) && \ | ||
GITHUB_PAT=$(cat /run/secrets/github_pat) && \ | ||
echo "Configuring git for user: ${GITHUB_USER}" && \ | ||
echo "Note: GitHub authentication is temporary until Midnight repos are public" && \ | ||
mkdir -p /root/.cargo && \ | ||
echo '[net]' >> /root/.cargo/config.toml && \ | ||
echo 'git-fetch-with-cli = true' >> /root/.cargo/config.toml && \ | ||
git config --global url."https://${GITHUB_USER}:${GITHUB_PAT}@github.com/".insteadOf "https://github.com/" && \ | ||
echo "Git config set. Testing access..." && \ | ||
git ls-remote https://github.com/midnightntwrk/midnight-ledger-prototype > /dev/null 2>&1 && echo "✓ Git access successful" || echo "✗ Git access failed" | ||
|
||
# Copy source | ||
COPY . . | ||
|
||
# Build | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=/usr/app/target \ | ||
--mount=type=secret,id=github_user,mode=0400 \ | ||
--mount=type=secret,id=github_pat,mode=0400 \ | ||
GITHUB_USER=$(cat /run/secrets/github_user) && \ | ||
GITHUB_PAT=$(cat /run/secrets/github_pat) && \ | ||
cargo build --release && \ | ||
cargo install --root /usr/app --path . --debug && \ | ||
git config --global --unset-all url."https://${GITHUB_USER}:${GITHUB_PAT}@github.com/".insteadOf && \ | ||
echo "Git credentials cleared" | ||
|
||
# Setting up build directories | ||
FROM --platform=${BUILDPLATFORM} cgr.dev/chainguard/wolfi-base | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=base --chown=nonroot:nonroot /usr/app/bin/openzeppelin-relayer /app/openzeppelin-relayer | ||
|
||
# Install plugin dependencies | ||
ARG TARGETARCH | ||
ARG NODE_VERSION=20.19 | ||
|
||
# Install Node.js | ||
USER root | ||
RUN apk add --no-cache nodejs=~${NODE_VERSION} npm | ||
|
||
ENV PATH="/usr/local/bin:$PATH" | ||
|
||
# Install pnpm and ts-node | ||
RUN npm install -g pnpm ts-node typescript | ||
|
||
# removes apk and unneeded wolfi-base tools. | ||
RUN apk del wolfi-base apk-tools | ||
|
||
# Copy plugins folder and install dependencies | ||
COPY --chown=nonroot:nonroot ./plugins /app/plugins | ||
|
||
USER nonroot | ||
WORKDIR /app/plugins | ||
RUN pnpm install --frozen-lockfile | ||
|
||
# Return to app root | ||
WORKDIR /app | ||
|
||
ENV APP_PORT=8080 | ||
ENV METRICS_PORT=8081 | ||
|
||
EXPOSE ${APP_PORT}/tcp ${METRICS_PORT}/tcp | ||
|
||
# starting up | ||
ENTRYPOINT ["/app/openzeppelin-relayer"] |
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,19 @@ | ||
{ | ||
"networks": [ | ||
{ | ||
"type": "midnight", | ||
"network": "testnet", | ||
"rpc_urls": ["wss://rpc.testnet-02.midnight.network/"], | ||
"explorer_urls": [ | ||
"https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.testnet-02.midnight.network#/explorer" | ||
], | ||
"indexer_urls": { | ||
"ws": "wss://indexer.testnet-02.midnight.network/api/v1/graphql/ws", | ||
"http": "https://indexer.testnet-02.midnight.network/api/v1/graphql" | ||
}, | ||
"prover_url": "http://localhost:6300", | ||
"average_blocktime_ms": 6000, | ||
"is_testnet": true | ||
} | ||
] | ||
} |
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
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.
Uh oh!
There was an error while loading. Please reload this page.