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

increase max events per txn #303

Merged
merged 5 commits into from
May 17, 2024
Merged
Changes from all commits
Commits
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
15 changes: 12 additions & 3 deletions contract/vm_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ var (
)

const (
maxEventCnt = 50
maxEventCntV2 = 50
maxEventCntV4 = 128
maxEventNameSize = 64
maxEventArgSize = 4096
luaCallCountDeduc = 1000
Expand All @@ -66,6 +67,14 @@ func init() {
zeroBig = types.NewZeroAmount()
}

func maxEventCnt(ctx *vmContext) int32 {
if ctx.blockInfo.ForkVersion >= 4 {
return maxEventCntV4
} else {
return maxEventCntV2
}
}

//export luaSetDB
func luaSetDB(L *LState, service C.int, key unsafe.Pointer, keyLen C.int, value *C.char) *C.char {
ctx := contexts[service]
Expand Down Expand Up @@ -1239,8 +1248,8 @@ func luaEvent(L *LState, service C.int, eventName *C.char, args *C.char) *C.char
if ctx.isQuery == true || ctx.nestedView > 0 {
return C.CString("[Contract.Event] event not permitted in query")
}
if ctx.eventCount >= maxEventCnt {
return C.CString(fmt.Sprintf("[Contract.Event] exceeded the maximum number of events(%d)", maxEventCnt))
if ctx.eventCount >= maxEventCnt(ctx) {
return C.CString(fmt.Sprintf("[Contract.Event] exceeded the maximum number of events(%d)", maxEventCnt(ctx)))
}
if len(C.GoString(eventName)) > maxEventNameSize {
return C.CString(fmt.Sprintf("[Contract.Event] exceeded the maximum length of event name(%d)", maxEventNameSize))
Expand Down
Loading