Skip to content

Commit 3589cb6

Browse files
committed
Introduce the cre secure mint transmitter
1 parent a4a59d2 commit 3589cb6

8 files changed

Lines changed: 489 additions & 93 deletions

File tree

core/scripts/cre/environment/configs/single-don.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[[blockchains]]
33
type = "anvil"
44
chain_id = "1337"
5-
docker_cmd_params = ["-b", "5"]
5+
docker_cmd_params = ["-b", "2"]
66

77
# uncomment to start a second blockchain
88
#[[blockchains]]
@@ -62,7 +62,7 @@
6262
JSONConsole = true
6363
6464
[Telemetry]
65-
Enabled = true
65+
Enabled = false
6666
Endpoint = 'host.docker.internal:4317'
6767
ChipIngressEndpoint = 'chip-ingress:50051'
6868
InsecureConnection = true
@@ -84,7 +84,7 @@
8484
JSONConsole = true
8585
8686
[Telemetry]
87-
Enabled = true
87+
Enabled = false
8888
Endpoint = 'host.docker.internal:4317'
8989
ChipIngressEndpoint = 'chip-ingress:50051'
9090
InsecureConnection = true
@@ -106,7 +106,7 @@
106106
JSONConsole = true
107107
108108
[Telemetry]
109-
Enabled = true
109+
Enabled = false
110110
Endpoint = 'host.docker.internal:4317'
111111
ChipIngressEndpoint = 'chip-ingress:50051'
112112
InsecureConnection = true
@@ -128,7 +128,7 @@
128128
JSONConsole = true
129129
130130
[Telemetry]
131-
Enabled = true
131+
Enabled = false
132132
Endpoint = 'host.docker.internal:4317'
133133
ChipIngressEndpoint = 'chip-ingress:50051'
134134
InsecureConnection = true
@@ -150,7 +150,7 @@
150150
JSONConsole = true
151151
152152
[Telemetry]
153-
Enabled = true
153+
Enabled = false
154154
Endpoint = 'host.docker.internal:4317'
155155
ChipIngressEndpoint = 'chip-ingress:50051'
156156
InsecureConnection = true

core/services/ocr2/delegate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ func (d *Delegate) newServicesSecureMint(
12491249
return nil, ErrRelayNotEnabled{Err: err, PluginName: "securemint", Relay: spec.Relay}
12501250
}
12511251

1252-
secureMintServices, err := securemint.NewSecureMintServices(ctx, jb, d.isNewlyCreatedJob, relayer, d.pipelineRunner, lggr, oracleArgsNoPlugin, smConfig)
1252+
secureMintServices, err := securemint.NewSecureMintServices(ctx, jb, d.isNewlyCreatedJob, relayer, d.pipelineRunner, lggr, oracleArgsNoPlugin, smConfig, d.capabilitiesRegistry)
12531253
secureMintServices = append(secureMintServices, ocrLogger)
12541254

12551255
return secureMintServices, err

core/services/ocr3/securemint/config/config.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ import (
1010
type SecureMintConfig struct {
1111
Token string `json:"token"`
1212
Reserves string `json:"reserves"`
13+
14+
// Trigger capability configuration
15+
TriggerCapabilityName string `json:"triggerCapabilityName"`
16+
TriggerCapabilityVersion string `json:"triggerCapabilityVersion"`
17+
TriggerTickerMinResolutionMs int `json:"triggerTickerMinResolutionMs"`
18+
TriggerSendChannelBufferSize int `json:"triggerSendChannelBufferSize"`
19+
}
20+
21+
// SecureMintTriggerConfig holds configuration for secure mint trigger subscribers
22+
type SecureMintTriggerConfig struct {
23+
// The interval in milliseconds after which a new trigger event is generated.
24+
MaxFrequencyMs uint64 `json:"maxFrequencyMs" yaml:"maxFrequencyMs" mapstructure:"maxFrequencyMs"`
1325
}
1426

1527
// Parse parses the secure mint configuration from JSON bytes

core/services/ocr3/securemint/integrationtest/integration_test.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/ethereum/go-ethereum/common"
1818
gethtypes "github.com/ethereum/go-ethereum/core/types"
1919
"github.com/ethereum/go-ethereum/eth/ethconfig"
20-
"github.com/onsi/gomega"
2120
"github.com/stretchr/testify/assert"
2221
"github.com/stretchr/testify/require"
2322

@@ -31,7 +30,6 @@ import (
3130
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
3231
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
3332
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/csakey"
34-
"github.com/smartcontractkit/chainlink/v2/core/services/ocr3/securemint"
3533
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/llo"
3634
"github.com/smartcontractkit/freeport"
3735
"github.com/smartcontractkit/libocr/commontypes"
@@ -201,16 +199,16 @@ func validateJobsRunningSuccessfully(t *testing.T, nodes []node, jobIDs map[int]
201199
wg.Wait()
202200
t.Logf("All pipeline runs completed successfully")
203201

204-
// 3. Check that transmissions work
205-
expectedNumTransmissions := int32(4)
206-
gomega.NewWithT(t).Eventually(func() bool {
207-
numTransmissions := securemint.StubTransmissionCounter.Load()
208-
t.Logf("Number of (stub) report transmissions: %d", numTransmissions)
209-
return numTransmissions >= expectedNumTransmissions
210-
}, 30*time.Second, 1*time.Second).Should(
211-
gomega.BeTrue(),
212-
fmt.Sprintf("expected at least %d reports transmitted, but got less", expectedNumTransmissions),
213-
)
202+
// // 3. Check that transmissions work
203+
// expectedNumTransmissions := int32(4)
204+
// gomega.NewWithT(t).Eventually(func() bool {
205+
// numTransmissions := securemint.StubTransmissionCounter.Load()
206+
// t.Logf("Number of (stub) report transmissions: %d", numTransmissions)
207+
// return numTransmissions >= expectedNumTransmissions
208+
// }, 30*time.Second, 1*time.Second).Should(
209+
// gomega.BeTrue(),
210+
// fmt.Sprintf("expected at least %d reports transmitted, but got less", expectedNumTransmissions),
211+
// )
214212
}
215213

216214
func setSecureMintOnchainConfigUsingOCR3Configurator(t *testing.T, steve *bind.TransactOpts, backend evmtypes.Backend, nodes []node, oracles []confighelper.OracleIdentityExtra) (*configurator.Configurator, common.Address) {

core/services/ocr3/securemint/services.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/smartcontractkit/chainlink-common/pkg/loop"
99
"github.com/smartcontractkit/chainlink-common/pkg/types"
10+
coretypes "github.com/smartcontractkit/chainlink-common/pkg/types/core"
1011
"github.com/smartcontractkit/chainlink/v2/core/config/env"
1112
"github.com/smartcontractkit/chainlink/v2/core/logger"
1213
"github.com/smartcontractkit/chainlink/v2/core/services"
@@ -16,9 +17,9 @@ import (
1617
sm_ea "github.com/smartcontractkit/chainlink/v2/core/services/ocr3/securemint/ea"
1718
"github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon"
1819
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
20+
evm_types "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types"
1921
"github.com/smartcontractkit/chainlink/v2/plugins"
2022
libocr "github.com/smartcontractkit/libocr/offchainreporting2plus"
21-
ocr2plus_types "github.com/smartcontractkit/libocr/offchainreporting2plus/types"
2223
"github.com/smartcontractkit/por_mock_ocr3plugin/por"
2324
sm_plugin "github.com/smartcontractkit/por_mock_ocr3plugin/por"
2425
)
@@ -63,6 +64,7 @@ func NewSecureMintServices(ctx context.Context,
6364
lggr logger.Logger,
6465
argsNoPlugin libocr.OCR3OracleArgs[por.ChainSelector],
6566
cfg JobConfig,
67+
capabilitiesRegistry coretypes.CapabilitiesRegistry,
6668
) (srvs []job.ServiceCtx, err error) {
6769
// Parse and validate the secure mint plugin configuration
6870
secureMintPluginConfig, err := sm_plugin_config.Parse(jb.OCR2OracleSpec.PluginConfig.Bytes())
@@ -76,6 +78,19 @@ func NewSecureMintServices(ctx context.Context,
7678

7779
spec := jb.OCR2OracleSpec
7880

81+
// Get relay config to extract don ID
82+
relayConfig, err := evm_types.NewRelayOpts(types.RelayArgs{
83+
ExternalJobID: jb.ExternalJobID,
84+
JobID: jb.ID,
85+
ContractID: spec.ContractID,
86+
New: isNewlyCreatedJob,
87+
RelayConfig: spec.RelayConfig.Bytes(),
88+
ProviderType: string(spec.PluginType),
89+
}).RelayConfig()
90+
if err != nil {
91+
return nil, fmt.Errorf("failed to get relay config: %w", err)
92+
}
93+
7994
// Create result run saver for pipeline execution
8095
runSaver := ocrcommon.NewResultRunSaver(
8196
pipelineRunner,
@@ -101,8 +116,23 @@ func NewSecureMintServices(ctx context.Context,
101116
argsNoPlugin.ContractConfigTracker = configProvider.ContractConfigTracker()
102117
argsNoPlugin.OffchainConfigDigester = configProvider.OffchainConfigDigester()
103118

104-
// Using a stub contract transmitter for testing purposes until DF-21404 is done
105-
argsNoPlugin.ContractTransmitter = newStubContractTransmitter(lggr, ocr2plus_types.Account(spec.TransmitterID.String))
119+
// Create the new secure mint transmitter with trigger capabilities
120+
transmitterConfig := TransmitterConfig{
121+
Logger: lggr,
122+
CapabilitiesRegistry: capabilitiesRegistry,
123+
DonID: relayConfig.LLODONID,
124+
TriggerCapabilityName: secureMintPluginConfig.TriggerCapabilityName,
125+
TriggerCapabilityVersion: secureMintPluginConfig.TriggerCapabilityVersion,
126+
TriggerTickerMinResolutionMs: secureMintPluginConfig.TriggerTickerMinResolutionMs,
127+
TriggerSendChannelBufferSize: secureMintPluginConfig.TriggerSendChannelBufferSize,
128+
}
129+
130+
transmitter, err := transmitterConfig.NewTransmitter(spec.TransmitterID.String)
131+
if err != nil {
132+
return nil, fmt.Errorf("failed to create secure mint transmitter: %w", err)
133+
}
134+
argsNoPlugin.ContractTransmitter = transmitter
135+
srvs = append(srvs, transmitter)
106136

107137
abort := func() {
108138
if cerr := services.MultiCloser(srvs).Close(); cerr != nil {

core/services/ocr3/securemint/stub_transmitter.go

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)