Skip to content
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

[FVM] refactor5- simplify storage limit checker code #950

Merged
merged 9 commits into from
Jul 26, 2021

Conversation

ramtinms
Copy link
Member

@ramtinms ramtinms commented Jul 12, 2021

This PR:

  • simplifies the logic of storage limit checker by not injecting the method (that was a legacy code from the time that storage capacity was not a cadence balance check call)
  • no new env is created for the storage limit checker, this removes unwanted changes by two env controlling the same program cache.
  • using new Env mocking system the tests has been ported without issue

@ramtinms ramtinms changed the title [FVM] refactor5- simplify storage limit checker code [WIP] [FVM] refactor5- simplify storage limit checker code Jul 12, 2021
@ramtinms ramtinms changed the title [WIP] [FVM] refactor5- simplify storage limit checker code [FVM] refactor5- simplify storage limit checker code Jul 12, 2021
@ramtinms ramtinms requested a review from m4ksio July 12, 2021 22:21
Copy link
Contributor

@janezpodhostnik janezpodhostnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner! Nice!

@@ -186,6 +186,10 @@ func (e *ScriptEnv) ValueExists(owner, key []byte) (exists bool, err error) {
return len(v) > 0, nil
}

func (e *ScriptEnv) AccountExists(address common.Address) (exists bool, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this being used anywhere, or did I miss something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used anywhere yet, but I need it for the next PR.

Copy link
Member

@Kay-Zee Kay-Zee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


// does it exist?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we no longer need to check for existence?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to check existence accounts that are passed are already checked and if accounts not exist it would return zero capacity so it errors out.

fvm/transactionStorageLimiter.go Outdated Show resolved Hide resolved
func (e *ScriptEnv) EmitEvent(event cadence.Event) error {
return errors.NewOperationNotSupportedError("EmitEvent")
}

func (e *ScriptEnv) Events() []flow.Event {
return []flow.Event{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why simply not nil?

Base automatically changed from ramtin/fvm-separate-environments to master July 26, 2021 16:35
@ramtinms ramtinms merged commit 397f22b into master Jul 26, 2021
@ramtinms ramtinms deleted the ramtin/fvm-refactor-storage-limiter branch July 26, 2021 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants