@@ -45,11 +45,12 @@ package wasmer
45
45
//
46
46
// extern int32_t ext_trie_blake2_256_root_version_1(void *context, int64_t a);
47
47
// extern int32_t ext_trie_blake2_256_ordered_root_version_1(void *context, int64_t a);
48
+ // extern int32_t ext_trie_blake2_256_verify_proof_version_1(void *context, int32_t a, int64_t b, int64_t c, int64_t d);
48
49
//
50
+ // extern int64_t ext_misc_runtime_version_version_1(void *context, int64_t a);
49
51
// extern void ext_misc_print_hex_version_1(void *context, int64_t a);
50
52
// extern void ext_misc_print_num_version_1(void *context, int64_t a);
51
53
// extern void ext_misc_print_utf8_version_1(void *context, int64_t a);
52
- // extern int64_t ext_misc_runtime_version_version_1(void *context, int64_t a);
53
54
//
54
55
// extern void ext_default_child_storage_clear_version_1(void *context, int64_t a, int64_t b);
55
56
// extern int64_t ext_default_child_storage_get_version_1(void *context, int64_t a, int64_t b);
@@ -59,6 +60,7 @@ package wasmer
59
60
// extern void ext_default_child_storage_set_version_1(void *context, int64_t a, int64_t b, int64_t c);
60
61
// extern void ext_default_child_storage_storage_kill_version_1(void *context, int64_t a);
61
62
// extern int32_t ext_default_child_storage_storage_kill_version_2(void *context, int64_t a, int64_t b);
63
+ // extern int64_t ext_default_child_storage_storage_kill_version_3(void *context, int64_t a, int64_t b);
62
64
// extern void ext_default_child_storage_clear_prefix_version_1(void *context, int64_t a, int64_t b);
63
65
// extern int32_t ext_default_child_storage_exists_version_1(void *context, int64_t a, int64_t b);
64
66
//
@@ -75,17 +77,20 @@ package wasmer
75
77
//
76
78
// extern void ext_offchain_index_set_version_1(void *context, int64_t a, int64_t b);
77
79
// extern int32_t ext_offchain_is_validator_version_1(void *context);
80
+ // extern void ext_offchain_local_storage_clear_version_1(void *context, int32_t a, int64_t b);
78
81
// extern int32_t ext_offchain_local_storage_compare_and_set_version_1(void *context, int32_t a, int64_t b, int64_t c, int64_t d);
79
82
// extern int64_t ext_offchain_local_storage_get_version_1(void *context, int32_t a, int64_t b);
80
83
// extern void ext_offchain_local_storage_set_version_1(void *context, int32_t a, int64_t b, int64_t c);
81
84
// extern int64_t ext_offchain_network_state_version_1(void *context);
82
85
// extern int32_t ext_offchain_random_seed_version_1(void *context);
83
86
// extern int64_t ext_offchain_submit_transaction_version_1(void *context, int64_t a);
87
+ // extern int64_t ext_offchain_timestamp_version_1(void *context);
84
88
//
85
89
// extern void ext_storage_append_version_1(void *context, int64_t a, int64_t b);
86
90
// extern int64_t ext_storage_changes_root_version_1(void *context, int64_t a);
87
91
// extern void ext_storage_clear_version_1(void *context, int64_t a);
88
92
// extern void ext_storage_clear_prefix_version_1(void *context, int64_t a);
93
+ // extern int64_t ext_storage_clear_prefix_version_2(void *context, int64_t a, int64_t b);
89
94
// extern void ext_storage_commit_transaction_version_1(void *context);
90
95
// extern int32_t ext_storage_exists_version_1(void *context, int64_t a);
91
96
// extern int64_t ext_storage_get_version_1(void *context, int64_t a);
@@ -95,6 +100,9 @@ package wasmer
95
100
// extern int64_t ext_storage_root_version_1(void *context);
96
101
// extern void ext_storage_set_version_1(void *context, int64_t a, int64_t b);
97
102
// extern void ext_storage_start_transaction_version_1(void *context);
103
+ //
104
+ // extern void ext_transaction_index_index_version_1(void *context, int32_t a, int32_t b, int32_t c);
105
+ // extern void ext_transaction_index_renew_version_1(void *context, int32_t a, int32_t b);
98
106
import "C"
99
107
100
108
import (
@@ -154,6 +162,18 @@ func ext_logging_max_level_version_1(context unsafe.Pointer) C.int32_t {
154
162
return 4
155
163
}
156
164
165
+ //export ext_transaction_index_index_version_1
166
+ func ext_transaction_index_index_version_1 (context unsafe.Pointer , a , b , c C.int32_t ) {
167
+ logger .Trace ("[ext_transaction_index_index_version_1] executing..." )
168
+ logger .Warn ("[ext_transaction_index_index_version_1] unimplemented" )
169
+ }
170
+
171
+ //export ext_transaction_index_renew_version_1
172
+ func ext_transaction_index_renew_version_1 (context unsafe.Pointer , a , b C.int32_t ) {
173
+ logger .Trace ("[ext_transaction_index_renew_version_1] executing..." )
174
+ logger .Warn ("[ext_transaction_index_renew_version_1] unimplemented" )
175
+ }
176
+
157
177
//export ext_sandbox_instance_teardown_version_1
158
178
func ext_sandbox_instance_teardown_version_1 (context unsafe.Pointer , a C.int32_t ) {
159
179
logger .Trace ("[ext_sandbox_instance_teardown_version_1] executing..." )
@@ -835,6 +855,13 @@ func ext_trie_blake2_256_ordered_root_version_1(context unsafe.Pointer, dataSpan
835
855
return C .int32_t (ptr )
836
856
}
837
857
858
+ //export ext_trie_blake2_256_verify_proof_version_1
859
+ func ext_trie_blake2_256_verify_proof_version_1 (context unsafe.Pointer , a C.int32_t , b , c , d C.int64_t ) C.int32_t {
860
+ logger .Debug ("[ext_trie_blake2_256_verify_proof_version_1] executing..." )
861
+ logger .Warn ("[ext_trie_blake2_256_verify_proof_version_1] unimplemented" )
862
+ return 0
863
+ }
864
+
838
865
//export ext_misc_print_hex_version_1
839
866
func ext_misc_print_hex_version_1 (context unsafe.Pointer , dataSpan C.int64_t ) {
840
867
logger .Trace ("[ext_misc_print_hex_version_1] executing..." )
@@ -1093,9 +1120,36 @@ func ext_default_child_storage_storage_kill_version_1(context unsafe.Pointer, ch
1093
1120
}
1094
1121
1095
1122
//export ext_default_child_storage_storage_kill_version_2
1096
- func ext_default_child_storage_storage_kill_version_2 (context unsafe.Pointer , a , b C.int64_t ) C.int32_t {
1123
+ func ext_default_child_storage_storage_kill_version_2 (context unsafe.Pointer , childStorageKeySpan , _ C.int64_t ) C.int32_t {
1097
1124
logger .Debug ("[ext_default_child_storage_storage_kill_version_2] executing..." )
1098
- logger .Warn ("[ext_default_child_storage_storage_kill_version_2] unimplemented" )
1125
+ logger .Warn ("[ext_default_child_storage_storage_kill_version_2] somewhat unimplemented" )
1126
+ // TODO: need to use `limit` parameter
1127
+
1128
+ instanceContext := wasm .IntoInstanceContext (context )
1129
+ ctx := instanceContext .Data ().(* runtime.Context )
1130
+ storage := ctx .Storage
1131
+
1132
+ childStorageKey := asMemorySlice (instanceContext , childStorageKeySpan )
1133
+ storage .DeleteChild (childStorageKey )
1134
+
1135
+ // note: this function always returns `KillStorageResult::AllRemoved`, which is 0
1136
+ return 0
1137
+ }
1138
+
1139
+ //export ext_default_child_storage_storage_kill_version_3
1140
+ func ext_default_child_storage_storage_kill_version_3 (context unsafe.Pointer , childStorageKeySpan , _ C.int64_t ) C.int64_t {
1141
+ logger .Debug ("[ext_default_child_storage_storage_kill_version_3] executing..." )
1142
+ logger .Warn ("[ext_default_child_storage_storage_kill_version_3] somewhat unimplemented" )
1143
+ // TODO: need to use `limit` parameter
1144
+
1145
+ instanceContext := wasm .IntoInstanceContext (context )
1146
+ ctx := instanceContext .Data ().(* runtime.Context )
1147
+ storage := ctx .Storage
1148
+
1149
+ childStorageKey := asMemorySlice (instanceContext , childStorageKeySpan )
1150
+ storage .DeleteChild (childStorageKey )
1151
+
1152
+ // TODO: this function returns a `KillStorageResult` which may be `AllRemoved` (0) or `SomeRemaining` (1)
1099
1153
return 0
1100
1154
}
1101
1155
@@ -1297,6 +1351,12 @@ func ext_offchain_index_set_version_1(context unsafe.Pointer, keySpan, valueSpan
1297
1351
logger .Warn ("[ext_offchain_index_set_version_1] unimplemented" )
1298
1352
}
1299
1353
1354
+ //export ext_offchain_local_storage_clear_version_1
1355
+ func ext_offchain_local_storage_clear_version_1 (context unsafe.Pointer , a C.int32_t , b C.int64_t ) {
1356
+ logger .Trace ("[ext_offchain_local_storage_clear_version_1] executing..." )
1357
+ logger .Warn ("[ext_offchain_local_storage_clear_version_1] unimplemented" )
1358
+ }
1359
+
1300
1360
//export ext_offchain_is_validator_version_1
1301
1361
func ext_offchain_is_validator_version_1 (context unsafe.Pointer ) C.int32_t {
1302
1362
logger .Debug ("[ext_offchain_is_validator_version_1] executing..." )
@@ -1478,6 +1538,13 @@ func ext_offchain_submit_transaction_version_1(context unsafe.Pointer, data C.in
1478
1538
return C .int64_t (ptr )
1479
1539
}
1480
1540
1541
+ //export ext_offchain_timestamp_version_1
1542
+ func ext_offchain_timestamp_version_1 (context unsafe.Pointer ) C.int64_t {
1543
+ logger .Trace ("[ext_offchain_timestamp_version_1] executing..." )
1544
+ logger .Warn ("[ext_offchain_timestamp_version_1] unimplemented" )
1545
+ return 0
1546
+ }
1547
+
1481
1548
func storageAppend (storage runtime.Storage , key , valueToAppend []byte ) error {
1482
1549
nextLength := big .NewInt (1 )
1483
1550
var valueRes []byte
@@ -1584,6 +1651,27 @@ func ext_storage_clear_prefix_version_1(context unsafe.Pointer, prefixSpan C.int
1584
1651
}
1585
1652
}
1586
1653
1654
+ //export ext_storage_clear_prefix_version_2
1655
+ func ext_storage_clear_prefix_version_2 (context unsafe.Pointer , prefixSpan , _ C.int64_t ) C.int64_t {
1656
+ logger .Trace ("[ext_storage_clear_prefix_version_2] executing..." )
1657
+ logger .Warn ("[ext_storage_clear_prefix_version_2] somewhat unimplemented" )
1658
+ // TODO: need to use unused `limit` parameter
1659
+
1660
+ instanceContext := wasm .IntoInstanceContext (context )
1661
+ ctx := instanceContext .Data ().(* runtime.Context )
1662
+ storage := ctx .Storage
1663
+
1664
+ prefix := asMemorySlice (instanceContext , prefixSpan )
1665
+ logger .Debug ("[ext_storage_clear_prefix_version_1]" , "prefix" , fmt .Sprintf ("0x%x" , prefix ))
1666
+
1667
+ err := storage .ClearPrefix (prefix )
1668
+ if err != nil {
1669
+ logger .Error ("[ext_storage_clear_prefix_version_1]" , "error" , err )
1670
+ }
1671
+
1672
+ return 1
1673
+ }
1674
+
1587
1675
//export ext_storage_exists_version_1
1588
1676
func ext_storage_exists_version_1 (context unsafe.Pointer , keySpan C.int64_t ) C.int32_t {
1589
1677
logger .Trace ("[ext_storage_exists_version_1] executing..." )
@@ -1961,6 +2049,10 @@ func ImportsNodeRuntime() (*wasm.Imports, error) { //nolint
1961
2049
if err != nil {
1962
2050
return nil , err
1963
2051
}
2052
+ _ , err = imports .Append ("ext_default_child_storage_storage_kill_version_3" , ext_default_child_storage_storage_kill_version_3 , C .ext_default_child_storage_storage_kill_version_3 )
2053
+ if err != nil {
2054
+ return nil , err
2055
+ }
1964
2056
1965
2057
_ , err = imports .Append ("ext_hashing_blake2_128_version_1" , ext_hashing_blake2_128_version_1 , C .ext_hashing_blake2_128_version_1 )
1966
2058
if err != nil {
@@ -2025,6 +2117,10 @@ func ImportsNodeRuntime() (*wasm.Imports, error) { //nolint
2025
2117
if err != nil {
2026
2118
return nil , err
2027
2119
}
2120
+ _ , err = imports .Append ("ext_offchain_local_storage_clear_version_1" , ext_offchain_local_storage_clear_version_1 , C .ext_offchain_local_storage_clear_version_1 )
2121
+ if err != nil {
2122
+ return nil , err
2123
+ }
2028
2124
_ , err = imports .Append ("ext_offchain_local_storage_compare_and_set_version_1" , ext_offchain_local_storage_compare_and_set_version_1 , C .ext_offchain_local_storage_compare_and_set_version_1 )
2029
2125
if err != nil {
2030
2126
return nil , err
@@ -2049,6 +2145,10 @@ func ImportsNodeRuntime() (*wasm.Imports, error) { //nolint
2049
2145
if err != nil {
2050
2146
return nil , err
2051
2147
}
2148
+ _ , err = imports .Append ("ext_offchain_timestamp_version_1" , ext_offchain_timestamp_version_1 , C .ext_offchain_timestamp_version_1 )
2149
+ if err != nil {
2150
+ return nil , err
2151
+ }
2052
2152
2053
2153
_ , err = imports .Append ("ext_sandbox_instance_teardown_version_1" , ext_sandbox_instance_teardown_version_1 , C .ext_sandbox_instance_teardown_version_1 )
2054
2154
if err != nil {
@@ -2095,6 +2195,10 @@ func ImportsNodeRuntime() (*wasm.Imports, error) { //nolint
2095
2195
if err != nil {
2096
2196
return nil , err
2097
2197
}
2198
+ _ , err = imports .Append ("ext_storage_clear_prefix_version_2" , ext_storage_clear_prefix_version_2 , C .ext_storage_clear_prefix_version_2 )
2199
+ if err != nil {
2200
+ return nil , err
2201
+ }
2098
2202
_ , err = imports .Append ("ext_storage_commit_transaction_version_1" , ext_storage_commit_transaction_version_1 , C .ext_storage_commit_transaction_version_1 )
2099
2203
if err != nil {
2100
2204
return nil , err
@@ -2140,6 +2244,19 @@ func ImportsNodeRuntime() (*wasm.Imports, error) { //nolint
2140
2244
if err != nil {
2141
2245
return nil , err
2142
2246
}
2247
+ _ , err = imports .Append ("ext_trie_blake2_256_verify_proof_version_1" , ext_trie_blake2_256_verify_proof_version_1 , C .ext_trie_blake2_256_verify_proof_version_1 )
2248
+ if err != nil {
2249
+ return nil , err
2250
+ }
2251
+
2252
+ _ , err = imports .Append ("ext_transaction_index_index_version_1" , ext_transaction_index_index_version_1 , C .ext_transaction_index_index_version_1 )
2253
+ if err != nil {
2254
+ return nil , err
2255
+ }
2256
+ _ , err = imports .Append ("ext_transaction_index_renew_version_1" , ext_transaction_index_renew_version_1 , C .ext_transaction_index_renew_version_1 )
2257
+ if err != nil {
2258
+ return nil , err
2259
+ }
2143
2260
2144
2261
return imports , nil
2145
2262
}
0 commit comments