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

Feat/vm1.5 #4789

Merged
merged 370 commits into from Jun 26, 2023
Merged

Feat/vm1.5 #4789

merged 370 commits into from Jun 26, 2023

Conversation

iulianpascalau
Copy link
Contributor

@iulianpascalau iulianpascalau commented Dec 12, 2022

Multi-async on a single level:
In a single-level multi-async we do not break the execution of scA when scA makes an asyncCall (in v1 we stopped the execution of scA, so asyncCall is always the last thing scA does in currently deployed and developed SCs), we only register the requests to the VM to make an async call after the execution ends. This registration saves the asyncCall info into a VM internal structure, plus a set of information persisted in the storage of the SC under protected keys (SC can read these keys, but cannot forcefully write under those, only by using the asyncCalls). Persisted information is cleaned up from SC trie after the asyncCalls and callBacks are concluded.
scA registers a number of asyncCalls and finishes its execution. The VM iterates on the registered asyncCalls and calls them in the order they were created. If one execution is intrashard, it will execute synchronously, in the case of cross-shard calls, those will be propagated as a smart contract result cross-shard, and a callback is called through a callback SCR. The function which should be called back is registered and persisted in the storage, so the VM will read from storage according to the unique IDs of the asyncCalls and get all the necessary information needed for the callback.
Introduced a limitation of multi-level asynchronous calls. AsyncCall from AsyncCall is not allowed. AsyncCall from callback is not allowed.

ManagedBigFloats:
Introduced a new API that targets bigFloats. Safe math with bigFloats, using standardized GO libraries.

ManagedMap:
Introduced a new API to support managed Maps for SC developers. Simple to use, all map features included.

BackTransfers:
We found that we can help developers, by changing some of the paradigms regarding SC to SC execution with payments. On the old VM if parentSC called childSC and childSC transferred back tokens to parents it must have called a “deposit” function and parentSC had to register that deposit into a storage. After that childSC execution is finished, we get back into the execution of parentSC and we have to read from storage what kind of transfers the child did towards itself.
Another problem with this is if parentSC is not payable by SC and childSC does not call deposit, only transfers, the execution will fail. This is even more complicated in asynchronous calls, and we found that if childSC is not well written, a malicious parentSC can make it problematic for the childSC. One example was the liquid staking contracts, where unbonded funds could get lost because malicious parentSC was not payable by SC.
So we decided to change the paradigm: When parentSC calls childSC and childSC does a set of transfers to the parent, the payable check is skipped for the parent. The check is skipped even if the parentSC called with asyncCall the childSC and even if childSC is in another shard vs. the parentSC.
Technically speaking: All transfers without execution from childSC to parentSC are accumulated in a new structure called backTransfers. In the end, the parentSC can do the following <payments, results> = ExecuteOnDest(child). This makes DeFi legoblocks easier to create.
The accumulated backTransfers can be read by the parentSC by calling the managedGetBackTransfers VM API.

Testing procedure

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

iulianpascalau and others added 30 commits October 6, 2022 14:35
…out-flags

only factory and sc processor V2 without flags - trying PRs
Trying new refactor branch - helping reviewers
# Conflicts:
#	process/smartContract/processProxy/processProxy.go
…tion

separated test proxy process from production one
# Conflicts:
#	process/smartContract/processProxy/processProxy.go
matei-p and others added 23 commits May 24, 2023 20:44
# Conflicts:
#	common/enablers/enableEpochsHandler.go
#	factory/processing/blockProcessorCreator.go
#	genesis/errors.go
#	go.mod
#	go.sum
#	integrationTests/testInitializer.go
#	integrationTests/testSyncNode.go
#	integrationTests/vm/testInitializer.go
#	integrationTests/vm/txsFee/asyncCall_test.go
#	integrationTests/vm/txsFee/relayedBuiltInFunctions_test.go
#	integrationTests/vm/wasm/wasmvm/wasmVM_test.go
#	process/block/baseProcess_test.go
#	process/block/export_test.go
#	process/block/metablock_test.go
#	process/block/shardblock_test.go
#	process/smartContract/process_test.go
# Conflicts:
#	common/enablers/enableEpochsHandler.go
#	genesis/process/genesisBlockCreator.go
#	go.mod
#	go.sum
#	integrationTests/testProcessorNode.go
#	process/transaction/shardProcess_test.go
@sasurobert sasurobert marked this pull request as ready for review June 21, 2023 13:18
Copy link
Collaborator

@gabi-vuls gabi-vuls left a comment

Choose a reason for hiding this comment

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

System test passed.

@sasurobert sasurobert merged commit 82fe42f into rc/v1.6.0 Jun 26, 2023
6 checks passed
@sasurobert sasurobert deleted the feat/vm1.5 branch June 26, 2023 12:46
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

9 participants