Skip to content

Commit 9facf64

Browse files
authored
Merge pull request #14959 from karalabe/metropolis-precompiles
core/vm: metropolis precompiles
2 parents 2403656 + f8d8b56 commit 9facf64

7 files changed

Lines changed: 710 additions & 147 deletions

File tree

‎core/vm/common.go‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,21 @@ func calcMemSize(off, l *big.Int) *big.Int {
3434

3535
// getData returns a slice from the data based on the start and size and pads
3636
// up to size with zero's. This function is overflow safe.
37-
func getData(data []byte, start, size *big.Int) []byte {
37+
func getData(data []byte, start uint64, size uint64) []byte {
38+
length := uint64(len(data))
39+
if start > length {
40+
start = length
41+
}
42+
end := start + size
43+
if end > length {
44+
end = length
45+
}
46+
return common.RightPadBytes(data[start:end], int(size))
47+
}
48+
49+
// getDataBig returns a slice from the data based on the start and size and pads
50+
// up to size with zero's. This function is overflow safe.
51+
func getDataBig(data []byte, start *big.Int, size *big.Int) []byte {
3852
dlen := big.NewInt(int64(len(data)))
3953

4054
s := math.BigMin(start, dlen)

0 commit comments

Comments
 (0)