Skip to content

Change relay arg from block number to block rlp#9

Open
k06a wants to merge 1 commit intotranvictor:masterfrom
nearprotocol:relay/rlpheader-arg
Open

Change relay arg from block number to block rlp#9
k06a wants to merge 1 commit intotranvictor:masterfrom
nearprotocol:relay/rlpheader-arg

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