Skip to content

Commit f064cf0

Browse files
authored
zig: Improve transfer-lamports performance with new SDK version (#8)
* transfer-lamports: Upgrade zig dep to faster version * Update deps
1 parent 89efc3b commit f064cf0

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ lets the VM assume it worked.
162162
| Language | CU Usage |
163163
| --- | --- |
164164
| Rust | 464 |
165-
| Zig | 186 |
165+
| Zig | 43 |
166166
| C | 103 |
167167
| Assembly | 22 |
168168

transfer-lamports/zig/build.zig.zon

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,11 @@
1515
// Once all dependencies are fetched, `zig build` no longer requires
1616
// internet connectivity.
1717
.dependencies = .{
18-
.base58 = .{
19-
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.13.3.tar.gz",
20-
.hash = "1220fd067bf167b9062cc29ccf715ff97643c2d3f8958beea863b6036876bb71bcb8",
21-
},
2218
.@"solana-program-sdk" = .{
23-
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.13.1.tar.gz",
24-
.hash = "122030336f1257e3c0aa64243f5243f554b903c6b9ef3a91d48bfbe896c0c7d9b13b",
19+
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.14.0.tar.gz",
20+
.hash = "1220bdfa4ea1ab6330959ce4bc40feb5b39a7f98923a266a94b69e27fd20c3526786",
2521
},
2622
},
27-
28-
// Specifies the set of files and directories that are included in this package.
29-
// Only files and directories listed here are included in the `hash` that
30-
// is computed for this package.
31-
// Paths are relative to the build root. Use the empty string (`""`) to refer to
32-
// the build root itself.
33-
// A directory listed here means that all files within, recursively, are included.
3423
.paths = .{
3524
"build.zig",
3625
"build.zig.zon",

transfer-lamports/zig/main.zig

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ const sol = @import("solana-program-sdk");
22

33
export fn entrypoint(input: [*]u8) u64 {
44
const context = sol.Context.load(input) catch return 1;
5-
const accounts = context.loadRawAccounts(sol.allocator) catch return 1;
6-
defer accounts.deinit();
7-
8-
const source = accounts.items[0];
9-
const destination = accounts.items[1];
5+
const source = context.accounts[0];
6+
const destination = context.accounts[1];
107
source.lamports().* -= 5;
118
destination.lamports().* += 5;
12-
139
return 0;
1410
}

0 commit comments

Comments
 (0)