Skip to content

Instantly share code, notes, and snippets.

@leonprou
Created September 26, 2020 16:12
Show Gist options
  • Save leonprou/d87df893cb284a4bd15647492a7966c6 to your computer and use it in GitHub Desktop.
Save leonprou/d87df893cb284a4bd15647492a7966c6 to your computer and use it in GitHub Desktop.
Syncing Fuse with Ethereum.md
Clone the repo and install the dependencies
```
git clone https://github.com/fuseio/fuse-bridge
cd fuse-bridge
git checkout feature/find-not-relayed-messages
cd fuse-bridge/native-to-erc20/oracle
npm install
```
Fuse and Ethereum networks are connected via the bridge that relay messages from Fuse network to Ethereum.
The messages are update of validator set, Fuse tokens minting, or Fuse transfers.
Validator set updates and minting done on EoC (End of Cycle) on Fuse.
While the transfers happen when Fuse transferred between networks via the bridge.
To relay the message you're interested in to Ethereum, all signers of the message needs to be in the validator set on Ethereum.
If they're not, it means that more events in the past wasn't missed and you need to relay them before.
Good to notice: validator set event is fired on every EoC, and might not have any new validators.
In that case that event can be skiped and doesn't need to be relayed to Ethereum, as it doesn't introduce new data.
Look into the file `src/tx/cycle.js`. It is used both to look for the messages and to relay them.
uncomment the funcion you intend execute and congifure the parameters, then run
```
node src/tx/cycle.js collected-signatures-watcher.config
```
@CrackerHax
Copy link

CrackerHax commented Sep 26, 2020

Added UserRequestForSignature so we can look for relayed fuse tokens

  if (event === 'SignedForUserRequest' || event === 'InitiateChange' || event === 'UserRequestForSignature') {
    events.forEach(event => console.log(event.returnValues))
    return events
  }

Also had to add event variable to relayMessages:

const relayMessages = async ({ fromBlock, toBlock, execute, isNewSetFilter, limit, event }) => {                                                                                                                                               
const config = require('../../config/collected-signatures-watcher.config')                                                                                                                                                                 
    const messages = (await getMessages({ fromBlock, toBlock, isNewSetFilter, isRelayedFilter: false, event })).slice(0, limit)   

Example:
getMessages({ fromBlock: 6680590, toBlock: 6680592, isRelayedFilter: false, isNewSetFilter: false, event: 'UserRequestForSignature' })
relayMessages({ fromBlock: 6680590, toBlock: 6680592, isRelayedFilter: false, isNewSetFilter: false, execute: true, event: 'UserRequestForSignature'})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment