Skip to content

Commit

Permalink
Remove rebase/merge regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke authored and holgerd77 committed Aug 12, 2020
1 parent 338974b commit 4a547c2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/vm/lib/evm/opFns.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BN = require('bn.js')
import * as utils from 'ethereumjs-util'
import { keccak256, setLengthRight, TWO_POW256, MAX_INTEGER, KECCAK256_NULL } from 'ethereumjs-util'
import { ERROR, VmError } from '../exceptions'
import { RunState } from './interpreter'

Expand Down Expand Up @@ -38,12 +38,12 @@ export const handlers: { [k: string]: OpHandler } = {
},
ADD: function (runState: RunState) {
const [a, b] = runState.stack.popN(2)
const r = a.add(b).mod(utils.TWO_POW256)
const r = a.add(b).mod(TWO_POW256)
runState.stack.push(r)
},
MUL: function (runState: RunState) {
const [a, b] = runState.stack.popN(2)
const r = a.mul(b).mod(utils.TWO_POW256)
const r = a.mul(b).mod(TWO_POW256)
runState.stack.push(r)
},
SUB: function (runState: RunState) {
Expand Down Expand Up @@ -137,7 +137,7 @@ export const handlers: { [k: string]: OpHandler } = {
runState.stack.push(new BN(0))
return
}
const m = BN.red(utils.TWO_POW256)
const m = BN.red(TWO_POW256)
const redBase = base.toRed(m)
const r = redBase.redPow(exponent)
runState.stack.push(r.fromRed())
Expand Down Expand Up @@ -226,7 +226,7 @@ export const handlers: { [k: string]: OpHandler } = {
return
}

const r = b.shln(a.toNumber()).iand(utils.MAX_INTEGER)
const r = b.shln(a.toNumber()).iand(MAX_INTEGER)
runState.stack.push(r)
},
SHR: function (runState: RunState) {
Expand All @@ -246,7 +246,7 @@ export const handlers: { [k: string]: OpHandler } = {
const isSigned = b.testn(255)
if (a.gten(256)) {
if (isSigned) {
r = new BN(utils.MAX_INTEGER)
r = new BN(MAX_INTEGER)
} else {
r = new BN(0)
}
Expand All @@ -257,7 +257,7 @@ export const handlers: { [k: string]: OpHandler } = {
const c = b.shrn(a.toNumber())
if (isSigned) {
const shiftedOutWidth = 255 - a.toNumber()
const mask = utils.MAX_INTEGER.shrn(shiftedOutWidth).shln(shiftedOutWidth)
const mask = MAX_INTEGER.shrn(shiftedOutWidth).shln(shiftedOutWidth)
r = c.ior(mask)
} else {
r = c
Expand All @@ -276,7 +276,7 @@ export const handlers: { [k: string]: OpHandler } = {
runState.eei.useGas(
new BN(runState._common.param('gasPrices', 'sha3Word')).imul(divCeil(length, new BN(32))),
)
const r = new BN(utils.keccak256(data))
const r = new BN(keccak256(data))
runState.stack.push(r)
},
// 0x30 range - closure state
Expand Down Expand Up @@ -308,7 +308,7 @@ export const handlers: { [k: string]: OpHandler } = {
const i = pos.toNumber()
let loaded = runState.eei.getCallData().slice(i, i + 32)
loaded = loaded.length ? loaded : Buffer.from([0])
const r = new BN(utils.setLengthRight(loaded, 32))
const r = new BN(setLengthRight(loaded, 32))

runState.stack.push(r)
},
Expand Down Expand Up @@ -382,11 +382,11 @@ export const handlers: { [k: string]: OpHandler } = {

const code = await runState.eei.getExternalCode(address)
if (code.length === 0) {
runState.stack.push(new BN(utils.KECCAK256_NULL))
runState.stack.push(new BN(KECCAK256_NULL))
return
}

runState.stack.push(new BN(utils.keccak256(code)))
runState.stack.push(new BN(keccak256(code)))
},
RETURNDATASIZE: function (runState: RunState) {
runState.stack.push(runState.eei.getReturnDataSize())
Expand Down Expand Up @@ -861,7 +861,7 @@ export const handlers: { [k: string]: OpHandler } = {
}

function describeLocation(runState: RunState) {
var hash = utils.keccak256(runState.eei.getCode()).toString('hex')
var hash = keccak256(runState.eei.getCode()).toString('hex')
var address = runState.eei.getAddress().toString('hex')
var pc = runState.programCounter - 1
return hash + '/' + address + ':' + pc
Expand Down Expand Up @@ -921,7 +921,7 @@ function getDataSlice(data: Buffer, offset: BN, length: BN): Buffer {

data = data.slice(offset.toNumber(), end.toNumber())
// Right-pad with zeros to fill dataLength bytes
data = utils.setLengthRight(data, length.toNumber())
data = setLengthRight(data, length.toNumber())

return data
}
Expand Down

0 comments on commit 4a547c2

Please sign in to comment.