Skip to content

Commit

Permalink
Merge pull request #151 from renproject/feat(watcher)/watch-solana-burns
Browse files Browse the repository at this point in the history
feat(watcher): watch solana burns
  • Loading branch information
jazg committed May 13, 2021
2 parents de95de8 + 4843f25 commit d755883
Show file tree
Hide file tree
Showing 7 changed files with 386 additions and 49 deletions.
38 changes: 29 additions & 9 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ on: [push]
jobs:
test:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: a62d00da59d1b0fb35f3a4ae854efa9441af892d
SOLANA_FFI_COMMIT: df7838d724f5eaf262ed77ed93b35b3f1f652bd3
services:
solana:
image: renbot/ren-solana:latest
ports:
- 8899:8899
postgres:
image: postgres:12.1
env:
Expand All @@ -28,27 +35,40 @@ jobs:
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-lightnode-${{ hashFiles('**/go.sum') }}
- name: Install dependencies (Filecoin FFI)

- name: Cache extern dependencies
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
- name: Install dependency packages
run: |
sudo apt-get update
sudo apt install ocl-icd-opencl-dev
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
git submodule add https://github.com/filecoin-project/filecoin-ffi.git .extern/filecoin-ffi
cd .extern/filecoin-ffi
git checkout a62d00da59d1b0fb35f3a4ae854efa9441af892d
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
cd ../..
- name: Replace submodule extern with cached extern
run: |
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
sudo apt install libudev-dev libssl-dev
git submodule add https://github.com/renproject/solana-ffi.git .extern/solana-ffi
cd .extern/solana-ffi
git checkout 4bd204b6017173c1425468db8566f053abb49f0b
go get -u github.com/xlab/c-for-go
cd .extern/solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
cd ../..
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.4.1
- Update Multichain to v0.3.8
- Add support for watching Solana burns

## 0.3.2

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.15
require (
github.com/alicebob/miniredis/v2 v2.14.3
github.com/btcsuite/btcd v0.21.0-beta
github.com/dfuse-io/solana-go v0.2.0
github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b // indirect
github.com/ethereum/go-ethereum v1.10.1
github.com/evalphobia/logrus_sentry v0.8.2
Expand All @@ -13,6 +14,7 @@ require (
github.com/jbenet/go-base58 v0.0.0-20150317085156-6237cf65f3a6
github.com/lib/pq v1.7.0
github.com/mattn/go-sqlite3 v1.11.0
github.com/near/borsh-go v0.3.0
github.com/onsi/ginkgo v1.14.0
github.com/onsi/gomega v1.10.1
github.com/renproject/aw v0.4.1-0.20210413051002-6234359989ab
Expand Down
43 changes: 35 additions & 8 deletions go.sum

Large diffs are not rendered by default.

28 changes: 26 additions & 2 deletions lightnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/renproject/multichain"
"github.com/renproject/phi"
"github.com/sirupsen/logrus"

solanaRPC "github.com/dfuse-io/solana-go/rpc"
)

// Lightnode is the top level container that encapsulates the functionality of
Expand Down Expand Up @@ -128,6 +130,8 @@ func New(options Options, ctx context.Context, logger logrus.FieldLogger, sqlDB
}

watchers := map[multichain.Chain]map[multichain.Asset]watcher.Watcher{}

// Ethereum watchers
ethGateways := bindings.EthereumGateways()
ethClients := bindings.EthereumClients()
for chain, contracts := range ethGateways {
Expand All @@ -140,12 +144,32 @@ func New(options Options, ctx context.Context, logger logrus.FieldLogger, sqlDB
if watchers[chain] == nil {
watchers[chain] = map[multichain.Asset]watcher.Watcher{}
}
burnLogFetcher := watcher.NewBurnLogFetcher(bindings)
watchers[chain][selector.Asset()] = watcher.NewWatcher(logger, options.Network, selector, verifierBindings, burnLogFetcher, ethClients[chain], resolverI, client, options.DistPubKey, options.WatcherPollRate, options.WatcherMaxBlockAdvance, options.WatcherConfidenceInterval)
burnLogFetcher := watcher.NewEthBurnLogFetcher(bindings)
blockHeightFetcher := watcher.NewEthBlockHeightFetcher(ethClients[chain])
watchers[chain][selector.Asset()] = watcher.NewWatcher(logger, options.Network, selector, verifierBindings, burnLogFetcher, blockHeightFetcher, resolverI, client, options.DistPubKey, options.WatcherPollRate, options.WatcherMaxBlockAdvance, options.WatcherConfidenceInterval)
logger.Info("watching", selector)
}
}

// Solana watchers
solanaGateways := bindings.ContractGateways()[multichain.Solana]
solClient := solanaRPC.NewClient(bindingsOpts.Chains[multichain.Solana].RPC.String())
for asset, bindings := range solanaGateways {
chain := multichain.Solana
selector := tx.Selector(fmt.Sprintf("%v/from%v", asset, chain))
if !whitelistMap[selector] {
logger.Info("not watching ", selector)
continue
}
if watchers[chain] == nil {
watchers[chain] = map[multichain.Asset]watcher.Watcher{}
}
solanaFetcher := watcher.NewSolFetcher(solClient, string(bindings))
watchers[chain][selector.Asset()] = watcher.NewWatcher(logger, options.Network, selector, verifierBindings, solanaFetcher, solanaFetcher, resolverI, client, options.DistPubKey, options.WatcherPollRate, options.WatcherMaxBlockAdvance, options.WatcherConfidenceInterval)
logger.Info("watching ", selector)
logger.Info("at ", bindings)
}

return Lightnode{
options: options,
logger: logger,
Expand Down
Loading

0 comments on commit d755883

Please sign in to comment.