Skip to content

Conversation

@k06a
Copy link

@k06a k06a commented Feb 15, 2020

Allows to use with any network. We serialise web3js header to rlp with this code:

const blockFromRpc = require('ethereumjs-block/from-rpc')
const utils = require('ethereumjs-util');

function web3BlockToRlp(blockData) {
    blockData.difficulty = parseInt(blockData.difficulty, 10);
    blockData.totalDifficulty = parseInt(blockData.totalDifficulty, 10);
    blockData.uncleHash = blockData.sha3Uncles;
    blockData.coinbase = blockData.miner;
    blockData.transactionTrie = blockData.transactionsRoot;
    blockData.receiptTrie = blockData.receiptsRoot;
    blockData.bloom = blockData.logsBloom;
    const blockHeader = blockFromRpc(blockData);
    return utils.rlp.encode(blockHeader.header.raw);
}

const blockRlpHex = web3.utils.bytesToHex(web3BlockToRlp(await web3.eth.getBlock(blockNumber)));
const proof = JSON.parse(await execute(`./ethashproof/cmd/relayer/relayer ${blockRlpHex} | sed -e '1,/Json output/d'`));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant