Skip to content

Commit

Permalink
Merge branch 'develop' into TT-1550-Provide-PoC-for-keeping-test-conf…
Browse files Browse the repository at this point in the history
…igs-in-git
  • Loading branch information
lukaszcl committed Sep 12, 2024
2 parents 345bd28 + a2514d7 commit d8b1963
Show file tree
Hide file tree
Showing 76 changed files with 1,032 additions and 245 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-numbers-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#internal Implement LatestHead for ChainService
5 changes: 5 additions & 0 deletions .changeset/shy-bulldogs-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#added Full Open Telemetry support, configurable via `Telemetry`
36 changes: 8 additions & 28 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
<!---
Does this work have a corresponding ticket?
Please link your Jira ticket by including it in one of the following reference:
<!--- Does this work have a corresponding ticket? Please link it here as well as one of:
- the PR title
- branch name
- commit message
By referencing it, it will let the QA team to know what to watch out for when creating a new release.
Example:
[LINK-777](https://smartcontract-it.atlassian.net/browse/LINK-777)
[LINK-777](https://smartcontract-it.atlassian.net/browse/LINK-777)
-->

### Requires Dependencies
<!---
Does this work depend on other open PRs?
Please list other PRs that are blocking this PR.
Example:
- https://github.com/smartcontractkit/chainlink-common/pull/7777777
### Requires
<!--- Does this work depend on other open PRs? Please list them.
- https://github.com/smartcontractkit/chainlink-common/pull/7777777
-->

### Resolves Dependencies
<!---
Does this work support other open PRs?
Please list other PRs that are waiting for this PR to be merged.
Example:
- https://github.com/smartcontractkit/ccip/pull/7777777
### Resolves
<!--- Does this work support other open PRs? Please list them.
- https://github.com/smartcontractkit/ccip/pull/7777777
-->
97 changes: 97 additions & 0 deletions .github/scripts/jira/axios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import {
AxiosRequestConfig,
AxiosResponse,
AxiosError,
InternalAxiosRequestConfig,
} from "axios";
import { Readable } from "stream";

interface AxiosErrorFormat<Data = any> {
config: Pick<AxiosRequestConfig, (typeof CONFIG_KEYS)[number]>;
code?: string;
response: Partial<Pick<AxiosResponse<Data>, (typeof RESPONSE_KEYS)[number]>>;
isAxiosError: boolean;
}

interface AxiosErrorFormatError<Data = any>
extends Error,
AxiosErrorFormat<Data> {}

export function formatAxiosError<Data = any>(
origErr: AxiosError<Data>
): AxiosErrorFormatError<Data> {
const { message, name, stack, code, config, response, isAxiosError } =
origErr;

const err: AxiosErrorFormatError = {
...new Error(message),
name,
stack,
code,
isAxiosError,
config: {},
response: {},
};

for (const k of CONFIG_KEYS) {
if (config?.[k] === undefined) {
continue;
}

err.config[k] = formatValue(config[k], k);
}

for (const k of RESPONSE_KEYS) {
if (response?.[k] === undefined) {
continue;
}

err.response[k] = formatValue(response[k], k);
}

return err as any;
}

const CONFIG_KEYS: (keyof InternalAxiosRequestConfig)[] = [
"url",
"method",
"baseURL",
"params",
"data",
"timeout",
"timeoutErrorMessage",
"withCredentials",
"auth",
"responseType",
"xsrfCookieName",
"xsrfHeaderName",
"maxContentLength",
"maxBodyLength",
"maxRedirects",
"socketPath",
"proxy",
"decompress",
] as const;

const RESPONSE_KEYS: (keyof AxiosResponse)[] = [
"data",
"status",
"statusText",
] as const;

function formatValue(
value: any,
key: (typeof CONFIG_KEYS)[number] | (typeof RESPONSE_KEYS)[number]
): any {
if (key !== "data") {
return value;
}

if (process.env.BROWSER !== "true") {
if (value instanceof Readable) {
return "[Readable]";
}
}

return value;
}
26 changes: 18 additions & 8 deletions .github/scripts/jira/create-jira-traceability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
generateIssueLabel,
generateJiraIssuesLink,
getJiraEnvVars,
handleError,
} from "./lib";
import * as core from "@actions/core";

Expand Down Expand Up @@ -191,15 +192,24 @@ async function main() {

const client = createJiraClient();
const label = generateIssueLabel(product, baseRef, headRef);
await addTraceabillityToJiraIssues(
client,
jiraIssueNumbers,
label,
artifactUrl
);
try {
await addTraceabillityToJiraIssues(
client,
jiraIssueNumbers,
label,
artifactUrl
);
} catch (e) {
handleError(e);

const { jiraHost } = getJiraEnvVars()
core.summary.addLink("Jira Issues", generateJiraIssuesLink(`${jiraHost}/issues/`, label));
process.exit(1);
}

const { jiraHost } = getJiraEnvVars();
core.summary.addLink(
"Jira Issues",
generateJiraIssuesLink(`${jiraHost}/issues/`, label)
);
core.summary.write();
}
main();
4 changes: 2 additions & 2 deletions .github/scripts/jira/enforce-jira-issue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from "@actions/core";
import jira from "jira.js";
import { createJiraClient, getGitTopLevel, parseIssueNumberFrom } from "./lib";
import { createJiraClient, getGitTopLevel, handleError, parseIssueNumberFrom } from "./lib";
import { promises as fs } from "fs";
import { join } from "path";

Expand Down Expand Up @@ -36,7 +36,7 @@ async function doesIssueExist(

return true;
} catch (e) {
core.debug(e as any);
handleError(e)
return false;
}
}
Expand Down
18 changes: 17 additions & 1 deletion .github/scripts/jira/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import * as jira from "jira.js";
import { exec } from "child_process";
import { promisify } from "util";
import { join } from "path";

import { isAxiosError } from "axios";
import { formatAxiosError } from "./axios";
export function generateJiraIssuesLink(baseUrl: string, label: string) {
// https://smartcontract-it.atlassian.net/issues/?jql=labels%20%3D%20%22review-artifacts-automation-base%3A8d818ea265ff08887e61ace4f83364a3ee149ef0-head%3A3c45b71f3610de28f429cef0163936eaa448e63c%22
const jqlQuery = `labels = "${label}"`;
Expand Down Expand Up @@ -129,3 +130,18 @@ export function createJiraClient() {
},
});
}

export function handleError(e: unknown) {
if (e instanceof Error) {
if (isAxiosError(e)) {
core.error(formatAxiosError(e));
} else if (isAxiosError(e.cause)) {
core.error(formatAxiosError(e.cause));
} else {
core.error(e);
}
} else {
core.error(JSON.stringify(e));
}
core.setFailed("Error adding traceability to Jira issues");
}
3 changes: 3 additions & 0 deletions .github/scripts/jira/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@
"@types/node": "^20.14.10",
"typescript": "^5.5.3",
"vitest": "^2.0.3"
},
"peerDependencies": {
"axios": "^1.7.7"
}
}
11 changes: 7 additions & 4 deletions .github/scripts/jira/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/scripts/jira/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
Expand Down
1 change: 0 additions & 1 deletion .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ packages:
config:
filename: evm_mock.go
dir: "{{ .InterfaceDir }}/rpclibmocks"

github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/prices:
config:
dir: "{{ .InterfaceDir }}/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func setupNodeOCR3(
}
relayerFactory := chainlink.RelayerFactory{
Logger: lggr,
LoopRegistry: plugins.NewLoopRegistry(lggr.Named("LoopRegistry"), cfg.Tracing()),
LoopRegistry: plugins.NewLoopRegistry(lggr.Named("LoopRegistry"), cfg.Tracing(), cfg.Telemetry()),
GRPCOpts: loop.GRPCOpts{},
CapabilitiesRegistry: coretypes.NewCapabilitiesRegistry(t),
}
Expand All @@ -155,7 +155,7 @@ func setupNodeOCR3(
RestrictedHTTPClient: &http.Client{},
AuditLogger: audit.NoopLogger,
MailMon: mailMon,
LoopRegistry: plugins.NewLoopRegistry(lggr, cfg.Tracing()),
LoopRegistry: plugins.NewLoopRegistry(lggr, cfg.Tracing(), cfg.Telemetry()),
})
require.NoError(t, err)
require.NoError(t, app.GetKeyStore().Unlock(ctx, "password"))
Expand Down
7 changes: 4 additions & 3 deletions core/capabilities/gateway_connector/service_wrapper_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gatewayconnector
package gatewayconnector_test

import (
"crypto/ecdsa"
Expand All @@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

gatewayconnector "github.com/smartcontractkit/chainlink/v2/core/capabilities/gateway_connector"
"github.com/smartcontractkit/chainlink/v2/core/config/toml"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand All @@ -17,7 +18,7 @@ import (
ksmocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks"
)

func generateWrapper(t *testing.T, privateKey *ecdsa.PrivateKey, keystoreKey *ecdsa.PrivateKey) (*ServiceWrapper, error) {
func generateWrapper(t *testing.T, privateKey *ecdsa.PrivateKey, keystoreKey *ecdsa.PrivateKey) (*gatewayconnector.ServiceWrapper, error) {
logger := logger.TestLogger(t)
privateKeyV2 := ethkey.FromPrivateKey(privateKey)
addr := privateKeyV2.Address
Expand All @@ -43,7 +44,7 @@ func generateWrapper(t *testing.T, privateKey *ecdsa.PrivateKey, keystoreKey *ec
ethKeystore := ksmocks.NewEth(t)
ethKeystore.On("EnabledKeysForChain", mock.Anything, mock.Anything).Return([]ethkey.KeyV2{keystoreKeyV2}, nil)
gc := config.Capabilities().GatewayConnector()
wrapper := NewGatewayConnectorServiceWrapper(gc, ethKeystore, clockwork.NewFakeClock(), logger)
wrapper := gatewayconnector.NewGatewayConnectorServiceWrapper(gc, ethKeystore, clockwork.NewFakeClock(), logger)
require.NoError(t, err)
return wrapper, err
}
Expand Down
18 changes: 18 additions & 0 deletions core/capabilities/webapi/trigger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package webapi

import (
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/gateway/connector"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
)

func NewTrigger(config string, registry core.CapabilitiesRegistry, connector connector.GatewayConnector, lggr logger.Logger) (job.ServiceCtx, error) {
// TODO (CAPPL-22, CAPPL-24):
// - decode config
// - create an implementation of the capability API and add it to the Registry
// - create a handler and register it with Gateway Connector
// - manage trigger subscriptions
// - process incoming trigger events and related metadata
return nil, nil
}
5 changes: 5 additions & 0 deletions core/chains/chain_kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ func (s *testChainService) HealthReport() map[string]error {
return map[string]error{}
}

// Implement [types.LatestHead] interface
func (s *testChainService) LatestHead(_ context.Context) (head types.Head, err error) {
return
}

// Implement [types.ChainService] interface
func (s *testChainService) GetChainStatus(ctx context.Context) (stat types.ChainStatus, err error) {
return
Expand Down
Loading

0 comments on commit d8b1963

Please sign in to comment.