Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhuie19 committed Jul 8, 2024
1 parent db9a484 commit 3512d93
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions core/config/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
MercuryPlugin = NewPlugin("mercury")
SolanaPlugin = NewPlugin("solana")
StarknetPlugin = NewPlugin("starknet")
CCIPExecPlugin = NewPlugin("ccip-exec")
// PrometheusDiscoveryHostName is the externally accessible hostname
// published by the node in the `/discovery` endpoint. Generally, it is expected to match
// the public hostname of node.
Expand Down
2 changes: 1 addition & 1 deletion core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2036,7 +2036,7 @@ func (d *Delegate) newServicesCCIPExecution(ctx context.Context, lggr logger.Sug
MetricsRegisterer: prometheus.WrapRegistererWith(map[string]string{"job_name": jb.Name.ValueOrZero()}, prometheus.DefaultRegisterer),
}

return ccipexec.NewExecServices(ctx, lggr, jb, string(sourceTokenAddress), srcProvider, dstProvider, int64(srcChainID), dstChainID, d.isNewlyCreatedJob, oracleArgsNoPlugin2, logError)
return ccipexec.NewExecServices(ctx, lggr, d.cfg, jb, string(sourceTokenAddress), srcProvider, dstProvider, int64(srcChainID), dstChainID, d.isNewlyCreatedJob, oracleArgsNoPlugin2, logError)
}

func (d *Delegate) ccipExecGetDstProvider(ctx context.Context, jb job.Job, pluginJobSpecConfig ccipconfig.ExecPluginJobSpecConfig, transmitterID string) (types.CCIPExecProvider, error) {
Expand Down
35 changes: 31 additions & 4 deletions core/services/ocr2/plugins/ccip/ccipexec/initializers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import (
"strconv"
"time"

"github.com/smartcontractkit/chainlink/v2/plugins"

"github.com/smartcontractkit/chainlink-common/pkg/loop"

"github.com/smartcontractkit/chainlink/v2/core/config/env"

"github.com/smartcontractkit/chainlink-common/pkg/types"

"github.com/Masterminds/semver/v3"
Expand Down Expand Up @@ -46,10 +52,31 @@ var (

var defaultNewReportingPluginRetryConfig = ccipdata.RetryConfig{InitialDelay: time.Second, MaxDelay: 5 * time.Minute}

func NewExecServices(ctx context.Context, lggr logger.Logger, jb job.Job, sourceTokenAddress string, srcProvider types.CCIPExecProvider, dstProvider types.CCIPExecProvider, srcChainID int64, dstChainID int64, new bool, argsNoPlugin libocr2.OCR2OracleArgs, logError func(string)) ([]job.ServiceCtx, error) {
wrappedPluginFactory, err := NewExecutionReportingPluginFactoryV2(ctx, lggr, sourceTokenAddress, srcChainID, dstChainID, srcProvider, dstProvider)
if err != nil {
return nil, err
func NewExecServices(ctx context.Context, lggr logger.Logger, cfg plugins.RegistrarConfig, jb job.Job, sourceTokenAddress string, srcProvider types.CCIPExecProvider, dstProvider types.CCIPExecProvider, srcChainID int64, dstChainID int64, new bool, argsNoPlugin libocr2.OCR2OracleArgs, logError func(string)) ([]job.ServiceCtx, error) {
loopCmd := env.CCIPExecPlugin.Cmd.Get()
loopEnabled := loopCmd != ""

var wrappedPluginFactory *ExecutionReportingPluginFactory
var err error
if loopEnabled {
// find loop command
envVars, err := plugins.ParseEnvFile(env.CCIPExecPlugin.Env.Get())
if err != nil {
return nil, fmt.Errorf("failed to parse ccip exec env file: %w", err)
}
cmdFn, grpcOpts, err := cfg.RegisterLOOP(plugins.CmdConfig{
ID: "ccip-exec",
Cmd: loopCmd,
Env: envVars,
})
// get reporting plugin factory from loop
factoryServer := loop.NewExecutionService(lggr, grpcOpts, cmdFn, srcProvider, dstProvider, uint32(srcChainID), uint32(dstChainID), sourceTokenAddress)

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / lint

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_race_tests)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_fuzz)

factoryServer declared and not used

Check failure on line 73 in core/services/ocr2/plugins/ccip/ccipexec/initializers.go

View workflow job for this annotation

GitHub Actions / Flakey Test Detection

factoryServer declared and not used
// wrap into ExecutionReportingPluginFactory
} else {
wrappedPluginFactory, err = NewExecutionReportingPluginFactoryV2(ctx, lggr, sourceTokenAddress, srcChainID, dstChainID, srcProvider, dstProvider)
if err != nil {
return nil, err
}
}

argsNoPlugin.ReportingPluginFactory = promwrapper.NewPromFactory(wrappedPluginFactory, "CCIPExecution", jb.OCR2OracleSpec.Relay, big.NewInt(0).SetInt64(dstChainID))
Expand Down

0 comments on commit 3512d93

Please sign in to comment.