Applying new parameter counting rule.
New rule for counting input parameter size was defined in ICON.
It's just counting bytes of UTF8 encoded compact JSON.
@@ -13,11 +13,13 @@ import (
"github.com/icon-project/goloop/common/crypto"
"github.com/icon-project/goloop/module"
"github.com/icon-project/goloop/service/contract"
+ "github.com/icon-project/goloop/service/scoreresult"
"github.com/icon-project/goloop/service/state"
)
const (
txMaxDataSize = 512 * 1024 // 512kB
+ configUseInputCoutingCompactJSON = true
)
type transactionV3Data struct {
@@ -415,6 +417,13 @@ func countBytesOfData(data []byte) (int, error) {
return 0, nil
}
+ if configUseInputCoutingCompactJSON {
+ b := bytes.NewBuffer(nil)
+ if err := json.Compact(b, data); err != nil {
+ return 0, scoreresult.ErrInvalidParameter
+ }
+ return b.Len(), nil
+ } else {
var idata interface{}
if err := json.Unmarshal(data, &idata); err != nil {
return 0, err
@@ -422,6 +431,7 @@ func countBytesOfData(data []byte) (int, error) {
return countBytesOfDataValue(idata), nil
}
}
+}
func countBytesOfDataValue(v interface{}) int {
switch o := v.(type) {
