Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change relay arg from block number to block rlp #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

k06a
Copy link

@k06a k06a commented Feb 16, 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'`));

@k06a k06a requested a review from tranvictor February 16, 2020 20:18
Copy link
Owner

@tranvictor tranvictor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working with the block itself instead of the block number is a good idea, however, I think we better make another command line for that instead of changing this one.

@tranvictor tranvictor self-requested a review April 17, 2020 04:08
@tranvictor
Copy link
Owner

@k06a can you take a look at my comment and change accordingly?

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.

2 participants