Skip to content

Commit

Permalink
Merge pull request #6 from near/rinkeby
Browse files Browse the repository at this point in the history
Patch for rinkeby
  • Loading branch information
ailisp authored Sep 7, 2020
2 parents ad63e2b + d9e5aff commit 6fbd7ac
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
10 changes: 8 additions & 2 deletions eth-on-near-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const borshSchema = {
['hashes_gc_threshold', 'u64'],
['finalized_gc_threshold', 'u64'],
['num_confirmations', 'u64'],
['trusted_signer', '?AccountId']
],
},
dagMerkleRootInput: {
Expand Down Expand Up @@ -61,6 +62,10 @@ const borshSchema = {
kind: 'option',
type: 'H256',
},
'?AccountId': {
kind: 'option',
type: 'string',
}
}

class EthOnNearClientContract extends BorshContract {
Expand Down Expand Up @@ -116,13 +121,13 @@ class EthOnNearClientContract extends BorshContract {

// Call initialization methods on the contract.
// If validate_ethash is true will do ethash validation otherwise it won't.
async maybeInitialize(validate_ethash, robustWeb3) {
async maybeInitialize(validate_ethash, trusted_signer, robustWeb3) {
await this.accessKeyInit()
let initialized = false
try {
// @ts-ignore
initialized = await this.initialized()
} catch (e) {}
} catch (e) { }
if (!initialized) {
console.log('EthOnNearClient is not initialized, initializing...')
const last_block_number = await robustWeb3.getBlockNumber()
Expand All @@ -139,6 +144,7 @@ class EthOnNearClientContract extends BorshContract {
hashes_gc_threshold: 40000,
finalized_gc_threshold: 500,
num_confirmations: 10,
trusted_signer,
},
new BN('300000000000000')
)
Expand Down
3 changes: 2 additions & 1 deletion eth2near-relay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ function execute(command, _callback) {
}

function web3BlockToRlp(blockData) {
blockData.difficulty = parseInt(blockData.difficulty, 10)
// difficulty is only used and make sense in PoW network
blockData.difficulty = parseInt(blockData.difficulty || '0', 10)
blockData.totalDifficulty = parseInt(blockData.totalDifficulty, 10)
blockData.uncleHash = blockData.sha3Uncles
blockData.coinbase = blockData.miner
Expand Down
3 changes: 2 additions & 1 deletion init/near-contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class InitNearContracts {
const nearNodeUrl = RainbowConfig.getParam('near-node-url')
const nearNetworkId = RainbowConfig.getParam('near-network-id')
const validateEthash = RainbowConfig.getParam('near-client-validate-ethash')
const trustedSigner = RainbowConfig.getParam('near-client-trusted-signer')

const clientPk = nearlib.KeyPair.fromString(clientSk).getPublicKey()
const proverPk = nearlib.KeyPair.fromString(proverSk).getPublicKey()
Expand Down Expand Up @@ -97,7 +98,7 @@ class InitNearContracts {
clientAccount
)
const robustWeb3 = new RobustWeb3(RainbowConfig.getParam('eth-node-url'))
await clientContract.maybeInitialize(validateEthash === 'true', robustWeb3)
await clientContract.maybeInitialize(validateEthash === 'true', trustedSigner || null, robustWeb3)
const proverContract = new EthOnNearProverContract(
new nearlib.Account(near.connection, proverAccount),
proverAccount
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rainbow-bridge-lib",
"version": "1.0.1",
"version": "1.0.2",
"description": "lib lib",
"author": "Near Inc.",
"repository": {
Expand Down

0 comments on commit 6fbd7ac

Please sign in to comment.