util.rs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /* This file is part of DarkFi (https://dark.fi)
  2. *
  3. * Copyright (C) 2020-2024 Dyne.org foundation
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. use std::io::Cursor;
  19. use darkfi_sdk::wasm;
  20. use darkfi_serial::Decodable;
  21. use log::{debug, error};
  22. use wasmer::{FunctionEnvMut, WasmPtr};
  23. use super::acl::acl_allow;
  24. use crate::runtime::vm_runtime::{ContractSection, Env};
  25. /// Host function for logging strings.
  26. pub(crate) fn drk_log(mut ctx: FunctionEnvMut<Env>, ptr: WasmPtr<u8>, len: u32) {
  27. let (env, mut store) = ctx.data_and_store_mut();
  28. // Subtract used gas. Here we count the length of the string.
  29. env.subtract_gas(&mut store, len as u64);
  30. let memory_view = env.memory_view(&store);
  31. match ptr.read_utf8_string(&memory_view, len) {
  32. Ok(msg) => {
  33. let mut logs = env.logs.borrow_mut();
  34. logs.push(msg);
  35. std::mem::drop(logs);
  36. }
  37. Err(_) => {
  38. error!(
  39. target: "runtime::util::drk_log",
  40. "[WASM] [{}] drk_log(): Failed to read UTF-8 string from VM memory",
  41. env.contract_id,
  42. );
  43. }
  44. }
  45. }
  46. /// Writes data to the `contract_return_data` field of [`Env`].
  47. /// The data will be read from `ptr` at a memory offset specified by `len`.
  48. ///
  49. /// Returns `SUCCESS` on success, otherwise returns an error code corresponding
  50. /// to a [`ContractError`].
  51. ///
  52. /// Permissions: metadata, exec
  53. pub(crate) fn set_return_data(mut ctx: FunctionEnvMut<Env>, ptr: WasmPtr<u8>, len: u32) -> i64 {
  54. let (env, mut store) = ctx.data_and_store_mut();
  55. let cid = &env.contract_id;
  56. // Enforce function ACL
  57. if let Err(e) = acl_allow(env, &[ContractSection::Metadata, ContractSection::Exec]) {
  58. error!(
  59. target: "runtime::util::set_return_data",
  60. "[WASM] [{}] set_return_data(): Called in unauthorized section: {}", cid, e,
  61. );
  62. return darkfi_sdk::error::CALLER_ACCESS_DENIED
  63. }
  64. // Subtract used gas. Here we count the length read from the memory slice.
  65. env.subtract_gas(&mut store, len as u64);
  66. let memory_view = env.memory_view(&store);
  67. let Ok(slice) = ptr.slice(&memory_view, len) else { return darkfi_sdk::error::INTERNAL_ERROR };
  68. let Ok(return_data) = slice.read_to_vec() else { return darkfi_sdk::error::INTERNAL_ERROR };
  69. // This function should only ever be called once on the runtime.
  70. if env.contract_return_data.take().is_some() {
  71. return darkfi_sdk::error::SET_RETVAL_ERROR
  72. }
  73. env.contract_return_data.set(Some(return_data));
  74. wasm::entrypoint::SUCCESS
  75. }
  76. /// Retrieve an object from the object store specified by the index `idx`.
  77. /// The object's data is written to `ptr`.
  78. ///
  79. /// Returns `SUCCESS` on success and an error code otherwise.
  80. ///
  81. /// Permissions: deploy, metadata, exec
  82. pub(crate) fn get_object_bytes(mut ctx: FunctionEnvMut<Env>, ptr: WasmPtr<u8>, idx: u32) -> i64 {
  83. // Get the slice, where we will read the size of the buffer
  84. let (env, mut store) = ctx.data_and_store_mut();
  85. let cid = env.contract_id;
  86. // Enforce function ACL
  87. if let Err(e) =
  88. acl_allow(env, &[ContractSection::Deploy, ContractSection::Metadata, ContractSection::Exec])
  89. {
  90. error!(
  91. target: "runtime::util::get_object_bytes()",
  92. "[WASM] [{}] get_object_bytes(): Called in unauthorized section: {}", cid, e,
  93. );
  94. return darkfi_sdk::error::CALLER_ACCESS_DENIED
  95. }
  96. // Get the object from env
  97. let objects = env.objects.borrow();
  98. if idx as usize >= objects.len() {
  99. error!(
  100. target: "runtime::util::get_object_bytes",
  101. "[WASM] [{}] get_object_bytes(): Tried to access object out of bounds", cid,
  102. );
  103. return darkfi_sdk::error::DATA_TOO_LARGE
  104. }
  105. let obj = objects[idx as usize].clone();
  106. drop(objects);
  107. if obj.len() > u32::MAX as usize {
  108. return darkfi_sdk::error::DATA_TOO_LARGE
  109. }
  110. // Subtract used gas. Here we count the bytes written to the memory slice
  111. env.subtract_gas(&mut store, obj.len() as u64);
  112. // Read N bytes from the object and write onto the ptr.
  113. let memory_view = env.memory_view(&store);
  114. let Ok(slice) = ptr.slice(&memory_view, obj.len() as u32) else {
  115. error!(
  116. target: "runtime::util::get_object_bytes",
  117. "[WASM] [{}] get_object_bytes(): Failed to make slice from ptr", cid,
  118. );
  119. return darkfi_sdk::error::INTERNAL_ERROR
  120. };
  121. // Put the result in the VM
  122. if let Err(e) = slice.write_slice(&obj) {
  123. error!(
  124. target: "runtime::util::get_object_bytes",
  125. "[WASM] [{}] get_object_bytes(): Failed to write to memory slice: {}", cid, e,
  126. );
  127. return darkfi_sdk::error::INTERNAL_ERROR
  128. };
  129. wasm::entrypoint::SUCCESS
  130. }
  131. /// Returns the size (number of bytes) of an object in the object store
  132. /// specified by index `idx`.
  133. ///
  134. /// Permissions: deploy, metadata, exec
  135. pub(crate) fn get_object_size(mut ctx: FunctionEnvMut<Env>, idx: u32) -> i64 {
  136. // Get the slice, where we will read the size of the buffer
  137. let (env, mut store) = ctx.data_and_store_mut();
  138. let cid = env.contract_id;
  139. // Enforce function ACL
  140. if let Err(e) =
  141. acl_allow(env, &[ContractSection::Deploy, ContractSection::Metadata, ContractSection::Exec])
  142. {
  143. error!(
  144. target: "runtime::util::get_object_size()",
  145. "[WASM] [{}] get_object_size(): Called in unauthorized section: {}", cid, e,
  146. );
  147. return darkfi_sdk::error::CALLER_ACCESS_DENIED
  148. }
  149. // Get the object from env
  150. let objects = env.objects.borrow();
  151. if idx as usize >= objects.len() {
  152. error!(
  153. target: "runtime::util::get_object_size",
  154. "[WASM] [{}] get_object_size(): Tried to access object out of bounds", cid,
  155. );
  156. return darkfi_sdk::error::DATA_TOO_LARGE
  157. }
  158. let obj = &objects[idx as usize];
  159. let obj_len = obj.len();
  160. drop(objects);
  161. if obj_len > u32::MAX as usize {
  162. return darkfi_sdk::error::DATA_TOO_LARGE
  163. }
  164. // Subtract used gas. Here we count the size of the object.
  165. // TODO: This could probably be fixed-cost
  166. env.subtract_gas(&mut store, obj_len as u64);
  167. obj_len as i64
  168. }
  169. /// Will return current runtime configured verifying block height number
  170. ///
  171. /// Permissions: deploy, metadata, exec
  172. pub(crate) fn get_verifying_block_height(mut ctx: FunctionEnvMut<Env>) -> i64 {
  173. let (env, mut store) = ctx.data_and_store_mut();
  174. let cid = env.contract_id;
  175. if let Err(e) =
  176. acl_allow(env, &[ContractSection::Deploy, ContractSection::Metadata, ContractSection::Exec])
  177. {
  178. error!(
  179. target: "runtime::util::get_verifying_block_height",
  180. "[WASM] [{}] get_verifying_block_height(): Called in unauthorized section: {}", cid, e,
  181. );
  182. return darkfi_sdk::error::CALLER_ACCESS_DENIED
  183. }
  184. // Subtract used gas. Here we count the size of the object.
  185. // u32 is 4 bytes.
  186. env.subtract_gas(&mut store, 4);
  187. env.verifying_block_height as i64
  188. }
  189. /// Will return current runtime configured transaction hash
  190. ///
  191. /// Permissions: deploy, metadata, exec
  192. pub(crate) fn get_tx_hash(mut ctx: FunctionEnvMut<Env>) -> i64 {
  193. let (env, mut store) = ctx.data_and_store_mut();
  194. let cid = env.contract_id;
  195. if let Err(e) =
  196. acl_allow(env, &[ContractSection::Deploy, ContractSection::Metadata, ContractSection::Exec])
  197. {
  198. error!(
  199. target: "runtime::util::get_tx_hash",
  200. "[WASM] [{}] get_tx_hash(): Called in unauthorized section: {}", cid, e,
  201. );
  202. return darkfi_sdk::error::CALLER_ACCESS_DENIED
  203. }
  204. // Subtract used gas. Here we count the size of the object.
  205. env.subtract_gas(&mut store, 32);
  206. // Return the length of the objects Vector.
  207. // This is the location of the data that was retrieved and pushed
  208. let mut objects = env.objects.borrow_mut();
  209. objects.push(env.tx_hash.inner().to_vec());
  210. (objects.len() - 1) as i64
  211. }
  212. /// Will return current runtime configured verifying block height number
  213. ///
  214. /// Permissions: deploy, metadata, exec
  215. pub(crate) fn get_call_index(mut ctx: FunctionEnvMut<Env>) -> i64 {
  216. let (env, mut store) = ctx.data_and_store_mut();
  217. let cid = env.contract_id;
  218. if let Err(e) =
  219. acl_allow(env, &[ContractSection::Deploy, ContractSection::Metadata, ContractSection::Exec])
  220. {
  221. error!(
  222. target: "runtime::util::get_call_index",
  223. "[WASM] [{}] get_call_index(): Called in unauthorized section: {}", cid, e,
  224. );
  225. return darkfi_sdk::error::CALLER_ACCESS_DENIED
  226. }
  227. // Subtract used gas. Here we count the size of the object.
  228. // u8 is 1 byte.
  229. env.subtract_gas(&mut store, 1);
  230. env.call_idx as i64
  231. }
  232. /// Will return current blockchain timestamp,
  233. /// defined as the last block's timestamp.
  234. ///
  235. /// Permissions: deploy, metadata, exec
  236. pub(crate) fn get_blockchain_time(mut ctx: FunctionEnvMut<Env>) -> i64 {
  237. let (env, mut store) = ctx.data_and_store_mut();
  238. let cid = &env.contract_id;
  239. if let Err(e) =
  240. acl_allow(env, &[ContractSection::Deploy, ContractSection::Metadata, ContractSection::Exec])
  241. {
  242. error!(
  243. target: "runtime::util::get_blockchain_time",
  244. "[WASM] [{}] get_blockchain_time(): Called in unauthorized section: {}", cid, e,
  245. );
  246. return darkfi_sdk::error::CALLER_ACCESS_DENIED
  247. }
  248. // Grab current last block
  249. let timestamp = match env.blockchain.lock().unwrap().last_block_timestamp() {
  250. Ok(b) => b,
  251. Err(e) => {
  252. error!(
  253. target: "runtime::util::get_blockchain_time",
  254. "[WASM] [{}] get_blockchain_time(): Internal error getting from blocks tree: {}", cid, e,
  255. );
  256. return darkfi_sdk::error::DB_GET_FAILED
  257. }
  258. };
  259. // Subtract used gas. Here we count the size of the object.
  260. // u64 is 8 bytes.
  261. env.subtract_gas(&mut store, 8);
  262. // Create the return object
  263. let mut ret = Vec::with_capacity(8);
  264. ret.extend_from_slice(&timestamp.inner().to_be_bytes());
  265. // Copy Vec<u8> to the VM
  266. let mut objects = env.objects.borrow_mut();
  267. objects.push(ret.to_vec());
  268. if objects.len() > u32::MAX as usize {
  269. return darkfi_sdk::error::DATA_TOO_LARGE
  270. }
  271. (objects.len() - 1) as i64
  272. }
  273. /// Grabs last block from the `Blockchain` overlay and then copies its
  274. /// height to the VM's object store.
  275. ///
  276. /// On success, returns the index of the new object in the object store.
  277. /// Otherwise, returns an error code.
  278. ///
  279. /// Permissions: deploy, metadata, exec
  280. pub(crate) fn get_last_block_height(mut ctx: FunctionEnvMut<Env>) -> i64 {
  281. let (env, mut store) = ctx.data_and_store_mut();
  282. let cid = &env.contract_id;
  283. // Enforce function ACL
  284. if let Err(e) =
  285. acl_allow(env, &[ContractSection::Deploy, ContractSection::Metadata, ContractSection::Exec])
  286. {
  287. error!(
  288. target: "runtime::util::get_last_block_height",
  289. "[WASM] [{}] get_last_block_height(): Called in unauthorized section: {}", cid, e,
  290. );
  291. return darkfi_sdk::error::CALLER_ACCESS_DENIED
  292. }
  293. // Grab current last block height
  294. let height = match env.blockchain.lock().unwrap().last_block_height() {
  295. Ok(b) => b,
  296. Err(e) => {
  297. error!(
  298. target: "runtime::util::get_last_block_height",
  299. "[WASM] [{}] get_last_block_height(): Internal error getting from blocks tree: {}", cid, e,
  300. );
  301. return darkfi_sdk::error::DB_GET_FAILED
  302. }
  303. };
  304. // Subtract used gas. Here we count the size of the object.
  305. // u64 is 8 bytes.
  306. env.subtract_gas(&mut store, 8);
  307. // Create the return object
  308. let mut ret = Vec::with_capacity(8);
  309. ret.extend_from_slice(&darkfi_serial::serialize(&height));
  310. // Copy Vec<u8> to the VM
  311. let mut objects = env.objects.borrow_mut();
  312. objects.push(ret.to_vec());
  313. if objects.len() > u32::MAX as usize {
  314. return darkfi_sdk::error::DATA_TOO_LARGE
  315. }
  316. (objects.len() - 1) as i64
  317. }
  318. /// Reads a transaction by hash from the transactions store.
  319. ///
  320. /// This function can be called from the Exec or Metadata [`ContractSection`].
  321. ///
  322. /// On success, returns the length of the transaction bytes vector in the environment.
  323. /// Otherwise, returns an error code.
  324. ///
  325. /// Permissions: deploy, metadata, exec
  326. pub(crate) fn get_tx(mut ctx: FunctionEnvMut<Env>, ptr: WasmPtr<u8>) -> i64 {
  327. let (env, mut store) = ctx.data_and_store_mut();
  328. let cid = env.contract_id;
  329. if let Err(e) =
  330. acl_allow(env, &[ContractSection::Deploy, ContractSection::Metadata, ContractSection::Exec])
  331. {
  332. error!(
  333. target: "runtime::util::get_tx",
  334. "[WASM] [{}] get_tx(): Called in unauthorized section: {}", cid, e,
  335. );
  336. return darkfi_sdk::error::CALLER_ACCESS_DENIED
  337. }
  338. // Subtract used gas. Here we count the length of the looked-up hash.
  339. env.subtract_gas(&mut store, blake3::OUT_LEN as u64);
  340. // Ensure that it is possible to read memory
  341. let memory_view = env.memory_view(&store);
  342. let Ok(mem_slice) = ptr.slice(&memory_view, blake3::OUT_LEN as u32) else {
  343. error!(
  344. target: "runtime::util::get_tx",
  345. "[WASM] [{}] get_tx(): Failed to make slice from ptr", cid,
  346. );
  347. return darkfi_sdk::error::DB_GET_FAILED
  348. };
  349. let mut buf = vec![0_u8; blake3::OUT_LEN];
  350. if let Err(e) = mem_slice.read_slice(&mut buf) {
  351. error!(
  352. target: "runtime::util::get_tx",
  353. "[WASM] [{}] get_tx(): Failed to read from memory slice: {}", cid, e,
  354. );
  355. return darkfi_sdk::error::DB_GET_FAILED
  356. };
  357. let mut buf_reader = Cursor::new(buf);
  358. // Decode hash bytes for transaction that we wish to retrieve
  359. let hash: [u8; blake3::OUT_LEN] = match Decodable::decode(&mut buf_reader) {
  360. Ok(v) => v,
  361. Err(e) => {
  362. error!(
  363. target: "runtime::util::get_tx",
  364. "[WASM] [{}] get_tx(): Failed to decode hash from vec: {}", cid, e,
  365. );
  366. return darkfi_sdk::error::DB_GET_FAILED
  367. }
  368. };
  369. // Make sure there are no trailing bytes in the buffer. This means we've used all data that was
  370. // supplied.
  371. if buf_reader.position() != blake3::OUT_LEN as u64 {
  372. error!(
  373. target: "runtime::util::get_tx",
  374. "[WASM] [{}] get_tx(): Trailing bytes in argument stream", cid,
  375. );
  376. return darkfi_sdk::error::DB_GET_FAILED
  377. }
  378. // Retrieve transaction using the `hash`
  379. let ret = match env.blockchain.lock().unwrap().transactions.get_raw(&hash) {
  380. Ok(v) => v,
  381. Err(e) => {
  382. error!(
  383. target: "runtime::util::get_tx",
  384. "[WASM] [{}] get_tx(): Internal error getting from tree: {}", cid, e,
  385. );
  386. return darkfi_sdk::error::DB_GET_FAILED
  387. }
  388. };
  389. // Return special error if the data is empty
  390. let Some(return_data) = ret else {
  391. debug!(
  392. target: "runtime::util::get_tx",
  393. "[WASM] [{}] get_tx(): Return data is empty", cid,
  394. );
  395. return darkfi_sdk::error::DB_GET_EMPTY
  396. };
  397. if return_data.len() > u32::MAX as usize {
  398. return darkfi_sdk::error::DATA_TOO_LARGE
  399. }
  400. // Subtract used gas. Here we count the length of the data read from db.
  401. env.subtract_gas(&mut store, return_data.len() as u64);
  402. // Copy the data (Vec<u8>) to the VM by pushing it to the objects Vector.
  403. let mut objects = env.objects.borrow_mut();
  404. if objects.len() == u32::MAX as usize {
  405. return darkfi_sdk::error::DATA_TOO_LARGE
  406. }
  407. // Return the length of the objects Vector.
  408. // This is the location of the data that was retrieved and pushed
  409. objects.push(return_data.to_vec());
  410. (objects.len() - 1) as i64
  411. }
  412. /// Reads a transaction location by hash from the transactions store.
  413. ///
  414. /// This function can be called from the Exec or Metadata [`ContractSection`].
  415. ///
  416. /// On success, returns the length of the transaction location bytes vector in
  417. /// the environment. Otherwise, returns an error code.
  418. ///
  419. /// Permissions: deploy, metadata, exec
  420. pub(crate) fn get_tx_location(mut ctx: FunctionEnvMut<Env>, ptr: WasmPtr<u8>) -> i64 {
  421. let (env, mut store) = ctx.data_and_store_mut();
  422. let cid = env.contract_id;
  423. if let Err(e) =
  424. acl_allow(env, &[ContractSection::Deploy, ContractSection::Metadata, ContractSection::Exec])
  425. {
  426. error!(
  427. target: "runtime::util::get_tx_location",
  428. "[WASM] [{}] get_tx_location(): Called in unauthorized section: {}", cid, e,
  429. );
  430. return darkfi_sdk::error::CALLER_ACCESS_DENIED
  431. }
  432. // Subtract used gas. Here we count the length of the looked-up hash.
  433. env.subtract_gas(&mut store, blake3::OUT_LEN as u64);
  434. // Ensure that it is possible to read memory
  435. let memory_view = env.memory_view(&store);
  436. let Ok(mem_slice) = ptr.slice(&memory_view, blake3::OUT_LEN as u32) else {
  437. error!(
  438. target: "runtime::util::get_tx_location",
  439. "[WASM] [{}] get_tx_location(): Failed to make slice from ptr", cid,
  440. );
  441. return darkfi_sdk::error::DB_GET_FAILED
  442. };
  443. let mut buf = vec![0_u8; blake3::OUT_LEN];
  444. if let Err(e) = mem_slice.read_slice(&mut buf) {
  445. error!(
  446. target: "runtime::util::get_tx_location",
  447. "[WASM] [{}] get_tx_location(): Failed to read from memory slice: {}", cid, e,
  448. );
  449. return darkfi_sdk::error::DB_GET_FAILED
  450. };
  451. let mut buf_reader = Cursor::new(buf);
  452. // Decode hash bytes for transaction that we wish to retrieve
  453. let hash: [u8; blake3::OUT_LEN] = match Decodable::decode(&mut buf_reader) {
  454. Ok(v) => v,
  455. Err(e) => {
  456. error!(
  457. target: "runtime::util::get_tx_location",
  458. "[WASM] [{}] get_tx_location(): Failed to decode hash from vec: {}", cid, e,
  459. );
  460. return darkfi_sdk::error::DB_GET_FAILED
  461. }
  462. };
  463. // Make sure there are no trailing bytes in the buffer. This means we've used all data that was
  464. // supplied.
  465. if buf_reader.position() != blake3::OUT_LEN as u64 {
  466. error!(
  467. target: "runtime::util::get_tx_location",
  468. "[WASM] [{}] get_tx_location(): Trailing bytes in argument stream", cid,
  469. );
  470. return darkfi_sdk::error::DB_GET_FAILED
  471. }
  472. // Retrieve transaction using the `hash`
  473. let ret = match env.blockchain.lock().unwrap().transactions.get_location_raw(&hash) {
  474. Ok(v) => v,
  475. Err(e) => {
  476. error!(
  477. target: "runtime::util::get_tx_location",
  478. "[WASM] [{}] get_tx_location(): Internal error getting from tree: {}", cid, e,
  479. );
  480. return darkfi_sdk::error::DB_GET_FAILED
  481. }
  482. };
  483. // Return special error if the data is empty
  484. let Some(return_data) = ret else {
  485. debug!(
  486. target: "runtime::util::get_tx_location",
  487. "[WASM] [{}] get_tx_location(): Return data is empty", cid,
  488. );
  489. return darkfi_sdk::error::DB_GET_EMPTY
  490. };
  491. if return_data.len() > u32::MAX as usize {
  492. return darkfi_sdk::error::DATA_TOO_LARGE
  493. }
  494. // Subtract used gas. Here we count the length of the data read from db.
  495. env.subtract_gas(&mut store, return_data.len() as u64);
  496. // Copy the data (Vec<u8>) to the VM by pushing it to the objects Vector.
  497. let mut objects = env.objects.borrow_mut();
  498. if objects.len() == u32::MAX as usize {
  499. return darkfi_sdk::error::DATA_TOO_LARGE
  500. }
  501. // Return the length of the objects Vector.
  502. // This is the location of the data that was retrieved and pushed
  503. objects.push(return_data.to_vec());
  504. (objects.len() - 1) as i64
  505. }