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 async v3 #892

Draft
wants to merge 22 commits into
base: rc/barnard
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8ea3608
start with refactoring some ugly if's.
sasurobert Feb 6, 2024
33f2198
resolving todo's
sasurobert Feb 7, 2024
67c6683
fix
sasurobert Feb 14, 2024
60ba90e
Merge pull request #827 from multiversx/v1.7-to-asnyc-v3-14-feb
sasurobert Feb 14, 2024
e68ef25
Merge branch 'feat/async-v3' into refactor-asyncComposability
sasurobert Feb 14, 2024
5a655bc
Merge branch 'feat/async-v3' into refactor-asyncComposability
sasurobert Feb 14, 2024
ef67c62
Merge remote-tracking branch 'origin/rc/v1.7.next1' into v1.7-to-asny…
laurci Mar 28, 2024
2c0c3fd
Merge pull request #839 from multiversx/v1.7-to-async-v3-28-mar
sasurobert Mar 28, 2024
1cb1def
Merge branch 'feat/async-v3' into refactor-asyncComposability
laurci Mar 28, 2024
76ddb2c
refactor output in case of error for async callback and empty functio…
laurci Apr 5, 2024
c9ba5b7
refactor output in case of error for async callback
laurci Apr 5, 2024
f2a6004
refactor output in case of error for async callback
laurci Apr 5, 2024
3a2719c
Add AsyncV3 flag
laurci Apr 11, 2024
6adf736
Add test for output in case of error of async callback
laurci Apr 11, 2024
a0e8e84
Remove redundant output stack operations and guard deleteion by Async…
laurci Apr 11, 2024
bbee461
A bit of cleanup
laurci Apr 11, 2024
c4854af
AsyncV3Flag swap order
laurci Apr 12, 2024
d5b3efd
Merge pull request #840 from multiversx/refactor-async-composability-…
sasurobert Apr 12, 2024
eb6ecaa
async v3 callback order
laurci May 20, 2024
db0b7d8
store gas locked for pending callbacks
laurci May 20, 2024
c0d73ed
Merge remote-tracking branch 'origin/rc/barnard' into async-v3
laurci Oct 30, 2024
510746f
libvmexeccapi merge fix
laurci Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ clean:
build:
go build ./...

gen-async:
protoc -I=./vmhost -I=${GOPATH}/src -I=${GOPATH}/src/github.com/multiversx/protobuf/protobuf -I=${GOPATH}/src/github.com/gogo/protobuf --gogoslick_out=./vmhost ./vmhost/asyncCall.proto

vmserver:
ifndef VMSERVER_PATH
$(error VMSERVER_PATH is undefined)
Expand Down
1 change: 1 addition & 0 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
AsyncCallStep = 10
AsyncCallbackGasLock = 10
CreateAsyncCall = 10
CreateAsyncV3Call = 10
SetAsyncCallback = 10
SetAsyncGroupCallback = 10
SetAsyncContextCallback = 10
Expand Down
1 change: 1 addition & 0 deletions config/gasCost.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type BaseOpsAPICost struct {
AsyncCallStep uint64
AsyncCallbackGasLock uint64
CreateAsyncCall uint64
CreateAsyncV3Call uint64
SetAsyncCallback uint64
SetAsyncGroupCallback uint64
SetAsyncContextCallback uint64
Expand Down
1 change: 1 addition & 0 deletions config/gasSchedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ func FillGasMapBaseOpsAPICosts(value, asyncCallbackGasLock uint64) map[string]ui
gasMap["AsyncCallStep"] = value
gasMap["AsyncCallbackGasLock"] = asyncCallbackGasLock
gasMap["CreateAsyncCall"] = value
gasMap["CreateAsyncV3Call"] = value
gasMap["SetAsyncCallback"] = value
gasMap["SetAsyncGroupCallback"] = value
gasMap["SetAsyncContextCallback"] = value
Expand Down
1 change: 1 addition & 0 deletions executor/vmHooks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions executor/wrapper/wrapperVMHooks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mock/context/executorMockFunc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion scenario/gasSchedules/gasSchedules.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package gasschedules

// TODO: go:embed can be used after we upgrade to go 1.16
// import _ "embed"

// //go:embed gasScheduleV1.toml
Expand Down
1 change: 0 additions & 1 deletion test/contracts/erc20/erc20.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ void computeAllowanceKey(byte *destination, byte *from, byte* to) {
// Note: in smart contract addresses, the first 10 bytes are all 0
// therefore we read from byte 10 onwards to provide more significant bytes
// and to minimize the chance for collisions
// TODO: switching to a hash instead of a concatenation of addresses might make it safer
for (int i = 0; i < 15; i++) {
destination[1+i] = from[10+i];
}
Expand Down
83 changes: 51 additions & 32 deletions vmhost/asyncCall.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,28 @@ type AsyncCall struct {
CallbackClosure []byte

IsBuiltinFunctionCall bool
IsAsyncV3 bool

HasPendingCallback bool
PendingCallbackGasLocked uint64
}

// Clone creates a deep clone of the AsyncCall
func (ac *AsyncCall) Clone() *AsyncCall {
clone := &AsyncCall{
CallID: ac.CallID,
Status: ac.Status,
ExecutionMode: ac.ExecutionMode,
Destination: make([]byte, len(ac.Destination)),
Data: make([]byte, len(ac.Data)),
GasLimit: ac.GasLimit,
GasLocked: ac.GasLocked,
ValueBytes: make([]byte, len(ac.ValueBytes)),
SuccessCallback: ac.SuccessCallback,
ErrorCallback: ac.ErrorCallback,
CallID: ac.CallID,
Status: ac.Status,
ExecutionMode: ac.ExecutionMode,
Destination: make([]byte, len(ac.Destination)),
Data: make([]byte, len(ac.Data)),
GasLimit: ac.GasLimit,
GasLocked: ac.GasLocked,
ValueBytes: make([]byte, len(ac.ValueBytes)),
SuccessCallback: ac.SuccessCallback,
ErrorCallback: ac.ErrorCallback,
IsAsyncV3: ac.IsAsyncV3,
HasPendingCallback: ac.HasPendingCallback,
PendingCallbackGasLocked: ac.PendingCallbackGasLocked,
}

copy(clone.Destination, ac.Destination)
Expand Down Expand Up @@ -105,6 +112,12 @@ func (ac *AsyncCall) HasDefinedAnyCallback() bool {
return len(ac.SuccessCallback) > 0 || len(ac.ErrorCallback) > 0
}

// MarkSkippedCallback this async call has skipped calling its callback
func (ac *AsyncCall) MarkSkippedCallback(pendingGasLock uint64) {
ac.HasPendingCallback = true
ac.PendingCallbackGasLocked = pendingGasLock
}

// UpdateStatus sets the status of the async call depending on the provided ReturnCode
func (ac *AsyncCall) UpdateStatus(returnCode vmcommon.ReturnCode) {
ac.Status = AsyncCallResolved
Expand Down Expand Up @@ -135,17 +148,20 @@ func (ac *AsyncCall) IsInterfaceNil() bool {

func (ac *AsyncCall) toSerializable() *SerializableAsyncCall {
return &SerializableAsyncCall{
CallID: ac.CallID,
Status: SerializableAsyncCallStatus(ac.Status),
ExecutionMode: SerializableAsyncCallExecutionMode(ac.ExecutionMode),
Destination: ac.Destination,
Data: ac.Data,
GasLimit: ac.GasLimit,
GasLocked: ac.GasLocked,
ValueBytes: ac.ValueBytes,
SuccessCallback: ac.SuccessCallback,
ErrorCallback: ac.ErrorCallback,
CallbackClosure: ac.CallbackClosure,
CallID: ac.CallID,
Status: SerializableAsyncCallStatus(ac.Status),
ExecutionMode: SerializableAsyncCallExecutionMode(ac.ExecutionMode),
Destination: ac.Destination,
Data: ac.Data,
GasLimit: ac.GasLimit,
GasLocked: ac.GasLocked,
ValueBytes: ac.ValueBytes,
SuccessCallback: ac.SuccessCallback,
ErrorCallback: ac.ErrorCallback,
CallbackClosure: ac.CallbackClosure,
IsAsyncV3: ac.IsAsyncV3,
HasPendingCallback: ac.HasPendingCallback,
PendingCallbackGasLocked: ac.PendingCallbackGasLocked,
}
}

Expand All @@ -159,16 +175,19 @@ func fromSerializableAsyncCalls(serializableAsyncCalls []*SerializableAsyncCall)

func (serAsyncCall *SerializableAsyncCall) fromSerializable() *AsyncCall {
return &AsyncCall{
CallID: serAsyncCall.CallID,
Status: AsyncCallStatus(serAsyncCall.Status),
ExecutionMode: AsyncCallExecutionMode(serAsyncCall.ExecutionMode),
Destination: serAsyncCall.Destination,
Data: serAsyncCall.Data,
GasLimit: serAsyncCall.GasLimit,
GasLocked: serAsyncCall.GasLocked,
ValueBytes: serAsyncCall.ValueBytes,
SuccessCallback: serAsyncCall.SuccessCallback,
ErrorCallback: serAsyncCall.ErrorCallback,
CallbackClosure: serAsyncCall.CallbackClosure,
CallID: serAsyncCall.CallID,
Status: AsyncCallStatus(serAsyncCall.Status),
ExecutionMode: AsyncCallExecutionMode(serAsyncCall.ExecutionMode),
Destination: serAsyncCall.Destination,
Data: serAsyncCall.Data,
GasLimit: serAsyncCall.GasLimit,
GasLocked: serAsyncCall.GasLocked,
ValueBytes: serAsyncCall.ValueBytes,
SuccessCallback: serAsyncCall.SuccessCallback,
ErrorCallback: serAsyncCall.ErrorCallback,
CallbackClosure: serAsyncCall.CallbackClosure,
IsAsyncV3: serAsyncCall.IsAsyncV3,
HasPendingCallback: serAsyncCall.HasPendingCallback,
PendingCallbackGasLocked: serAsyncCall.PendingCallbackGasLocked,
}
}
Loading
Loading