-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interfaces and skeleton methods for ChainReader EVM POC (#10990)
* Implement skeleton interfaces, structs, & methods for ChainReader EVM POC - Read ChainReader config in from RelayConfig - Add some initialization and validation relay skeletons - Use medianProviderWrapper instead of passing medianContract separately This avoids us having to modify the signature of NewMedianFactory, which would require further modifications to all non-evm repos and chainlink-relay - Add chain_reader_test.go with some basic relay tests Co-authored-by: Jordan Krage <jmank88@gmail.com> - Add chain reader config validation - Add chain reader config validation tests - Add config for chain reader median contract to cr validation testcases - Add unimplemented Encode(), Decode(), GetMaxEncodingSize(), GetMaxDecodingSize() - Add ChainReader() method to mock provider for plugin test - Rename relaymercury.ChainReader to MercuryChainReader, resolve name collisions - Add tests for errors during ChainReader construction - Propagate InvalidConfig & any other errors back to client We should ignore Unimplemented until node ops have been given ample time to migrate to the new job spec (including a section for ChainReader config) so that we can remove the old product-specific MedianContract component from MedianProvider. All other errors we can immediately start passing back to the client, letting the core node decide how to handle them (eg. displaying an "invalid job spec" message to the UI if the RelayConfig was invalid or the ContractID missing) * Update relay versions * Simplify chain reader config validation * Update commit hashes one final time now that all relays are merged. --------- Co-authored-by: ilija <pavlovicilija42@gmail.com>
- Loading branch information
1 parent
d65ca4f
commit c17067b
Showing
32 changed files
with
828 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package median | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" | ||
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" | ||
|
||
"github.com/smartcontractkit/chainlink-common/pkg/logger" | ||
"github.com/smartcontractkit/chainlink-common/pkg/loop" | ||
"github.com/smartcontractkit/chainlink-common/pkg/services" | ||
"github.com/smartcontractkit/chainlink-common/pkg/types" | ||
) | ||
|
||
type Plugin struct { | ||
loop.Plugin | ||
stop services.StopChan | ||
} | ||
|
||
func NewPlugin(lggr logger.Logger) *Plugin { | ||
return &Plugin{Plugin: loop.Plugin{Logger: lggr}, stop: make(services.StopChan)} | ||
} | ||
|
||
func (p *Plugin) NewMedianFactory(ctx context.Context, provider types.MedianProvider, dataSource, juelsPerFeeCoin median.DataSource, errorLog loop.ErrorLog) (loop.ReportingPluginFactory, error) { | ||
var ctxVals loop.ContextValues | ||
ctxVals.SetValues(ctx) | ||
lggr := logger.With(p.Logger, ctxVals.Args()...) | ||
|
||
factory := median.NumericalMedianFactory{ | ||
ContractTransmitter: provider.MedianContract(), | ||
DataSource: dataSource, | ||
JuelsPerFeeCoinDataSource: juelsPerFeeCoin, | ||
Logger: logger.NewOCRWrapper(lggr, true, func(msg string) { | ||
ctx, cancelFn := p.stop.NewCtx() | ||
defer cancelFn() | ||
if err := errorLog.SaveError(ctx, msg); err != nil { | ||
lggr.Errorw("Unable to save error", "err", msg) | ||
} | ||
}), | ||
OnchainConfigCodec: provider.OnchainConfigCodec(), | ||
ReportCodec: provider.ReportCodec(), | ||
} | ||
s := &reportingPluginFactoryService{lggr: logger.Named(lggr, "ReportingPluginFactory"), ReportingPluginFactory: factory} | ||
|
||
p.SubService(s) | ||
|
||
return s, nil | ||
} | ||
|
||
type reportingPluginFactoryService struct { | ||
services.StateMachine | ||
lggr logger.Logger | ||
ocrtypes.ReportingPluginFactory | ||
} | ||
|
||
func (r *reportingPluginFactoryService) Name() string { return r.lggr.Name() } | ||
|
||
func (r *reportingPluginFactoryService) Start(ctx context.Context) error { | ||
return r.StartOnce("ReportingPluginFactory", func() error { return nil }) | ||
} | ||
|
||
func (r *reportingPluginFactoryService) Close() error { | ||
return r.StopOnce("ReportingPluginFactory", func() error { return nil }) | ||
} | ||
|
||
func (r *reportingPluginFactoryService) HealthReport() map[string]error { | ||
return map[string]error{r.Name(): r.Healthy()} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.