I also just merged this too: Consider dropping the VM number length limit · Issue #1 · bitjson/bch-bigint · GitHub (thanks for opening @bitcoincashautist!)
Going to copy the latest rationale:
Removal of Number Length Limit
With the activation of the Arithmetic Operation Cost Limit, the additional limitation on VM number length has no impact on worst-case transaction validation performance (see Tests & Benchmarks). This proposal removes the limit, allowing valid VM numbers to extend to the stack element size limit (A.K.A. MAX_SCRIPT_ELEMENT_SIZE
) of 10,000 bytes. See CHIP: Targeted Virtual Machine Limits
.
Alternatively, this proposal could raise the limit to a higher constant value like 258
, the constant selected by Satoshi Nakamoto in reverted makefile.unix wx-config -- version 0.3.6
(July 29, 2010). However, because the limit is no longer necessary for mitigating worst-case transaction validation cost, selection of any particular constant would be arbitrary.
By fully-removing the limit, overall protocol complexity is reduced, simplifying both future VM implementations and contract development. For VM implementations, eliminating out-of-range cases significantly reduces the combinatorial set of possible inputs and outputs for the numeric operations: OP_1ADD
(0x8b
), OP_1SUB
(0x8c
), OP_NEGATE
(0x8f
), OP_ABS
(0x90
), OP_NOT
(0x91
), OP_0NOTEQUAL
(0x92
), OP_ADD
(0x93
), OP_SUB
(0x94
), OP_MUL
(0x95
), OP_DIV
(0x96
), OP_MOD
(0x97
), OP_BOOLAND
(0x9a
), OP_BOOLOR
(0x9b
), OP_NUMEQUAL
(0x9c
), OP_NUMEQUALVERIFY
(0x9d
), OP_NUMNOTEQUAL
(0x9e
), OP_LESSTHAN
(0x9f
), OP_GREATERTHAN
(0xa0
), OP_LESSTHANOREQUAL
(0xa1
), OP_GREATERTHANOREQUAL
(0xa2
), OP_MIN
(0xa3
), OP_MAX
(0xa4
), and OP_WITHIN
(0xa5
). For contract authors, eliminating the possibility of out-of-range errors prevents a class of potential vulnerabilities arising from a contract system’s failure to validate that intermediate arithmetic results never exceed an (uncommonly-encountered) maximum number length limit.
Non-Inclusion of Implementation-Specific Technical Details
This proposal specifies only the necessary change to the consensus protocol: removal of the number length limit.
The software changes required to support this consensus change differ significantly from implementation to implementation. VM implementations which already internally use arbitrary-precision arithmetic for VM number manipulation may only need to disable code enforcing the previous limit, while other implementations may be required to integrate an arbitrary-precision arithmetic library or language primitive. In all cases, implementations should verify their functional behavior and performance characteristics against the Tests & Benchmarks.
Non-Inclusion of VM Number Format or Operation Descriptions
Beyond dropping the unnecessary limit on VM number length, this proposal does not modify any other properties of the VM. Notably, the precise format and behavior of VM numbers across all VM operations – especially OP_1ADD
(0x8b
), OP_1SUB
(0x8c
), OP_NEGATE
(0x8f
), OP_ABS
(0x90
), OP_NOT
(0x91
), OP_0NOTEQUAL
(0x92
), OP_ADD
(0x93
), OP_SUB
(0x94
), OP_MUL
(0x95
), OP_DIV
(0x96
), OP_MOD
(0x97
), OP_BOOLAND
(0x9a
), OP_BOOLOR
(0x9b
), OP_NUMEQUAL
(0x9c
), OP_NUMEQUALVERIFY
(0x9d
), OP_NUMNOTEQUAL
(0x9e
), OP_LESSTHAN
(0x9f
), OP_GREATERTHAN
(0xa0
), OP_LESSTHANOREQUAL
(0xa1
), OP_GREATERTHANOREQUAL
(0xa2
), OP_MIN
(0xa3
), OP_MAX
(0xa4
), and OP_WITHIN
(0xa5
) – are part of network consensus and do not otherwise change as a result of this proposal. For the avoidance of doubt, see the Tests & Benchmarks.