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
30 changes: 12 additions & 18 deletions conformance/src/elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const ELFLoaderCtx = pb.ELFLoaderCtx;
const ElfLoaderEffects = pb.ELFLoaderEffects;

const svm = sig.vm;
const syscalls = svm.syscalls;
const Elf = svm.Elf;
const Executable = svm.Executable;
const Config = svm.Config;
Expand Down Expand Up @@ -49,26 +48,21 @@ fn executeElfTest(ctx: ELFLoaderCtx, allocator: std.mem.Allocator) !ElfLoaderEff
.calldests = std.ArrayList(u64).init(allocator),
};

const env = svm.Environment{ .config = .{}, .loader = .{} };
const env: svm.Environment = .{
.config = .{},
.loader = .ALL_DISABLED,
};
var loader = env.loader;
defer loader.deinit(allocator);

inline for (.{
.{ "sol_log_", syscalls.log },
.{ "sol_log_64_", syscalls.log64 },
.{ "sol_log_pubkey", syscalls.logPubkey },
.{ "sol_log_compute_units_", syscalls.logComputeUnits },
.{ "sol_memset_", syscalls.memops.memset },
.{ "sol_memcpy_", syscalls.memops.memcpy },
.{ "abort", syscalls.abort },
}) |entry| {
const name, const function = entry;
_ = try loader.registerHashed(
allocator,
name,
function,
);
}
.sol_log_,
.sol_log_64_,
.sol_log_pubkey,
.sol_log_compute_units_,
.sol_memset_,
.sol_memcpy_,
.abort,
}) |syscall| loader.enable(syscall);

const config: Config = .{
.maximum_version = .v0,
Expand Down
3 changes: 1 addition & 2 deletions conformance/src/instruction_execute.zig
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ fn executeInstruction(
}

// Override vm environment in the tc context
vm_environment.* = try sig.vm.Environment.initV1(
allocator,
vm_environment.* = sig.vm.Environment.initV1(
tc.feature_set,
&tc.compute_budget,
tc.slot,
Expand Down
9 changes: 5 additions & 4 deletions conformance/src/txn_execute.zig
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ fn executeTxnContext(
var stakes_cache = try StakesCache.init(allocator);
defer stakes_cache.deinit(allocator);

var vm_environment: vm.Environment = .{};
defer vm_environment.deinit(allocator);
var vm_environment: vm.Environment = .{
.loader = .ALL_DISABLED,
.config = .{},
};

var capitalization: Atomic(u64) = .init(0);

Expand Down Expand Up @@ -353,8 +355,7 @@ fn executeTxnContext(
});
}

vm_environment = try vm.Environment.initV1(
allocator,
vm_environment = vm.Environment.initV1(
&feature_set,
&compute_budget,
slot,
Expand Down
6 changes: 2 additions & 4 deletions conformance/src/utils.zig
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub fn createTransactionContext(
try allocator.create(sig.vm.Environment);
vm_environment.* = sig.vm.Environment{
.config = .{},
.loader = .{},
.loader = .ALL_DISABLED,
};

const program_map = if (environment.program_map) |ptr|
Expand Down Expand Up @@ -146,16 +146,14 @@ pub fn deinitTransactionContext(
tc: TransactionContext,
) void {
allocator.destroy(tc.feature_set);
allocator.destroy(tc.vm_environment);

tc.epoch_stakes.deinit(allocator);
allocator.destroy(tc.epoch_stakes);

tc.sysvar_cache.deinit(allocator);
allocator.destroy(tc.sysvar_cache);

tc.vm_environment.deinit(allocator);
allocator.destroy(tc.vm_environment);

for (tc.program_map.values()) |*v| v.deinit(allocator);
var program_map = tc.program_map.*;
program_map.deinit(allocator);
Expand Down
Loading