The Envelope will consist of the following fields:
version - For versioning (to ease introducing new changes in the future).
Right now, we'll only accept the value 0x0 (for Genesis)
We can use a variable length-integer encoding here.
Or allocate a fixed number of bytes
type - The Transaction type (Deploy / Spawn / Call)
A single byte seems the right choice.
principal - The Address of the Account paying for the Gas.
This will consume 20 bytes.
amount - For funding.
This field will be of type 64-bit integer (Big-Endian order).
We can use a variable length-integer encoding here.
tx_nonce - For the tx nonce.
I think can use a variable length-integer encoding here (encoding up to say 128 bit).
The number 128-bit should suffice for any imaginable Generalized Nonce Scheme to be implemented.
gas_limit - Maximum units of Gas to be paid.
This field will be of type 64-bit integer (Big-Endian order).
We can use a variable length-integer encoding here.
gas_fee - Fee per Unit of Gas.
This field will be of type 64-bit integer (Big-Endian order).
We can use a variable length-integer encoding here.
When it was implemented we've thought about the encoding between go-svm and SVM.
Since we've decided that SVM will own the encoding of the Envelope the implementation might change
to be more compact. (and of course, it should adjust to include version andtype` as well).
Now we could implement the Codec trait for Message.
This implementation will look on the transaction type and delegate the rest of the work to the current implementations of Template/SpawnAccunt/Transaction types.
It might be worth renaming SpawnAccount to simply Spawn.
Lastly, we could implement the Codec trait for Transaction
So decoding a Transaction will involve first decoding the Envelope part and then the Message part.
As discussed in the AA Transactions & SVM Integration
The
Envelope
will consist of the following fields:version
- For versioning (to ease introducing new changes in the future). Right now, we'll only accept the value 0x0 (for Genesis) We can use a variable length-integer encoding here. Or allocate a fixed number of bytestype
- The Transaction type (Deploy / Spawn / Call
) A single byte seems the right choice.principal
- TheAddress
of the Account paying for the Gas. This will consume 20 bytes.amount
- For funding. This field will be of type 64-bit integer (Big-Endian order). We can use a variable length-integer encoding here.tx_nonce
- For the tx nonce. I think can use a variable length-integer encoding here (encoding up to say 128 bit). The number 128-bit should suffice for any imaginable Generalized Nonce Scheme to be implemented.gas_limit
- Maximum units of Gas to be paid. This field will be of type 64-bit integer (Big-Endian order). We can use a variable length-integer encoding here.gas_fee
- Fee per Unit of Gas. This field will be of type 64-bit integer (Big-Endian order). We can use a variable length-integer encoding here.Notes
Envelope
type under thesvm-types
https://github.com/spacemeshos/svm/blob/master/crates/types/src/transaction/envelope.rsIt should be extended to have the
version
andtype
fields as well.svm-codec
right now we have some working implementation for theEnvelope
. https://github.com/spacemeshos/svm/blob/6edb73de199fafce0953f82af061ca1090ff911c/crates/codec/src/codec.rs#L137When it was implemented we've thought about the encoding between
go-svm
and SVM. Since we've decided that SVM will own the encoding of theEnvelope
the implementation might change to be more compact. (and of course, it should adjust to includeversion and
type` as well).Message
type to SVM under: https://github.com/spacemeshos/svm/tree/master/crates/types/src/transactionThe
Message
will be anenum
that will hold one of theMessage
types:Now we could implement the
Codec
trait forMessage
. This implementation will look on thetransaction type
and delegate the rest of the work to the current implementations ofTemplate/SpawnAccunt/Transaction
types.It might be worth renaming
SpawnAccount
to simplySpawn
.Regarding
Transaction
, if it'll be renamed toCall
we need to also rename this type: https://github.com/spacemeshos/svm/blob/master/crates/runtime/src/runtime/call.rsIf the
Transaction
name will be free again we could have:Lastly, we could implement the
Codec
trait forTransaction
So decoding aTransaction
will involve first decoding theEnvelope
part and then theMessage
part.@lrettig FYI