Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c3a09f5
feat: publish query filtering
Dodecahedr0x Mar 17, 2026
07dce46
fix: rename file
Dodecahedr0x Mar 17, 2026
7c08e53
Merge branch 'master' into dode/private-er-binairy
Dodecahedr0x Mar 17, 2026
469d90c
Merge branch 'master' into dode/private-er-binairy
Dodecahedr0x May 18, 2026
71bd33e
fix: wrong guard
Dodecahedr0x May 18, 2026
40a5f4b
fix: exit with error
Dodecahedr0x May 18, 2026
ac0a4b3
fix: version
Dodecahedr0x May 18, 2026
61940ef
Merge branch 'master' into dode/private-er-binairy
Dodecahedr0x May 18, 2026
d37aef3
Merge branch 'master' into dode/private-er-binairy
Dodecahedr0x May 19, 2026
48d45c3
fix: exit immediately
Dodecahedr0x May 19, 2026
73c8620
feat: handle async failure
Dodecahedr0x May 19, 2026
308242e
Merge branch 'master' into dode/private-er-binairy
Dodecahedr0x May 19, 2026
ac64bd3
Merge branch 'master' into dode/private-er-binairy
GabrielePicco May 19, 2026
ebc329a
Merge branch 'master' into dode/private-er-binairy
Dodecahedr0x May 20, 2026
388da9c
fix: check status
Dodecahedr0x May 21, 2026
bc58bc4
fix: remove sigterm
Dodecahedr0x May 21, 2026
10678ab
fix: await result
Dodecahedr0x May 21, 2026
137ff9e
Merge branch 'master' into dode/private-er-binairy
Dodecahedr0x May 21, 2026
07598b7
Merge branch 'master' into dode/private-er-binairy
Dodecahedr0x May 21, 2026
9d0a016
fix: remove duplicate run
Dodecahedr0x May 21, 2026
12325b4
feat: update version
Dodecahedr0x May 26, 2026
8328e3d
Merge branch 'master' into dode/private-er-binairy
Dodecahedr0x May 26, 2026
7f8b10f
Merge branch 'master' into dode/private-er-binairy
Dodecahedr0x May 27, 2026
6f48855
Merge branch 'master' into dode/private-er-binairy
GabrielePicco May 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/packages/npm-package/getVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ export function getVersions() {

return {
EPHEMERAL_VALIDATOR: pkg.version,
VRF_ORACLE: pkg.optionalDependencies["@magicblock-labs/vrf-oracle-linux-x64"],
RPC_ROUTER: pkg.optionalDependencies["@magicblock-labs/rpc-router-linux-x64"],
QUERY_FILTERING_SERVICE:
pkg.optionalDependencies[
"@magicblock-labs/query-filtering-service-linux-x64"
],
VRF_ORACLE:
pkg.optionalDependencies["@magicblock-labs/vrf-oracle-linux-x64"],
RPC_ROUTER:
pkg.optionalDependencies["@magicblock-labs/rpc-router-linux-x64"],
} as const;
}

export const VERSIONS = getVersions();
export const VERSIONS = getVersions();
7 changes: 6 additions & 1 deletion .github/packages/npm-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"bin": {
"ephemeral-validator": "ephemeralValidator.js",
"mb-test-validator": "mbTestValidator.js",
"query-filtering-service": "queryFilteringService.js",
"rpc-router": "rpcRouter.js",
"vrf-oracle": "vrfOracle.js"
},
Expand All @@ -34,6 +35,10 @@
"@magicblock-labs/ephemeral-validator-darwin-x64": "0.11.1",
"@magicblock-labs/ephemeral-validator-linux-arm64": "0.11.1",
"@magicblock-labs/ephemeral-validator-linux-x64": "0.11.1",
"@magicblock-labs/query-filtering-service-darwin-arm64": "0.1.1",
"@magicblock-labs/query-filtering-service-darwin-x64": "0.1.1",
"@magicblock-labs/query-filtering-service-linux-arm64": "0.1.1",
"@magicblock-labs/query-filtering-service-linux-x64": "0.1.1",
"@magicblock-labs/vrf-oracle-linux-x64": "0.2.3",
"@magicblock-labs/vrf-oracle-linux-arm64": "0.2.3",
"@magicblock-labs/vrf-oracle-darwin-x64": "0.2.3",
Expand All @@ -46,4 +51,4 @@
"publishConfig": {
"access": "public"
}
}
}
128 changes: 128 additions & 0 deletions .github/packages/npm-package/queryFilteringService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/env node
import fs from "fs";
import { spawn, spawnSync } from "child_process";
import path from "path";
import { arch, platform } from "os";
import { VERSIONS } from "./getVersions";

const PACKAGE_VERSION = `query-filtering-service ${VERSIONS.QUERY_FILTERING_SERVICE}`;

function getBinaryVersion(location: string): [string | null, string | null] {
const result = spawnSync(location, ["--version"]);
const error: string | null =
(result.error && result.error.toString()) ||
(result.status !== 0 && `Process exited with code ${result.status}`) ||
(result.stderr.length > 0 && result.stderr.toString().trim()) ||
null;
return [error, result.stdout && result.stdout.toString().trim()];
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

function getExePath(): string {
let os: string = platform();
let extension = "";
if (["win32", "cygwin"].includes(os)) {
os = "windows";
extension = ".exe";
}
const binaryName = `@magicblock-labs/query-filtering-service-${os}-${arch()}/bin/query-filtering-service${extension}`;
Comment thread
Dodecahedr0x marked this conversation as resolved.
try {
return require.resolve(binaryName);
} catch (e) {
throw new Error(
`Couldn't find application binary inside node_modules for ${os}-${arch()}, expected location: ${binaryName}`,
);
}
}

function runWithForwardedExit(child: ReturnType<typeof spawn>): void {
child.on("exit", (code: number | null, signal: NodeJS.Signals | null) => {
if (signal) {
process.kill(process.pid, signal);
return;
}
process.exit(code ?? 1);
});
Comment thread
Dodecahedr0x marked this conversation as resolved.

process.on("SIGINT", () => {
child.kill("SIGINT");
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

function runQueryFilteringService(location: string): Promise<boolean> {
const args = process.argv.slice(2);
const env = {
...process.env,
};
const queryFilteringService = spawn(location, args, {
stdio: "inherit",
env,
});
runWithForwardedExit(queryFilteringService);

return new Promise((resolve) => {
queryFilteringService.once("spawn", () => resolve(true));
queryFilteringService.once("error", (error) => {
console.error("Failed to spawn query-filtering-service:", error.message);
resolve(false);
});
});
}

async function tryPackageQueryFilteringService(): Promise<boolean> {
try {
const resolvedPath = getExePath();
return await runQueryFilteringService(resolvedPath);
} catch (e) {
console.error(
"Failed to run query-filtering-service from package:",
e instanceof Error ? e.message : e,
);
return false;
}
}

async function trySystemQueryFilteringService(): Promise<void> {
const absolutePath = process.env.PATH?.split(path.delimiter)
.filter((dir) => dir !== path.dirname(process.argv[1]))
.find((dir) => {
try {
fs.accessSync(`${dir}/query-filtering-service`, fs.constants.X_OK);
return true;
} catch {
return false;
}
});

if (!absolutePath) {
console.error("Could not find globally installed query-filtering-service.");
process.exit(1);
}

const absoluteBinaryPath = `${absolutePath}/query-filtering-service`;
const [error, binaryVersion] = getBinaryVersion(absoluteBinaryPath);

if (error !== null) {
console.error(`Failed to get version of global binary: ${error}`);
process.exit(1);
}
if (binaryVersion !== PACKAGE_VERSION) {
console.error(
`Globally installed query-filtering-service version is not correct. Expected "${PACKAGE_VERSION}", found "${binaryVersion}".`,
);
process.exit(1);
}

const success = await runQueryFilteringService(absoluteBinaryPath);
if (!success) {
console.error("Failed to spawn query-filtering-service from system PATH.");
process.exit(1);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

async function main(): Promise<void> {
if (!(await tryPackageQueryFilteringService())) {
await trySystemQueryFilteringService();
}
}

void main();
8 changes: 8 additions & 0 deletions .github/version-align.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ echo "Checking latest NPM versions for vrf-oracle and rpc-router..."
# Get latest versions from NPM
vrf_latest=$(npm view @magicblock-labs/vrf-oracle-linux-x64 version 2>/dev/null || echo "")
router_latest=$(npm view @magicblock-labs/rpc-router-linux-x64 version 2>/dev/null || echo "")
query_filtering_service_latest=$(npm view @magicblock-labs/query-filtering-service-linux-x64 version 2>/dev/null || echo "")

if [ -n "$vrf_latest" ]; then
echo "Updating vrf-oracle dependencies to version: $vrf_latest"
Expand All @@ -46,6 +47,13 @@ else
echo "Warning: Could not fetch latest rpc-router version from NPM"
fi

if [ -n "$query_filtering_service_latest" ]; then
echo "Updating query-filtering-service dependencies to version: $query_filtering_service_latest"
jq --arg version "$query_filtering_service_latest" '.optionalDependencies |= with_entries(if (.key | contains("query-filtering-service")) then .value = $version else . end)' packages/npm-package/package.json > temp.json && mv temp.json packages/npm-package/package.json
else
echo "Warning: Could not fetch latest query-filtering-service version from NPM"
fi

# Check if the any changes have been made to the specified files, if running with --check
if [[ "$1" == "--check" ]]; then
files_to_check=(
Expand Down
Loading