-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider using global variables instead of storage for some variables #15
Comments
@jakinyele Can you look at incorporating these changes? It seems like it may be relatively straightforward to implement these changes, and I'm unsure what complexity is added to the establish flow. |
This issue is being addressed in the branch |
Using global variables instead of storage for any channel-specific attributes introduces significant complexity in our code base, ie either the merchant or both parties will have to compile the contract using the SmartPy script. That is, if we switch merchant-specific attributes to global storage, then each merchant will have their own version of the contract, and if we switch customer-specific attributes as well, we would have a version of the contract for _each pair (or rather, channel). Therefore, I suggest we do not consider adding channel-specific attributes to storage at this time. @DariusParvin can you follow up with a list of non-channel-specific attributes where it does/might make sense to consider this optimization? |
The attributes that are possible to optimize are: I don't believe we have any intentions to make I can think of two reasons we may want
|
I agree with the above outlined approach. @jakinyele ? |
I also agree with the suggested approach. |
From the SmartPy review #4:
For the variables which get set once at the beginning of the contract and never change, they can be hard coded in the contract, rather than being defined in the 'storage' part of the contract. It would make the contract smaller and therefore cost less to originate. It could be done for the global variables such as 'selfDelay', as well as channel specific variables such as
cid
, although doing it for the channel specific variables would add a lot of complexity to the establish flow.The gains in efficiency would be relatively small (at least compared to a potential multichannel contract), so it's probably worth holding off on this until we explore that first.
The zkChannel spec is agnostic to exactly how the contract is specified. All that matters is that the merchant checks that what the customer originates on chain is what they expected given the same channel parameters.
The text was updated successfully, but these errors were encountered: