Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ jobs:

pip install -e ".[dev]"
- restore_cache:
key: test-vectors-e0b55b1fd3d72532b87a53fa6c313c8a09e34164
key: test-vectors-233b764514a3cd35adf986e0b9967946d486c987
- run:
name: Checkout Test Vectors
command: |
if [ ! -d "test-vectors" ]; then
git clone https://github.com/firedancer-io/test-vectors --depth 1
cd test-vectors
git fetch origin e0b55b1fd3d72532b87a53fa6c313c8a09e34164
git checkout e0b55b1fd3d72532b87a53fa6c313c8a09e34164
git fetch origin 233b764514a3cd35adf986e0b9967946d486c987
git checkout 233b764514a3cd35adf986e0b9967946d486c987

# We need each fixture file to have a unique name so that we can put them into the test-inputs directory
# in a "flat" manner. The problem is that there are just too many files and it exceeds ARG_MAX for a single
Expand All @@ -307,7 +307,7 @@ jobs:
find vm_interp/fixtures/v2 -type f -name '*.fix' -print0 | xargs -0 rename "s/\.fix\$/-v2.fix/"
fi
- save_cache:
key: test-vectors-e0b55b1fd3d72532b87a53fa6c313c8a09e34164
key: test-vectors-233b764514a3cd35adf986e0b9967946d486c987
paths:
- test-vectors/
- run:
Expand Down
4 changes: 2 additions & 2 deletions conformance/scripts/download_artifacts.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
set -e

# Specifically this commit of solfuzz-agave: 7e7b4935d66e17b478910b8a1e43b461cbb43f7d
artifact_id=3999155212
# Specifically this commit of solfuzz-agave: cef278ea3216bde6ea7fe760a89217560c2da856
artifact_id=4077531638
artifact_name="libsolfuzz-agave.so"

artifacts_url="https://api.github.com/repos/firedancer-io/solfuzz-agave/actions/artifacts"
Expand Down
3 changes: 2 additions & 1 deletion conformance/src/txn_execute.zig
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,10 @@ fn executeTxnContext(
// .accounts_db = &accounts_db,
// });

// Remove address lookup table and config program accounts by inserting empty accounts (zero-lamports)
// Remove address lookup table, stake, and config program accounts by inserting empty accounts (zero-lamports)
try accounts_db.putAccount(slot, program.address_lookup_table.ID, .EMPTY);
try accounts_db.putAccount(slot, program.config.ID, .EMPTY);
try accounts_db.putAccount(slot, program.stake.ID, .EMPTY);

// Load accounts into accounts db
for (accounts_map.keys(), accounts_map.values()) |pubkey, account| {
Expand Down
2 changes: 1 addition & 1 deletion src/core/features.zon
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
.{ .name = "vote_only_retransmitter_signed_fec_sets", .pubkey = "RfEcA95xnhuwooVAhUUksEJLZBF7xKCLuqrJoqk4Zph" },
.{ .name = "mask_out_rent_epoch_in_vm_serialization", .pubkey = "RENtePQcDLrAbxAsP3k8dwVcnNYQ466hi2uKvALjnXx" },
.{ .name = "disable_zk_elgamal_proof_program", .pubkey = "zkdoVwnSFnSLtGJG7irJPEYUpmb4i7sGMGcnN6T9rnC" },
.{ .name = "reenable_zk_elgamal_proof_program", .pubkey = "zkemPXcuM3G4wpMDZ36Cpw34EjUpvm1nuioiSGbGZPR" },
.{ .name = "reenable_zk_elgamal_proof_program", .pubkey = "zkesAyFB19sTkX8i9ReoKaMNDA4YNTPYJpZKPDt7FMW" },
.{ .name = "formalize_loaded_transaction_data_size", .pubkey = "DeS7sR48ZcFTUmt5FFEVDr1v1bh73aAbZiZq3SYr8Eh8" },
.{ .name = "enable_extend_program_checked", .pubkey = "2oMRZEDWT2tqtYMofhmmfQ8SsjqUFzT6sYXppQDavxwz" },
.{ .name = "require_static_nonce_account", .pubkey = "7VVhpg5oAjAmnmz1zCcSHb2Z9ecZB2FQqpnEwReka9Zm" },
Expand Down
11 changes: 6 additions & 5 deletions src/crypto/bn254/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub const G2 = struct {
// G2 does *not* have prime order, so we need to perform a secondary subgroup membership check.
// https://eprint.iacr.org/2022/348, Sec 3.1.
// [r]P == 0 <==> [x+1]P + ψ([x]P) + ψ²([x]P) = ψ³([2x]P)
const xp: G2 = mulScalar(p, @bitCast(Fp.constants.x));
const xp: G2 = mulScalar(p, Fp.constants.x);

const psi = xp.frob();
const psi2 = xp.frob2();
Expand Down Expand Up @@ -464,16 +464,17 @@ fn dbl(p: anytype) @TypeOf(p) {
///
/// https://encrypt.a41.io/primitives/abstract-algebra/elliptic-curve/scalar-multiplication/double-and-add
/// https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication#Double-and-add
fn mulScalar(a: anytype, scalar: [4]u64) @TypeOf(a) {
fn mulScalar(a: anytype, scalar: u256) @TypeOf(a) {
// TODO: can be further optimized with GLV and wNAF
const leading = @clz(@as(u256, @bitCast(scalar)));
const limbs: [4]u64 = @bitCast(scalar);
const leading = @clz(scalar);
if (leading == 256) return .zero;
var i: u8 = @intCast(256 - 1 - leading);
var r = a;
while (i > 0) {
i -= 1;
r = dbl(r);
if (bit(scalar, i)) r = addMixed(r, a);
if (bit(limbs, i)) r = addMixed(r, a);
}
return r;
}
Expand All @@ -488,7 +489,7 @@ pub fn addSyscall(out: *[64]u8, input: *const [128]u8) !void {
pub fn mulSyscall(out: *[64]u8, input: *const [96]u8) !void {
const a: G1 = try .fromBytes(input[0..64]);
// Scalar is provided in big-endian and we do *not* validate it.
const b: [4]u64 = @bitCast(Fp.byteSwap(input[64..][0..32].*));
const b: u256 = @bitCast(Fp.byteSwap(input[64..][0..32].*));
const result = mulScalar(a, b);
result.toBytes(out);
}
Expand Down
8 changes: 5 additions & 3 deletions src/replay/preprocess_transaction.zig
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ pub fn preprocessTransaction(
};

if (sig_verify == .run_sig_verify) {
txn.verifySignatures(msg_bytes.constSlice()) catch |err| return switch (err) {
error.SignatureVerificationFailed => .{ .err = .SignatureFailure },
else => .{ .err = .SanitizeFailure },
txn.verifySignatures(msg_bytes.constSlice()) catch |err| {
return switch (err) {
error.SignatureVerificationFailed => .{ .err = .SignatureFailure },
else => .{ .err = .SanitizeFailure },
};
};
}

Expand Down
12 changes: 7 additions & 5 deletions src/runtime/program_loader.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ pub fn loadPrograms(
errdefer programs.deinit(allocator);

for (accounts.keys(), accounts.values()) |pubkey, account| {
if (!account.executable) continue;
// https://github.com/firedancer-io/solfuzz-agave/blob/agave-v3.0.3/src/lib.rs#L771-L800
if (!account.owner.equals(&bpf_loader.v1.ID) and
!account.owner.equals(&bpf_loader.v2.ID) and
!account.owner.equals(&bpf_loader.v3.ID) and
!account.owner.equals(&bpf_loader.v4.ID)) continue;

var loaded_program = try loadProgram(
allocator,
Expand Down Expand Up @@ -506,10 +510,8 @@ test "loadPrograms: bad owner" {
loaded_programs.deinit(allocator);
}

switch (loaded_programs.get(program_key).?) {
.failed => {},
.loaded => std.debug.panic("Program should not load!", .{}),
}
if (loaded_programs.get(program_key) != null)
std.debug.panic("Program should not load!", .{});
}
}

Expand Down
Loading