massalabs / massa

The Decentralized and Scaled Blockchain
https://massa.net
5.58k stars 718 forks source link

Encapsulate the different states of the `SecureSend` wrapper into a state-machine of some sort. #3397

Open Ben-PH opened 1 year ago

Ben-PH commented 1 year ago

Is your feature request related to a problem? Please describe.

Right now, the SecureSend wrapper does not communicate which step of the process is current.

Describe the solution you'd like

A state-machine of some sort, which encapsulates the appropriate states

Describe alternatives you've considered

none yet

Additional context

critically important to not allow mutability of the data. Will probably need to think of an api and pub model.

Encapsulating state introduces data overhead unless the optimiser is able to do its thing. I don't think it would be an issue in the general case, but could contribute to "death by a thousand cuts", particularly if the overhead is included in data-transfer channels

Ben-PH commented 1 year ago

I came across this discussion on reddit about dependent typing that made me think of this: https://old.reddit.com/r/rust/comments/104md0s/is_coding_in_rust_as_bad_as_in_c_a_practical/j37v4z5/

I'm not too good with GAT, and other type-system wizzardries that you'll find a lot in languages like Haskell. I'm wondering if this would be a good use-case for such a type-system.