Skip to content

Commit

Permalink
replace external facing mercury with data streams
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill committed Jan 11, 2024
1 parent 841b455 commit 764df4a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 32 deletions.
10 changes: 5 additions & 5 deletions core/scripts/chaincli/.env.debugging.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ KEEPER_REGISTRY_ADDRESS=<Registry Address>
#TENDERLY_ACCOUNT_NAME=<Tenderly Account Name>
#TENDERLY_PROJECT_NAME=<Tenderly Project Name>

# [Optional] add mercury info only if your upkeep uses mercury
#MERCURY_ID=<Mercury ID>
#MERCURY_KEY=<Mercury Key>
#MERCURY_LEGACY_URL=<Mercury Legacy URL>
#MERCURY_URL=<Mercury Server URL>
# [Optional] add data streams info only if your upkeep uses data streams
#DATA_STREAMS_ID=<DATA STREAMS ID>
#DATA_STREAMS_KEY=<DATA STREAMS Key>
#DATA_STREAMS_LEGACY_URL=<DATA STREAMS Legacy URL FOR THIS NETWORK>
#DATA_STREAMS_URL=<DATA STREAMS Server URL FOR THIS NETWORK>
8 changes: 4 additions & 4 deletions core/scripts/chaincli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ Ensure the following fields are provided in your `.env` file:

If your targeted upkeep involves streams lookup, include the following information:

- `MERCURY_ID`
- `MERCURY_KEY`
- `MERCURY_LEGACY_URL`
- `MERCURY_URL`
- `DATA_STREAMS_ID`
- `DATA_STREAMS_KEY`
- `DATA_STREAMS_LEGACY_URL`
- `DATA_STREAMS_URL`

#### Tenderly Integration

Expand Down
12 changes: 6 additions & 6 deletions core/scripts/chaincli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ type Config struct {
FeedQuoteAddr string `mapstructure:"FEED_QUOTE_ADDR"`
FeedDecimals uint8 `mapstructure:"FEED_DECIMALS"`

// Mercury Config
MercuryURL string `mapstructure:"MERCURY_URL"`
MercuryLegacyURL string `mapstructure:"MERCURY_LEGACY_URL"`
MercuryID string `mapstructure:"MERCURY_ID"`
MercuryKey string `mapstructure:"MERCURY_KEY"`
MercuryCredName string `mapstructure:"MERCURY_CRED_NAME"`
// Data Streams Config
DataStreamsURL string `mapstructure:"DATA_STREAMS_URL"`
DataStreamsLegacyURL string `mapstructure:"DATA_STREAMS_LEGACY_URL"`
DataStreamsID string `mapstructure:"DATA_STREAMS_ID"`
DataStreamsKey string `mapstructure:"DATA_STREAMS_KEY"`
DataStreamsCredName string `mapstructure:"DATA_STREAMS_CRED_NAME"`

// Tenderly
TenderlyKey string `mapstructure:"TENDERLY_KEY"`
Expand Down
18 changes: 9 additions & 9 deletions core/scripts/chaincli/handler/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
}

if checkResult.UpkeepFailureReason == uint8(encoding.UpkeepFailureReasonTargetCheckReverted) {
mc := &models.MercuryCredentials{LegacyURL: k.cfg.MercuryLegacyURL, URL: k.cfg.MercuryURL, Username: k.cfg.MercuryID, Password: k.cfg.MercuryKey}
mc := &models.MercuryCredentials{LegacyURL: k.cfg.DataStreamsLegacyURL, URL: k.cfg.DataStreamsURL, Username: k.cfg.DataStreamsID, Password: k.cfg.DataStreamsKey}
mercuryConfig := evm21.NewMercuryConfig(mc, core.StreamsCompatibleABI)
lggr, _ := logger.NewLogger()
blockSub := &blockSubscriber{k.client}
Expand All @@ -281,25 +281,25 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
}

if streamsLookup.IsMercuryV02() {
message("using mercury lookup v0.2")
message("using data streams lookup v0.2")
// check if upkeep is allowed to use mercury v0.2
var allowed bool
_, _, _, allowed, err = streams.AllowedToUseMercury(triggerCallOpts, upkeepID)
if err != nil {
failUnknown("failed to check if upkeep is allowed to use mercury", err)
failUnknown("failed to check if upkeep is allowed to use data streams", err)
}
if !allowed {
resolveIneligible("upkeep reverted with StreamsLookup but is not allowed to access streams")
}
} else if streamsLookup.IsMercuryV03() {
// handle v0.3
message("using mercury lookup v0.3")
message("using data streams lookup v0.3")
} else {
resolveIneligible("upkeep reverted with StreamsLookup but the configuration is invalid")
}

if k.cfg.MercuryLegacyURL == "" || k.cfg.MercuryURL == "" || k.cfg.MercuryID == "" || k.cfg.MercuryKey == "" {
failCheckConfig("Mercury configs not set properly, check your MERCURY_LEGACY_URL, MERCURY_URL, MERCURY_ID and MERCURY_KEY", nil)
if k.cfg.DataStreamsLegacyURL == "" || k.cfg.DataStreamsURL == "" || k.cfg.DataStreamsID == "" || k.cfg.DataStreamsKey == "" {
failCheckConfig("Data streams configs not set properly, check your DATA_STREAMS_LEGACY_URL, DATA_STREAMS_URL, DATA_STREAMS_ID and DATA_STREAMS_KEY", nil)
}

// do mercury request
Expand All @@ -313,16 +313,16 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
resolveIneligible("upkeep used invalid revert data")
}
if checkResults[0].PipelineExecutionState == uint8(encoding.InvalidMercuryRequest) {
resolveIneligible("the mercury request data is invalid")
resolveIneligible("the data streams request data is invalid")
}
if err != nil {
failCheckConfig("failed to do mercury request ", err)
failCheckConfig("failed to do data streams request ", err)
}

// do checkCallback
err = streams.CheckCallback(ctx, values, streamsLookup, checkResults, 0)
if err != nil {
failUnknown("failed to execute mercury callback ", err)
failUnknown("failed to execute data streams callback ", err)
}
if checkResults[0].IneligibilityReason != 0 {
message(fmt.Sprintf("checkCallback failed with UpkeepFailureReason %d", checkResults[0].IneligibilityReason))
Expand Down
2 changes: 1 addition & 1 deletion core/scripts/chaincli/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (h *baseHandler) launchChainlinkNode(ctx context.Context, port int, contain
if err != nil {
return "", nil, fmt.Errorf("failed to create toml file: %w", err)
}
var secretTOMLStr = fmt.Sprintf(secretTOML, h.cfg.MercuryURL, h.cfg.MercuryID, h.cfg.MercuryKey)
var secretTOMLStr = fmt.Sprintf(secretTOML, h.cfg.DataStreamsURL, h.cfg.DataStreamsID, h.cfg.DataStreamsKey)
secretFile, secretTOMLFileCleanup, err := createTomlFile(secretTOMLStr)
if err != nil {
return "", nil, fmt.Errorf("failed to create secret toml file: %w", err)
Expand Down
15 changes: 8 additions & 7 deletions core/scripts/chaincli/handler/keeper_launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"

"github.com/smartcontractkit/chainlink-common/pkg/utils/hex"

"github.com/smartcontractkit/chainlink/v2/core/cmd"
iregistry21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1"
registry12 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_2"
Expand Down Expand Up @@ -377,13 +378,13 @@ func (k *Keeper) createOCR2KeeperJob(ctx context.Context, client cmd.HTTPClient,

request, err := json.Marshal(web.CreateJobRequest{
TOML: fmt.Sprintf(ocr2keeperJobTemplate,
contractAddr, // contractID
ocr2KeyConfig.ID, // ocrKeyBundleID
nodeAddr, // transmitterID - node wallet address
k.cfg.BootstrapNodeAddr, // bootstrap node key and address
k.cfg.ChainID, // chainID
contractVersion, // contractVersion
k.cfg.MercuryCredName, // mercury credential name
contractAddr, // contractID
ocr2KeyConfig.ID, // ocrKeyBundleID
nodeAddr, // transmitterID - node wallet address
k.cfg.BootstrapNodeAddr, // bootstrap node key and address
k.cfg.ChainID, // chainID
contractVersion, // contractVersion
k.cfg.DataStreamsCredName, // mercury credential name
),
})
if err != nil {
Expand Down

0 comments on commit 764df4a

Please sign in to comment.