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

[Testnet] NearOnEth client: increase max num of BPs. Near2Eth-relayer improvements #652

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/eth/nearbridge/contracts/NearBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract NearBridge is INearBridge, AdminControlled {
using NearDecoder for Borsh.Data;

// Assumed to be even and to not exceed 256.
uint constant MAX_BLOCK_PRODUCERS = 100;
uint constant MAX_BLOCK_PRODUCERS = 140;

struct Epoch {
bytes32 epochId;
Expand Down
10 changes: 7 additions & 3 deletions near2eth/near2eth-block-relay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ class Near2EthRelay {
// Get most recent block from Near blockchain.
const status = await this.near.connection.provider.status()
// Get the block two blocks before that, to make sure it is final.
const blockId = status.sync_info.latest_block_height - 2;
const headBlock = await this.near.connection.provider.block({
blockId: status.sync_info.latest_block_height
blockId: blockId
})
console.log(`Initializing with head block at: ${blockId}`);
const lastFinalBlockHash = headBlock.header.last_final_block
// The finalized block is not immediately available so we wait for it to become available.
let lightClientBlock = null
Expand All @@ -90,6 +92,7 @@ class Near2EthRelay {
}
console.log('Initializing with validators')
console.log(`${JSON.stringify(currentValidators)}`)
console.log(`Num validators: ${currentValidators.length}`);
const borshInitialValidators = borshifyInitialValidators(
currentValidators
)
Expand All @@ -101,7 +104,7 @@ class Near2EthRelay {
.initWithValidators(borshInitialValidators)
.send({
from: this.ethMasterAccount,
gas: 4000000,
gas: 6000000,
handleRevert: true,
gasPrice
})
Expand All @@ -122,12 +125,13 @@ class Near2EthRelay {

console.log('Initializing with block')
console.log(`${JSON.stringify(lightClientBlock)}`)
console.log(`Num validators: ${lightClientBlock.next_bps.length}`);
const borshBlock = borshify(lightClientBlock)
for (let i = 0; i < 10; i++) {
try {
await this.clientContract.methods.initWithBlock(borshBlock).send({
from: this.ethMasterAccount,
gas: 4000000,
gas: 6000000,
handleRevert: true,
gasPrice: new BN(await this.web3.eth.getGasPrice()).mul(
new BN(ethGasMultiplier)
Expand Down