Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Extending svm-codec with the Envelope #458

Closed
YaronWittenstein opened this issue Dec 19, 2021 · 1 comment
Closed

Extending svm-codec with the Envelope #458

YaronWittenstein opened this issue Dec 19, 2021 · 1 comment
Assignees
Labels
codec Related to the Codec simple-coin-iteration-1 svm svm-core SVM core change

Comments

@YaronWittenstein
Copy link
Contributor

YaronWittenstein commented Dec 19, 2021

As discussed in the AA Transactions & SVM Integration

The Envelope will consist of the following fields:

  1. 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

  2. type - The Transaction type (Deploy / Spawn / Call)
    A single byte seems the right choice.

  3. principal - The Address of the Account paying for the Gas.
    This will consume 20 bytes.

  4. amount - For funding.
    This field will be of type 64-bit integer (Big-Endian order).
    We can use a variable length-integer encoding here.

  5. 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.

  6. 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.

  7. 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

It should be extended to have the version and type fields as well.

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 and type` as well).

The Message will be an enum that will hold one of the Message types:

enum Message {
  Deploy(Template), 
  Spawn(SpawnAccount),
  Call(Transaction),
}

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.

struct Transaction {
  envelope: Envelope,
  message: Message
}
  • 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.

@lrettig FYI

@neysofu
Copy link
Contributor

neysofu commented Feb 16, 2022

Not relevant anymore due to changes to transaction syntax.

@neysofu neysofu closed this as completed Feb 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
codec Related to the Codec simple-coin-iteration-1 svm svm-core SVM core change
Projects
None yet
Development

No branches or pull requests

2 participants