purely functional on-chain smart contracts.
Opened this issue · 4 comments
An idea to make amoveo contracts shorter.
A new transaction type, and all it did was define a pure function to be made available in chalang.
So from now on, you could use this function in any chalang programs.
So far, we have been using the same 2 contracts over and over. When we do a channel_slash tx, it can be a very large transaction.
We could make both of these contracts into functions that will exist forever on Amoveo.
It wont take up more space than a few dozen accounts, and every channel_slash and channel_solo_close tx can be much smaller from now on.
This is especially important for a certain class of attacks where the attacker causes many people to want to do channel_slash txs at the same time.
Instead of making a new governance variable, we could reuse the one for making accounts. And have 1 byte of smart contract cost the same as 1 byte of accounts.
This would just be 1 new tx type.
Maybe we should call these purely functional smart contracts "libraries".
We would need to include merkel proofs of all the libraries we will use with our channel_solo_close and channel_slash txs. This merkel proof would include the entire smart contract definition.
So this method only saves block space if multiple people are using the same smart contract in the same block.
Something in spk.erl needs to insert all the library definitions into the chalang contract before running it in the chalang vm.
Some nodes could choose to download blocks without merkel proofs, and for them this would save a lot of space.
If we use sharding, and we want all the contracts to be available to all the shards, then that means 1 byte of libraries is much more expensive than 1 byte of accounts.
So I guess it does need to be a new governance variable.