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

BlockHeaderRegistry #123

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

BlockHeaderRegistry #123

wants to merge 14 commits into from

Conversation

pmlambert
Copy link

No description provided.

@pmlambert pmlambert marked this pull request as ready for review March 25, 2022 07:49
@pmlambert
Copy link
Author

@leonprou I believe I'm supposed to sync up with you to figure out exactly how to structure the runtime logic for the changes. Everything works here, I just need to know exactly where you guys want to go with this feature. For example, who can submit signatures for which blocks (are cycles important), can validators submit signatures for multiple blocks at the same height, how many blocks should be confirmed before submitting the signatures, etc.

Copy link

@sirpy sirpy left a comment

Choose a reason for hiding this comment

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

  1. contracts should not be here, they are irrelevant to the fuseapp
  2. what are all the changes to fuseapp files not related to the bridge?
  3. you are missing unit tests for the fuseapp bridge part, it is part of the bounty requirements
  4. By default fuse+ethereum+bsc are always enabled no matter if they are in the list or not

app/index.js Outdated Show resolved Hide resolved
app/index.js Outdated Show resolved Hide resolved
app/index.js Outdated Show resolved Hide resolved
app/index.js Outdated Show resolved Hide resolved
scripts/quickstart.sh Outdated Show resolved Hide resolved
app/index.js Outdated Show resolved Hide resolved
Dockerfile.spark Outdated Show resolved Hide resolved
@sirpy
Copy link

sirpy commented May 9, 2022

  • contracts should not be here, they are irrelevant to the fuseapp
  • what are all the changes to fuseapp files not related to the bridge?
  • you are missing unit tests for the fuseapp bridge part, it is part of the bounty requirements
  • By default fuse+ethereum+bsc are always enabled no matter if they are in the list or not

@pmlambert you missed the comment above

You are still not handling errors correctly in the .subscribe, better extract the whole .subscribe callback to a function

app/index.js Outdated
logger.info('emitRegistry')
const currentBlock = (await web3.eth.getBlockNumber()).toNumber()
const chains = await blockRegistry.methods.getRpcs.call()
await Promise.all(chains.filter(chain => !blockchains[chain[0]] || blockchains[chain[0]].rpc != chain[1]).map(async (chain) => initBlockchain(...chain)))
Copy link

Choose a reason for hiding this comment

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

if one initblockchain fail it shouldnt fail the whole function

Copy link

Choose a reason for hiding this comment

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

still not done

app/index.js Outdated
Comment on lines 51 to 60
if (chainId == 122) {
let cycleEnd = (await consensus.methods.getCurrentCycleEndBlock.call()).toNumber()
let validators = await consensus.methods.currentValidators().call()
const numValidators = validators.length
blockchains[chainId].blocks[block.hash] = await signFuse(block, chainId, blockchain.provider, blockchain.signer, cycleEnd, validators)
}
else {
blockchains[chainId].blocks[block.hash] = await sign(block, chainId, blockchain.provider, blockchain.signer)
}
})
Copy link

Choose a reason for hiding this comment

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

handle exceptions and extract to a function

@pmlambert
Copy link
Author

  1. contracts should not be here, they are irrelevant to the fuseapp
    Deleted
  2. what are all the changes to fuseapp files not related to the bridge?
    From using rebase, has been fixed
  3. you are missing unit tests for the fuseapp bridge part, it is part of the bounty requirements
    That is step 3, this is for parts 1 and 2
  4. By default fuse+ethereum+bsc are always enabled no matter if they are in the list or not
    Changed to use env keys ETH,BSC _RPC

@sirpy
Copy link

sirpy commented May 9, 2022

  1. contracts should not be here, they are irrelevant to the fuseapp
    Deleted
  2. what are all the changes to fuseapp files not related to the bridge?
    From using rebase, has been fixed
  3. you are missing unit tests for the fuseapp bridge part, it is part of the bounty requirements
    That is step 3, this is for parts 1 and 2
  4. By default fuse+ethereum+bsc are always enabled no matter if they are in the list or not
    Changed to use env keys ETH,BSC _RPC

Every step has its own requirement for unit tests. you can check the bounty and check boxes again for each step.

app/index.js Outdated
logger.info(`initBlockRegistryContract`, process.env.BLOCK_REGISTRY_ADDRESS)
blockRegistry = new web3.eth.Contract(require(path.join(cwd, 'abi/blockRegistry')), process.env.BLOCK_REGISTRY_ADDRESS)
initBlockchain(1, process.env.ETH_RPC || throw "Missing ETH_RPC in environment")
initBlockchain(56, process.env.BSC_RPC || throw "Missing BSC_RPC in environment"))
Copy link

Choose a reason for hiding this comment

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

bsc has public rpc

app/index.js Outdated
function initBlockRegistryContract() {
logger.info(`initBlockRegistryContract`, process.env.BLOCK_REGISTRY_ADDRESS)
blockRegistry = new web3.eth.Contract(require(path.join(cwd, 'abi/blockRegistry')), process.env.BLOCK_REGISTRY_ADDRESS)
initBlockchain(1, process.env.ETH_RPC || throw "Missing ETH_RPC in environment")
Copy link

Choose a reason for hiding this comment

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

use cloudflare eth endpoint

app/index.js Outdated
logger.info('emitRegistry')
const currentBlock = (await web3.eth.getBlockNumber()).toNumber()
const chains = await blockRegistry.methods.getRpcs.call()
await Promise.all(chains.filter(chain => !blockchains[chain[0]] || blockchains[chain[0]].rpc != chain[1]).map(async (chain) => initBlockchain(...chain)))
Copy link

Choose a reason for hiding this comment

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

still not done

app/index.js Outdated
})
})
} catch(e) {
throw `emitRegistry failed trying to update rpcs`
Copy link

Choose a reason for hiding this comment

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

i dont think that should prevent from calling addSignedBlocks part

app/index.js Outdated
const isValidator = await consensus.methods.isValidator(web3.utils.toChecksumAddress(account)).call()
if (!isValidator) {
logger.warn(`${account} is not a validator, skipping`)
return
}
await emitInitiateChange()
await emitRewardedOnCycle()
await emitRegistry()
Copy link

Choose a reason for hiding this comment

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

i dont think an exception here should cause the fuseapp to exit

app/index.js Outdated
try {
logger.info('emitRegistry')
const currentBlock = (await web3.eth.getBlockNumber()).toNumber()
const chains = await blockRegistry.methods.getRpcs.call()
Copy link

Choose a reason for hiding this comment

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

should be getRpcs()
and that's why I want unit tests or testnet deployment with mock contracts to see that this whole process is working

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.

3 participants