Skip to content

Commit

Permalink
Update host function index and recompile all services to align with G…
Browse files Browse the repository at this point in the history
…P-0.5.4
  • Loading branch information
clw8998 committed Jan 10, 2025
1 parent 2d9dbf5 commit 621ca4d
Show file tree
Hide file tree
Showing 20 changed files with 138 additions and 240 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions services/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified services/bootstrap/bootstrap.pvm
Binary file not shown.
12 changes: 6 additions & 6 deletions services/bootstrap/bootstrap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@
34: 33 07 a0 = 0x0
36: 32 00 ret
: @6 [export #2: 'accumulate']
38: 8b 11 f8 i64 sp = i64 sp - i64 8
41: 71 10 u64 [sp] = ra
38: 95 11 f8 sp = sp - 8
41: 7b 10 u64 [sp] = ra
43: 14 07 00 00 ff fe 00 00 00 00 a0 = 0xfeff0000
53: 78 78 20 a1 = u64 [a0 + 32]
53: 82 78 20 a1 = u64 [a0 + 32]
56: 33 09 64 a2 = 0x64
59: 33 0a 64 a3 = 0x64
62: 0a 09 ecalli 9 // 'new'
64: 14 0b 00 e0 fd fe 00 00 00 00 a4 = 0xfefde000
74: 49 0b u64 [a4 + 0] = 0
76: 71 b7 04 u64 [a4 + 4] = a0
76: 7b b7 04 u64 [a4 + 4] = a0
79: 14 09 04 e0 fd fe 00 00 00 00 a2 = 0xfefde004
89: 33 08 04 a1 = 0x4
92: 33 0a 04 a3 = 0x4
95: 14 07 00 e0 fd fe 00 00 00 00 a0 = 0xfefde000
105: 0a 03 ecalli 3 // 'write'
107: 78 10 ra = u64 [sp]
109: 8b 11 08 i64 sp = i64 sp + 0x8
107: 82 10 ra = u64 [sp]
109: 95 11 08 sp = sp + 0x8
112: 32 00 ret
: @7 [export #3: 'on_transfer']
114: 33 07 a0 = 0x0
Expand Down
Binary file modified services/bootstrap/bootstrap_blob.pvm
Binary file not shown.
Binary file modified services/fib/fib.pvm
Binary file not shown.
52 changes: 26 additions & 26 deletions services/fib/fib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,63 +19,63 @@
18: 33 07 a0 = 0x0
20: 32 00 ret
: @5 [export #1: 'refine']
22: 8b 11 d8 i64 sp = i64 sp - i64 40
25: 71 10 20 u64 [sp + 32] = ra
28: 71 15 18 u64 [sp + 24] = s0
31: 71 16 10 u64 [sp + 16] = s1
22: 95 11 d8 sp = sp - 40
25: 7b 10 20 u64 [sp + 32] = ra
28: 7b 15 18 u64 [sp + 24] = s0
31: 7b 16 10 u64 [sp + 16] = s1
34: 48 11 08 u32 [sp + 8] = 0
37: 49 01 u64 [sp + 0] = 0
39: 64 18 a1 = sp
41: 33 09 0c a2 = 0xc
44: 33 07 a0 = 0x0
46: 0a 10 ecalli 16 // 'import'
46: 0a 12 ecalli 18 // 'import'
48: 01 fallthrough
: @6
49: 79 77 a0 = a0 + 0x0
49: 83 77 i32 a0 = a0 + 0x0
51: 51 07 0d jump @8 if a0 == 0
: @7
54: 33 07 a0 = 0x0
56: 33 09 01 a2 = 0x1
59: 33 08 01 a1 = 0x1
62: 28 11 jump @9
: @8
64: 77 17 04 a0 = i32 [sp + 4]
67: 77 18 08 a1 = i32 [sp + 8]
70: 77 19 a2 = i32 [sp]
72: aa 78 08 a1 = a1 + a0
75: 79 99 01 a2 = a2 + 0x1
64: 81 17 04 a0 = i32 [sp + 4]
67: 81 18 08 a1 = i32 [sp + 8]
70: 81 19 a2 = i32 [sp]
72: be 78 08 i32 a1 = a1 + a0
75: 83 99 01 i32 a2 = a2 + 0x1
78: 01 fallthrough
: @9
79: 70 19 u32 [sp] = a2
81: 70 18 04 u32 [sp + 4] = a1
84: 70 17 08 u32 [sp + 8] = a0
79: 7a 19 u32 [sp] = a2
81: 7a 18 04 u32 [sp + 4] = a1
84: 7a 17 08 u32 [sp + 8] = a0
87: 64 15 s0 = sp
89: 33 06 0c s1 = 0xc
92: 64 17 a0 = sp
94: 33 08 0c a1 = 0xc
97: 0a 11 ecalli 17 // 'export'
97: 0a 13 ecalli 19 // 'export'
99: 64 5a a3 = s0
101: 64 6b a4 = s1
103: 33 07 a0 = 0x0
105: 78 10 20 ra = u64 [sp + 32]
108: 78 15 18 s0 = u64 [sp + 24]
111: 78 16 10 s1 = u64 [sp + 16]
114: 8b 11 28 i64 sp = i64 sp + 0x28
105: 82 10 20 ra = u64 [sp + 32]
108: 82 15 18 s0 = u64 [sp + 24]
111: 82 16 10 s1 = u64 [sp + 16]
114: 95 11 28 sp = sp + 0x28
117: 32 00 ret
: @10 [export #2: 'accumulate']
119: 8b 11 f0 i64 sp = i64 sp - i64 16
122: 71 10 08 u64 [sp + 8] = ra
119: 95 11 f0 sp = sp - 16
122: 7b 10 08 u64 [sp + 8] = ra
125: 46 11 07 u8 [sp + 7] = 0
128: 8b 17 07 i64 a0 = i64 sp + 0x7
131: 8d 77 20 a0 = a0 <<64 32
134: 8e 77 20 a0 = a0 >>64 32
128: 95 17 07 a0 = sp + 0x7
131: 97 77 20 a0 = a0 << 32
134: 98 77 20 a0 = a0 >> 32
137: 14 09 00 00 ff fe 00 00 00 00 a2 = 0xfeff0000
147: 33 08 01 a1 = 0x1
150: 33 0a 0c a3 = 0xc
153: 0a 03 ecalli 3 // 'write'
155: 33 07 a0 = 0x0
157: 78 10 08 ra = u64 [sp + 8]
160: 8b 11 10 i64 sp = i64 sp + 0x10
157: 82 10 08 ra = u64 [sp + 8]
160: 95 11 10 sp = sp + 0x10
163: 32 00 ret
: @11 [export #3: 'on_transfer']
165: 33 07 a0 = 0x0
Expand Down
Binary file modified services/fib/fib_blob.pvm
Binary file not shown.
56 changes: 2 additions & 54 deletions services/fib/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,64 +18,12 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {

#[polkavm_derive::polkavm_import]
extern "C" {
#[polkavm_import(index = 0)]
pub fn gas() -> i64;
#[polkavm_import(index = 1)]
pub fn lookup(service: u32, hash_ptr: *const u8, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 2)]
pub fn read(service: u32, key_ptr: *const u8, key_len: u32, out: *mut u8, out_len: u32) -> u32;
// #[polkavm_import(index = 3)]
// pub fn write(key_ptr: *const u8, key_len: u32, value: *const u8, value_len: u32) -> u32;

#[polkavm_import(index = 3)]
pub fn write(ko: u32, kz: u32, bo: u32, bz: u32) -> u32;

#[polkavm_import(index = 4)]
pub fn info(service: u32, out: *mut u8) -> u32;
#[polkavm_import(index = 5)]
pub fn empower(m: u32, a: u32, v: u32, o: u32, n: u32) -> u32;
#[polkavm_import(index = 6)]
pub fn assign(c: u32, out: *mut u8) -> u32;
#[polkavm_import(index = 7)]
pub fn designate(out: *mut u8) -> u32;
#[polkavm_import(index = 8)]
pub fn checkpoint() -> u64;
#[polkavm_import(index = 9)]
pub fn new(service: u32, hash_ptr: *const u8, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 10)]
pub fn upgrade(out: *const u8, g: u64, m: u64) -> u32;
#[polkavm_import(index = 11)]
pub fn transfer(d: u32, a: u64, g: u64, out: *mut u8) -> u32;
#[polkavm_import(index = 12)]
pub fn quit(d: u32, a: u64, g: u64, out: *mut u8) -> u32;
#[polkavm_import(index = 13)]
pub fn solicit(hash_ptr: *const u8, z: u32) -> u32;
#[polkavm_import(index = 14)]
pub fn forget(hash_ptr: *const u8, z: u32) -> u32;
#[polkavm_import(index = 15)]
pub fn historical_lookup(service: u32, hash_ptr: *const u8, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 16)]
pub fn import(import_index: u32, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 17)]
pub fn export(out: *const u8, out_len: u32) -> u32;
#[polkavm_import(index = 18)]
pub fn machine(out: *const u8, out_len: u32) -> u32;
pub fn import(import_index: u32, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 19)]
pub fn peek(out: *const u8, out_len: u32, i: u32) -> u32;
#[polkavm_import(index = 20)]
pub fn poke(n: u32, a: u32, b: u32, l: u32) -> u32;
#[polkavm_import(index = 21)]
pub fn invoke(n: u32, out: *mut u8) -> u32;
#[polkavm_import(index = 22)]
pub fn expunge(n: u32) -> u32;
#[polkavm_import(index = 99)]
pub fn blake2b(data: *const u8, data_len: u32, hash_ptr: *mut u8) -> u32;
#[polkavm_import(index = 100)]
pub fn blake2s(data: *const u8, data_len: u32, hash_ptr: *mut u8) -> u32;
#[polkavm_import(index = 101)]
pub fn ecrecover(h: *const u8, v: *const u8, r: *const u8, s: *const u8, out: *mut u8) -> u32;
#[polkavm_import(index = 102)]
pub fn sha2_256(data: *const u8, data_len: u32, hash_ptr: *mut u8) -> u32;
pub fn export(out: *const u8, out_len: u32) -> u32;
}

#[polkavm_derive::polkavm_export]
Expand Down
Binary file modified services/megatron/megatron.pvm
Binary file not shown.
40 changes: 20 additions & 20 deletions services/megatron/megatron.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,41 @@
35: 33 07 a0 = 0x0
37: 32 00 ret
: @6 [export #2: 'accumulate']
39: 8b 11 c0 i64 sp = i64 sp - i64 64
42: 71 10 38 u64 [sp + 56] = ra
45: 71 15 30 u64 [sp + 48] = s0
39: 95 11 c0 sp = sp - 64
42: 7b 10 38 u64 [sp + 56] = ra
45: 7b 15 30 u64 [sp + 48] = s0
48: 48 11 08 u32 [sp + 8] = 0
51: 49 01 u64 [sp + 0] = 0
53: 48 11 18 u32 [sp + 24] = 0
56: 49 11 10 u64 [sp + 16] = 0
59: 46 11 1f u8 [sp + 31] = 0
62: 14 08 00 00 ff fe 00 00 00 00 a1 = 0xfeff0000
72: 76 87 a0 = u32 [a1]
74: 76 85 04 s0 = u32 [a1 + 4]
77: 8b 18 1f i64 a1 = i64 sp + 0x1f
72: 80 87 a0 = u32 [a1]
74: 80 85 04 s0 = u32 [a1 + 4]
77: 95 18 1f a1 = sp + 0x1f
80: 33 09 01 a2 = 0x1
83: 64 1a a3 = sp
85: 33 0b 0c a4 = 0xc
88: 0a 02 ecalli 2 // 'read'
90: 8b 18 1f i64 a1 = i64 sp + 0x1f
90: 95 18 1f a1 = sp + 0x1f
93: 33 09 01 a2 = 0x1
96: 8b 1a 10 i64 a3 = i64 sp + 0x10
96: 95 1a 10 a3 = sp + 0x10
99: 33 0b 0c a4 = 0xc
102: 64 57 a0 = s0
104: 0a 02 ecalli 2 // 'read'
106: 77 17 04 a0 = i32 [sp + 4]
109: 77 18 08 a1 = i32 [sp + 8]
112: 77 19 14 a2 = i32 [sp + 20]
115: 77 1a 18 a3 = i32 [sp + 24]
118: 77 1b a4 = i32 [sp]
120: aa 97 07 a0 = a0 + a2
123: aa a8 08 a1 = a1 + a3
126: 70 1b 20 u32 [sp + 32] = a4
129: 70 17 24 u32 [sp + 36] = a0
132: 70 18 28 u32 [sp + 40] = a1
135: 8b 17 1f i64 a0 = i64 sp + 0x1f
106: 81 17 04 a0 = i32 [sp + 4]
109: 81 18 08 a1 = i32 [sp + 8]
112: 81 19 14 a2 = i32 [sp + 20]
115: 81 1a 18 a3 = i32 [sp + 24]
118: 81 1b a4 = i32 [sp]
120: be 97 07 i32 a0 = a0 + a2
123: be a8 08 i32 a1 = a1 + a3
126: 7a 1b 20 u32 [sp + 32] = a4
129: 7a 17 24 u32 [sp + 36] = a0
132: 7a 18 28 u32 [sp + 40] = a1
135: 95 17 1f a0 = sp + 0x1f
138: 33 08 01 a1 = 0x1
141: 8b 19 20 i64 a2 = i64 sp + 0x20
141: 95 19 20 a2 = sp + 0x20
144: 33 0a 0c a3 = 0xc
147: 0a 03 ecalli 3 // 'write'
149: 00 trap
Expand Down
Binary file modified services/megatron/megatron_blob.pvm
Binary file not shown.
38 changes: 0 additions & 38 deletions services/transfer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,8 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {

#[polkavm_derive::polkavm_import]
extern "C" {

#[polkavm_import(index = 1)]
pub fn lookup(service: u32, hash_ptr: *const u8, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 2)]
pub fn read(service: u32, key_ptr: *const u8, key_len: u32, out: *mut u8, out_len: u32) -> u32;

#[polkavm_import(index = 3)]
pub fn write(ko: u64, kz: u64, bo: u64, bz: u64) -> u64;

#[polkavm_import(index = 4)]
pub fn info(service: u64, out: u64) -> u64;

#[polkavm_import(index = 9)]
pub fn new(service: u32, hash_ptr: *const u8, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 10)]
pub fn upgrade(out: *const u8, g: u64, m: u64) -> u32;
#[polkavm_import(index = 11)]
pub fn transfer(d: u64, a: u64, g: u64, out: u64) -> u64;
#[polkavm_import(index = 12)]
pub fn quit(d: u32, a: u64, g: u64, out: *mut u8) -> u32;
#[polkavm_import(index = 13)]
pub fn solicit(hash_ptr: *const u8, z: u32) -> u32;
#[polkavm_import(index = 14)]
pub fn forget(hash_ptr: *const u8, z: u32) -> u32;
#[polkavm_import(index = 15)]
pub fn historical_lookup(service: u32, hash_ptr: *const u8, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 16)]
pub fn import(import_index: u32, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 17)]
pub fn export(out: *const u8, out_len: u32) -> u32;
#[polkavm_import(index = 18)]
pub fn machine(out: *const u8, out_len: u32) -> u32;
#[polkavm_import(index = 19)]
pub fn peek(out: *const u8, out_len: u32, i: u32) -> u32;
#[polkavm_import(index = 20)]
pub fn poke(n: u32, a: u32, b: u32, l: u32) -> u32;
#[polkavm_import(index = 21)]
pub fn invoke(n: u32, out: *mut u8) -> u32;
#[polkavm_import(index = 22)]
pub fn expunge(n: u32) -> u32;
}

#[polkavm_derive::polkavm_export]
Expand Down
Binary file modified services/transfer/transfer.pvm
Binary file not shown.
Loading

0 comments on commit 621ca4d

Please sign in to comment.