Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Repro for Geth 1.8.x `` regression
#!/usr/bin/env node
const Child_process = require('child_process')
const Web3 = require('web3')
const Assert = require('assert')
const SOL = `
contract BS {
function isValidSignature(
address signer,
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s)
returns (bool)
return signer == ecrecover(
keccak256("\\x19Ethereum Signed Message:\\n32", hash),
function ecRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public constant returns(address) {
return ecrecover(hash,v,r,s);
function keccak(bytes32 hash) public constant returns(bytes32) {
return keccak256(hash);
function keccakX(bytes32 hash) public constant returns(bytes32) {
return keccak256("\\x19Ethereum Signed Message:\\n32", hash);
async function run () {
// Compile bs.sol first
const child = Child_process.spawnSync("solc",['-', '--combined-json', 'abi,bin'],
{input: SOL, encoding: "utf8"})
Assert.strictEqual(child.status, 0, child.output[2])
const contracts = Object.values(JSON.parse(child.output[1]).contracts)
const web3 = new Web3('http://localhost:8545')
const addresses = await web3.eth.personal.getAccounts()
Assert.ok(addresses[0], "Need address[0] for deployment")
console.log("Deploying with", addresses[0])
const balance = await web3.eth.getBalance(addresses[0])
Assert.ok(balance > 0, "Need some ether for deployment")
const abi = JSON.parse(contracts[0].abi)
const contract = await new web3.eth.Contract(abi, null)
.deploy({data: "0x"+contracts[0].bin})
.send({from: addresses[0], gas: 1000000})
const maker = "0xc1b70e056bc09c33d7d0f668bd49e69c6d1a74d0"
const rnd = "0x7e568cb5eedc46ac087c6a291e108dd621f1569893269b478caf31658ce0568a"
console.log("Test keccak256 call")
const result = await contract.methods.keccak(rnd).call()
const hash = web3.utils.keccak256(rnd)
Assert.strictEqual(hash, result)
console.log("Test keccak256 call with multiple args")
const result2 = await contract.methods.keccakX(rnd).call()
const hash2 = web3.utils.soliditySha3("\x19Ethereum Signed Message:\n32", rnd)
Assert.strictEqual(hash2, result2)
const [h,v,r,s] = [
console.log("Test ecrecover transaction")
const tx = await contract.methods.ecRecover(h,v,r,s).send({from:addresses[0]})
Assert.equal(tx.status, 1)
console.log("Test ecrecover call")
const result3 = await contract.methods.ecRecover(h,v,r,s).call()
Assert.strictEqual("0xF23978a1fE45225D5E28C6730a5BD82D7e37865f", result3)
console.log("Test keccak256+ecrecover call")
const result4 = await contract.methods.isValidSignature(maker,h,v,r,s).call()
Assert.strictEqual(true, result4)
run().catch(err => {
process.exitCode = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment