On issue #458, we've extended the svm-codec to be aware of the Envelope.
We'll adapt both the Runtime and the C-API require a Transaction instead of Envelope and Message.
impl Runtime {
pub fn deploy(
&mut self,
raw_tx: &[u8],
context: &Context,
) -> DeployReceipt {
let tx = svm_codec::tx::decode_deploy(raw_tx);
if tx.is_err() {
let err = err::func_invalid_deploy(tx);
Err(err)
}
let tx = tx.unwrap();
let env = tx.envelope();
let msg = tx.message();
}
}
Now, we want to keep the raw_tx since we'll need it for further usage.
In the Deploy transaction, it'll be used for deriving the Template Address.
We'll need the' raw_tx' for Spawn, Call, and Verify we'll need the raw_tx for executing code.
(the raw transaction will be copied to the Wasm Instance Memory - see issue #462).
In similar fashion, we need to update the spawn, call and verify to require only the raw transaction.
The svm_codec should expose:
svm_codec::decode_deploy - to be used by deploy.
note that, right now we have svm_codec::template::decode but it only addresses the Message part.
svm_codec::decode_spawn - to be used by spawn.
svm_codec::decode_call - to be used by call.
svm_codec::decode_tx - to be used by verify.
Notes
For verify we could probably manage only with decoding the Envelope part.
So we can have instead svm_codec::decode_env.
The validations method (i.e validate_deploy/validate_spawn/validate_call should expect the whole raw transactions as a parameter.
Depends on #458
On issue #458, we've extended the
svm-codec
to be aware of theEnvelope
. We'll adapt both theRuntime
and the C-API require aTransaction
instead ofEnvelope
andMessage
.As an example, here we have the
svm_deploy
under the FFI API: https://github.com/spacemeshos/svm/blob/6edb73de199fafce0953f82af061ca1090ff911c/crates/runtime-ffi/src/api.rs#L262We'll modify the API to look as the following:
Consequently, we'll change the
Runtime
. In theDeploy
context, we've this link: https://github.com/spacemeshos/svm/blob/6edb73de199fafce0953f82af061ca1090ff911c/crates/runtime/src/runtime/runtime.rs#L548it'll be modified to something similar to this:
Now, we want to keep the
raw_tx
since we'll need it for further usage. In theDeploy
transaction, it'll be used for deriving theTemplate Address
.We'll need the' raw_tx' for
Spawn
,Call
, andVerify
we'll need theraw_tx
for executing code. (the raw transaction will be copied to the Wasm Instance Memory - see issue #462).In similar fashion, we need to update the
spawn
,call
andverify
to require only the raw transaction. Thesvm_codec
should expose:svm_codec::decode_deploy
- to be used bydeploy
. note that, right now we havesvm_codec::template::decode
but it only addresses theMessage
part.svm_codec::decode_spawn
- to be used byspawn
.svm_codec::decode_call
- to be used bycall
.svm_codec::decode_tx
- to be used byverify
.Notes
For
verify
we could probably manage only with decoding theEnvelope
part. So we can have insteadsvm_codec::decode_env
.The validations method (i.e
validate_deploy/validate_spawn/validate_call
should expect the whole raw transactions as a parameter.For example, this code: https://github.com/spacemeshos/svm/blob/6edb73de199fafce0953f82af061ca1090ff911c/crates/runtime/src/runtime/runtime.rs#L521
It should be modified to validate the whole transaction instead of only the
Message
part of aDeploy Transaction
.