Skip to content

Commit d384e05

Browse files
committed
vm: increase BigInt parsing precision
Follow the neo-project/neo#2883. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
1 parent afa4530 commit d384e05

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pkg/vm/stackitem/json.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const MaxAllowedInteger = 2<<53 - 1
2727
const MaxJSONDepth = 10
2828

2929
// MaxIntegerPrec is the maximum precision allowed for big.Integer parsing.
30-
// It equals to the reference value and doesn't allow to precisely parse big
31-
// numbers, see the https://github.com/neo-project/neo/issues/2879.
32-
const MaxIntegerPrec = 53
30+
// It allows to properly parse integer numbers that our 256-bit VM is able to
31+
// handle.
32+
const MaxIntegerPrec = 1<<8 + 1
3333

3434
// ErrInvalidValue is returned when an item value doesn't fit some constraints
3535
// during serialization or deserialization.

pkg/vm/stackitem/json_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ func TestFromToJSON(t *testing.T) {
134134
// the C# one, ref. https://github.com/neo-project/neo/issues/2879.
135135
func TestFromJSON_CompatBigInt(t *testing.T) {
136136
tcs := map[string]string{
137-
`9.05e+28`: "90499999999999993918259200000",
137+
`9.05e+28`: "90500000000000000000000000000",
138138
`1.871e+21`: "1871000000000000000000",
139-
`3.0366e+32`: "303660000000000004445016810323968",
140-
`1e+30`: "1000000000000000019884624838656",
139+
`3.0366e+32`: "303660000000000000000000000000000",
140+
`1e+30`: "1000000000000000000000000000000",
141141
}
142142
for in, expected := range tcs {
143143
t.Run(in, func(t *testing.T) {

0 commit comments

Comments
 (0)