|
| 1 | +#!/usr/bin/env zx |
| 2 | + |
| 3 | +// Firedancer conformance testing of the Core BPF Config program against its |
| 4 | +// original builtin implementation. |
| 5 | +// |
| 6 | +// Note: This script can only be run on Ubuntu. |
| 7 | + |
| 8 | +import 'zx/globals'; |
| 9 | +import { getProgramId, getProgramSharedObjectPath, workingDirectory } from '../utils.mjs'; |
| 10 | + |
| 11 | +// Clone the conformance harness. |
| 12 | +const harnessPath = path.join(workingDirectory, 'solana-conformance'); |
| 13 | +await $`git clone https://github.com/firedancer-io/solana-conformance.git`; |
| 14 | + |
| 15 | +// Clone the test vectors. |
| 16 | +const testVectorsPath = path.join(harnessPath, 'impl', 'test-vectors'); |
| 17 | +await $`git clone https://github.com/firedancer-io/test-vectors.git ${testVectorsPath}`; |
| 18 | + |
| 19 | +// Remove the fixtures we want to skip. |
| 20 | +const fixturesPath = path.join(testVectorsPath, 'instr', 'fixtures', 'config'); |
| 21 | +const skipFixtures = [ |
| 22 | + // These fixtures provide executable config accounts, which we know is a |
| 23 | + // case that can't manifest under the Solana protocol. |
| 24 | + '04a0b782cb1f4b1be044313331edda9dfb4696d6.fix', |
| 25 | + 'c7ec10c03d5faadcebd32dc5b9a4086abef892ca_3157979.fix', |
| 26 | + '68e8dbf0f31de69a2bd1d2c0fe9af3ba676301d6_3157979.fix', |
| 27 | + 'f84b5ad44f7a253ebc8056d06396694370a7fa4c_3157979.fix', |
| 28 | + '8bbe900444c675cfc3fbf0f80ae2eb061e536a09.fix', |
| 29 | +]; |
| 30 | +for (const fixture of skipFixtures) { |
| 31 | + await $`rm -f ${path.join(fixturesPath, fixture)}`; |
| 32 | +} |
| 33 | + |
| 34 | +// Clone the SolFuzz-Agave harness. |
| 35 | +const solFuzzAgavePath = path.join(harnessPath, 'impl', 'solfuzz-agave'); |
| 36 | +await $`git clone -b agave-v2.1.0 http://github.com/firedancer-io/solfuzz-agave.git ${solFuzzAgavePath}`; |
| 37 | + |
| 38 | +// Fetch protobuf files. |
| 39 | +await $`make -j -C ${solFuzzAgavePath} fetch_proto` |
| 40 | + |
| 41 | +// Move into the conformance harness. |
| 42 | +cd(harnessPath); |
| 43 | + |
| 44 | +// Build the environment. |
| 45 | +await $`bash install_ubuntu_lite.sh`; |
| 46 | + |
| 47 | +const solFuzzAgaveManifestPath = path.join(solFuzzAgavePath, 'Cargo.toml'); |
| 48 | +const solFuzzAgaveTargetPath = path.join( |
| 49 | + solFuzzAgavePath, |
| 50 | + 'target', |
| 51 | + 'x86_64-unknown-linux-gnu', |
| 52 | + 'release', |
| 53 | + 'libsolfuzz_agave.so', |
| 54 | +); |
| 55 | + |
| 56 | +const testTargetsDir = path.join(harnessPath, 'impl', 'lib'); |
| 57 | +await $`mkdir -p ${testTargetsDir}`; |
| 58 | + |
| 59 | +// Build the Agave target with the builtin version. |
| 60 | +const testTargetPathBuiltin = path.join(testTargetsDir, 'builtin.so'); |
| 61 | +await $`cargo build --manifest-path ${solFuzzAgaveManifestPath} \ |
| 62 | + --lib --release --target x86_64-unknown-linux-gnu`; |
| 63 | +await $`mv ${solFuzzAgaveTargetPath} ${testTargetPathBuiltin}`; |
| 64 | + |
| 65 | +// Build the Agave target with the BPF version. |
| 66 | +const testTargetPathCoreBpf = path.join(testTargetsDir, 'core_bpf.so'); |
| 67 | +await $`CORE_BPF_PROGRAM_ID=${getProgramId('program')} \ |
| 68 | + CORE_BPF_TARGET=${getProgramSharedObjectPath('program')} \ |
| 69 | + FORCE_RECOMPILE=true \ |
| 70 | + cargo build --manifest-path ${solFuzzAgaveManifestPath} \ |
| 71 | + --lib --release --target x86_64-unknown-linux-gnu --features core-bpf`; |
| 72 | +await $`mv ${solFuzzAgaveTargetPath} ${testTargetPathCoreBpf}`; |
| 73 | + |
| 74 | +// Run the tests. |
| 75 | +await $`source test_suite_env/bin/activate && \ |
| 76 | + solana-test-suite run-tests \ |
| 77 | + -i ${fixturesPath} -s ${testTargetPathBuiltin} -t ${testTargetPathCoreBpf}`; |
| 78 | + |
| 79 | +// Assert conformance. |
| 80 | +// There should be no fixtures in the `failed_protobufs` directory. |
| 81 | +if (fs.readdirSync('test_results/failed_protobufs').length > 0) { |
| 82 | + throw new Error(`Error: mismatches detected.`); |
| 83 | +} else { |
| 84 | + console.log('All tests passed.'); |
| 85 | +} |
0 commit comments