spacemeshos / svm

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

Reconstruct the whole binary Transaction #446

Closed YaronWittenstein closed 2 years ago

YaronWittenstein commented 2 years ago

Currently, SVM has no idea about the original Envelope encoding.

The way things are working is that go-svm encodes the Envelope into an in-memory buffer and passes it using the cGO API back to SVM.

SVM knows how to decode that buffer, but nothing guarantees that the original encoding of the Envelope as sent over the network will match the one used to communicate later between go-svm and SVM.

In order the satisfy the requirement of being able to hash the whole original transaction - SVM needs to be able to reconstruct the original Envelope encoding. In order to simplify things, it's highly suggested that go-svm will send the Envelope buffer using the original on-the-wire format and that SVM will know how to decode it later by itself.

Once SVM holds the original binary Envelope and the original binary Message (which is basically just passed as it's by go-spacemesh to go-svm and then to SVM) - SVM could combine these two parts into one. In other words, SVM has the original data of the transaction.

Another way to go about implementing this issue is to adjust the go-svm to SVM interface to simply send the whole transaction as a single buffer. Both implementations should end up with SVM having the whole original binary transaction.

YaronWittenstein commented 2 years ago

I'm closing this issue due to the recent agreement that SVM will take charge of parsing the Envelope. In other words, the go-svm and SVM C-API will require only a single tx parameter instead of two separate Envelope and Message params.

@neysofu @neysofu