Skip to content

Commit

Permalink
Merge branch 'release/0.3.5' into fix(confirmer)/dont-log-insufficien…
Browse files Browse the repository at this point in the history
…t-confirmations-as-error
  • Loading branch information
jazg committed Apr 6, 2021
2 parents c2b1236 + 9fcfabc commit 4f3c8ce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
10 changes: 0 additions & 10 deletions cmd/lightnode/lightnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/go-redis/redis/v7"
"github.com/renproject/aw/wire"
"github.com/renproject/darknode/jsonrpc"
"github.com/renproject/darknode/tx"
"github.com/renproject/darknode/txengine/txenginebindings"
"github.com/renproject/id"
"github.com/renproject/lightnode"
Expand Down Expand Up @@ -334,12 +333,3 @@ func parsePubKey(name string) *id.PubKey {
}
return (*id.PubKey)(key)
}

func parseWhitelist(name string) []tx.Selector {
whitelistStrings := strings.Split(os.Getenv(name), ",")
whitelist := make([]tx.Selector, len(whitelistStrings))
for i := range whitelist {
whitelist[i] = tx.Selector(whitelistStrings[i])
}
return whitelist
}
10 changes: 10 additions & 0 deletions lightnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,27 @@ func New(options Options, ctx context.Context, logger logrus.FieldLogger, sqlDB
db,
bindings,
)
whitelistMap := map[tx.Selector]bool{}
for _, i := range options.Whitelist {
whitelistMap[i] = true
}

watchers := map[multichain.Chain]map[multichain.Asset]watcher.Watcher{}
ethGateways := bindings.EthereumGateways()
ethClients := bindings.EthereumClients()
for chain, contracts := range ethGateways {
for asset, bindings := range contracts {
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{}
}
burnLogFetcher := watcher.NewBurnLogFetcher(bindings)
watchers[chain][asset] = watcher.NewWatcher(logger, options.Network, selector, verifierBindings, ethClients[chain], burnLogFetcher, resolverI, client, options.DistPubKey, options.WatcherPollRate, options.WatcherMaxBlockAdvance, options.WatcherConfidenceInterval)
logger.Info("watching", selector)
}
}

Expand Down
6 changes: 4 additions & 2 deletions watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (watcher Watcher) watchLogShiftOuts(parent context.Context) {
// Fetch logs
c, err := watcher.burnLogFetcher.FetchBurnLogs(ctx, last, cur)
if err != nil {
watcher.logger.Errorf("[watcher] error iterating LogBurn events from=%v to=%v: %v", last, cur, err)
watcher.logger.Errorf("[watcher] error fetching LogBurn events from=%v to=%v: %v", last, cur, err)
return
}

Expand Down Expand Up @@ -218,7 +218,9 @@ func (watcher Watcher) watchLogShiftOuts(parent context.Context) {
response := watcher.resolver.SubmitTx(ctx, 0, &params, nil)
if response.Error != nil {
watcher.logger.Errorf("[watcher] invalid burn transaction %v: %v", params, response.Error.Message)
continue
// return so that we retry, if the burnToParams are valid, the darknode should accept the tx
// we assume that the only failure case would be RPC/darknode backpressure, so we backoff here
return
}
}

Expand Down

0 comments on commit 4f3c8ce

Please sign in to comment.