Skip to content

Commit

Permalink
Merge pull request #303 from aergoio/topic/increase-max-events
Browse files Browse the repository at this point in the history
increase max events per txn
  • Loading branch information
kroggen authored May 17, 2024
2 parents 97bae14 + dc1ed72 commit fac5f47
Showing 1 changed file with 12 additions and 3 deletions.
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 @@ -1293,8 +1302,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

0 comments on commit fac5f47

Please sign in to comment.