This repository was archived by the owner on Aug 14, 2023. It is now read-only.
Merged
Conversation
neysofu
approved these changes
Dec 13, 2021
Contributor
neysofu
left a comment
There was a problem hiding this comment.
Just some minor comments. LGTM!
neysofu
approved these changes
Dec 13, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I want to refactor the
Runtimeof SVM.Here are the changes done on this one:
Adding
RuntimeError::FuncNotCtorThe
FuncNotAllowedrequires atarget.Since we don't really have a
targetwhen spawning, I've ended up theFuncNotCtorRemoval of
ImportsdependencyInitially, the
Runtimeexpected external imports.Back then, we thought that
Global-State-related host functions would be implemented within thego-spacemesh.Since then, the
Global Statehas been moved to the Rust land, so we ended up with having setting emptyimportsas a parameter when initializing theRuntimeMoved
Template Pricingto another fileI created
TemplatePriceCacheto act as the cache for theTemplate Pricing.The
Runtimeexpects now that cache as a dependency upon initialization.In practice, it'd be ideal to have only a single cache used throughout the process lifetime.
Added
GasTankI thought it would make the code more readable if the repeating pattern of checking whether we've enough gas during will be less explicit and noisy in the code.
I've also added two helpers:
check_gas_for_payloadandcheck_gas_for_func.Both expect a paramere named
gas_leftand its type ofGasTank.Each helper checks first whether there is any
gas in the tankand returns immediately if the tank is empty.The
GasTankcould have been anOption<u64>,but I think it's nicer as it's now.Other
ProtectedModetoAccessMode(also addedImmutableOnlyoption for the future).execfunction the creation ofAccountStoragefor thetarget- it seems unnecessary. If the target doesn't exist, we should fail (to be done in a separate PR)TODOundersrc/runtime/runtime.rssrc/runtime/runtime.rsin the editor.