mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
feat(core/vm): modexp precompiled support also less than 32-bytes inputs (#393)
* modexp support 32-bytes or less inputs * change revert string * bump version --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
This commit is contained in:
parent
2dcc60a082
commit
5eac3a73bc
6 changed files with 38 additions and 20 deletions
|
|
@ -36,7 +36,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errPrecompileDisabled = errors.New("sha256, ripemd160, blake2f precompiles temporarily disabled")
|
errPrecompileDisabled = errors.New("sha256, ripemd160, blake2f precompiles temporarily disabled")
|
||||||
errModexpUnsupportedInput = errors.New("modexp temporarily accepts only 32-byte (256-bit) inputs")
|
errModexpUnsupportedInput = errors.New("modexp temporarily only accepts inputs of 32 bytes (256 bits) or less")
|
||||||
)
|
)
|
||||||
|
|
||||||
// PrecompiledContract is the basic interface for native Go contracts. The implementation
|
// PrecompiledContract is the basic interface for native Go contracts. The implementation
|
||||||
|
|
@ -411,8 +411,8 @@ func (c *bigModExp) Run(input []byte) ([]byte, error) {
|
||||||
expLen = new(big.Int).SetBytes(getData(input, 32, 32)).Uint64()
|
expLen = new(big.Int).SetBytes(getData(input, 32, 32)).Uint64()
|
||||||
modLen = new(big.Int).SetBytes(getData(input, 64, 32)).Uint64()
|
modLen = new(big.Int).SetBytes(getData(input, 64, 32)).Uint64()
|
||||||
)
|
)
|
||||||
// Check that all inputs are `u256` (32 - bytes), revert otherwise
|
// Check that all inputs are `u256` (32 - bytes) or less, revert otherwise
|
||||||
if baseLen != 32 || expLen != 32 || modLen != 32 {
|
if baseLen > 32 || expLen > 32 || modLen > 32 {
|
||||||
return nil, errModexpUnsupportedInput
|
return nil, errModexpUnsupportedInput
|
||||||
}
|
}
|
||||||
if len(input) > 96 {
|
if len(input) > 96 {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,7 @@
|
||||||
[
|
[
|
||||||
{
|
|
||||||
"Input": "000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020",
|
|
||||||
"ExpectedError": "modexp temporarily accepts only 32-byte (256-bit) inputs",
|
|
||||||
"Name": "too small input"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"Input": "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020",
|
"Input": "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020",
|
||||||
"ExpectedError": "modexp temporarily accepts only 32-byte (256-bit) inputs",
|
"ExpectedError": "modexp temporarily only accepts inputs of 32 bytes (256 bits) or less",
|
||||||
"Name": "too big input"
|
"Name": "too big input"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -1,12 +1,7 @@
|
||||||
[
|
[
|
||||||
{
|
|
||||||
"Input": "000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020",
|
|
||||||
"ExpectedError": "modexp temporarily accepts only 32-byte (256-bit) inputs",
|
|
||||||
"Name": "too small input"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"Input": "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020",
|
"Input": "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020",
|
||||||
"ExpectedError": "modexp temporarily accepts only 32-byte (256-bit) inputs",
|
"ExpectedError": "modexp temporarily only accepts inputs of 32 bytes (256 bits) or less",
|
||||||
"Name": "too big input"
|
"Name": "too big input"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
18
core/vm/testdata/precompiles/modexp.json
vendored
18
core/vm/testdata/precompiles/modexp.json
vendored
|
|
@ -1,16 +1,30 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"Input": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
"Input": "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
||||||
"Expected": "0000000000000000000000000000000000000000000000000000000000000001",
|
"Expected": "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
"Name": "eip_example1",
|
"Name": "eip_example1",
|
||||||
"Gas": 13056,
|
"Gas": 13056,
|
||||||
"NoBenchmark": false
|
"NoBenchmark": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Input": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
"Input": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
||||||
"Expected": "0000000000000000000000000000000000000000000000000000000000000000",
|
"Expected": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
"Name": "eip_example2",
|
"Name": "eip_example2",
|
||||||
"Gas": 13056,
|
"Gas": 13056,
|
||||||
"NoBenchmark": false
|
"NoBenchmark": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Input": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
||||||
|
"Expected": "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
|
"Name": "eip_example3",
|
||||||
|
"Gas": 13056,
|
||||||
|
"NoBenchmark": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Input": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
||||||
|
"Expected": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"Name": "eip_example4",
|
||||||
|
"Gas": 13056,
|
||||||
|
"NoBenchmark": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
18
core/vm/testdata/precompiles/modexp_eip2565.json
vendored
18
core/vm/testdata/precompiles/modexp_eip2565.json
vendored
|
|
@ -1,16 +1,30 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"Input": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
"Input": "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
||||||
"Expected": "0000000000000000000000000000000000000000000000000000000000000001",
|
"Expected": "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
"Name": "eip_example1",
|
"Name": "eip_example1",
|
||||||
"Gas": 1360,
|
"Gas": 1360,
|
||||||
"NoBenchmark": false
|
"NoBenchmark": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Input": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
"Input": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
||||||
"Expected": "0000000000000000000000000000000000000000000000000000000000000000",
|
"Expected": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
"Name": "eip_example2",
|
"Name": "eip_example2",
|
||||||
"Gas": 1360,
|
"Gas": 1360,
|
||||||
"NoBenchmark": false
|
"NoBenchmark": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Input": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
||||||
|
"Expected": "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
|
"Name": "eip_example3",
|
||||||
|
"Gas": 1360,
|
||||||
|
"NoBenchmark": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Input": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
|
||||||
|
"Expected": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"Name": "eip_example4",
|
||||||
|
"Gas": 1360,
|
||||||
|
"NoBenchmark": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 4 // Major version component of the current release
|
VersionMajor = 4 // Major version component of the current release
|
||||||
VersionMinor = 2 // Minor version component of the current release
|
VersionMinor = 2 // Minor version component of the current release
|
||||||
VersionPatch = 8 // Patch version component of the current release
|
VersionPatch = 9 // Patch version component of the current release
|
||||||
VersionMeta = "sepolia" // Version metadata to append to the version string
|
VersionMeta = "sepolia" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue