Skip to content

Commit

Permalink
Improve chunk calculation for ABI encoding string values
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Dec 19, 2023
1 parent 35f0505 commit 78f8094
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions fvm/evm/stdlib/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package stdlib
import (
_ "embed"
"fmt"
"math"
"math/big"
"reflect"
"regexp"
Expand Down Expand Up @@ -116,11 +117,7 @@ func reportABIEncodingComputation(
// value of the string itself.
computation := uint(2 * abiEncodingByteSize)
stringLength := len(value.Str)
chunks := stringLength / abiEncodingByteSize
remainder := stringLength % abiEncodingByteSize
if remainder > 0 {
chunks += 1
}
chunks := math.Ceil(float64(stringLength) / float64(abiEncodingByteSize))
computation += uint(chunks * abiEncodingByteSize)
reportComputation(environment.ComputationKindEVMEncodeABI, computation)
case interpreter.BoolValue,
Expand Down

0 comments on commit 78f8094

Please sign in to comment.