spacemeshos / svm

SVM - Spacemesh Virtual Machine
https://spacemesh.io
MIT License
85 stars 14 forks source link

Implement host function: `svm_tx_range` #437

Open YaronWittenstein opened 2 years ago

YaronWittenstein commented 2 years ago

Depends on: #457

So assuming the FuncEnv holds tx of type Option<(usize, size>) it should be very easy to add this host function:

svm_tx_range that would return the Memory range holding the binary transaction. We need to consult Wasmer about whether it's possible to implement that as a single host function.

i.e:

fn txdata(env: &FuncEnv) -> (i32, i32) { ... }

If that won't work then please implement as two separate host functions:

fn txdata_offset(env: &FuncEnv) -> i32 { ... }

and

fn txdata_len(env: &FuncEnv) -> i32 { ... }

p.s: If the single host function will work please convert the current calldata_offset and calldata_len into a single host function as well: https://github.com/spacemeshos/svm/blob/6edb73de199fafce0953f82af061ca1090ff911c/crates/runtime/src/vmcalls/calldata.rs#L1-L16