Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Nov 15, 2024
2 parents a0cd93d + 452a99e commit c95ee7f
Show file tree
Hide file tree
Showing 36 changed files with 605 additions and 335 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-geckos-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#bugfix Update Log.Level and MaxSize configs description in the docs
8 changes: 4 additions & 4 deletions .github/actions/goreleaser-build-sign-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ runs:
name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- name: Setup docker buildx
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.0
- name: Set up Go
uses: ./.github/actions/setup-go
with:
go-version-file: 'go.mod'
only-modules: 'true'
- name: Setup goreleaser
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
with:
distribution: goreleaser-pro
install-only: true
Expand All @@ -49,12 +49,12 @@ runs:
GORELEASER_KEY: ${{ inputs.goreleaser-key }}

- name: Login to docker registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ inputs.docker-registry }}

- name: Install syft
uses: anchore/sbom-action/download-syft@61119d458adab75f756bc0b9e4bde25725f86a7a # v0.17.2
uses: anchore/sbom-action/download-syft@fc46e51fd3cb168ffb36c6d1915723c47db58abb # v0.17.7

- name: Run goreleaser release
shell: bash
Expand Down
51 changes: 36 additions & 15 deletions .github/workflows/delete-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,48 @@ jobs:
# See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
actions: write
contents: read
env:
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
- name: Check out code
uses: actions/[email protected]

- name: Cleanup Branch Caches
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge
- name: Setup gh-actions-cache extension
run: gh extension install actions/gh-actions-cache

echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
- name: Retrieve Trunk SHA
id: get-sha
run: |
SHA=$(gh pr view -R $REPO $PR_NUMBER --json mergeCommit --jq .mergeCommit.oid)
echo "sha=$SHA" >> $GITHUB_OUTPUT
## Setting this to not fail the workflow while deleting cache keys.
- name: Cleanup Caches
env:
TRUNK_SHA: ${{ steps.get-sha.outputs.sha }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
PR_BRANCH=refs/pull/$PR_NUMBER/merge
echo "Fetching list of cache keys for the PR branch ($PR_BRANCH)"
PR_CACHE_KEYS=$(gh actions-cache list -R $REPO -B $PR_BRANCH | cut -f 1)
echo "Deleting caches for PR branch ($PR_BRANCH)..."
for CACHE_KEY in $PR_CACHE_KEYS; do
gh actions-cache delete $CACHE_KEY -R $REPO -B $PR_BRANCH --confirm
done
if [[ -n "$TRUNK_SHA" ]]; then
echo "Found corresponding merge commit $TRUNK_SHA"
QUEUE_BRANCH="gh-readonly-queue/develop/pr-${PR_NUMBER}-${TRUNK_SHA}"
echo "Fetching list of cache keys for the merge queue branch ($QUEUE_BRANCH)"
QUEUE_CACHE_KEYS=$(gh actions-cache list -R $REPO -B $QUEUE_BRANCH | cut -f 1)
echo "Deleting caches for merge queue branch ($QUEUE_BRANCH)..."
for CACHE_KEY in $QUEUE_CACHE_KEYS; do
gh actions-cache delete $CACHE_KEY -R $REPO -B $QUEUE_BRANCH --confirm
done
fi
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/find-new-flaky-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:

- name: Install flakeguard
shell: bash
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@897bca304fc9f0e68b87579558750c4a3e83adec
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@9da200418b01268201a0e6477832734a14720d07

- name: Find new or updated test packages
if: ${{ inputs.runAllTests == false }}
Expand Down Expand Up @@ -259,7 +259,7 @@ jobs:

- name: Install flakeguard
shell: bash
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@897bca304fc9f0e68b87579558750c4a3e83adec
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@9da200418b01268201a0e6477832734a14720d07

- name: Run tests with flakeguard
shell: bash
Expand Down Expand Up @@ -301,7 +301,7 @@ jobs:

- name: Install flakeguard
shell: bash
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@897bca304fc9f0e68b87579558750c4a3e83adec
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@9da200418b01268201a0e6477832734a14720d07

- name: Set combined test results
id: set_test_results
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/run-nightly-flaky-test-detector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
schedule:
# Run every night at 3:00 AM UTC
- cron: '0 3 * * *'
workflow_dispatch: # Allows manual trigger for debugging

jobs:
trigger-flaky-test-detection:
Expand All @@ -14,8 +15,8 @@ jobs:
baseRef: 'origin/develop'
projectPath: '.'
runThreshold: '1'
runAllTests: 'true'
extraArgs: '{ "skipped_tests": "TestChainComponents", "test_repeat_count": "5", "all_tests_runner": "ubuntu22.04-32cores-128GB", "all_tests_runner_count": "3", "min_pass_ratio": "0" }'
runAllTests: true
extraArgs: '{ "skipped_tests": "TestChainComponents", "test_repeat_count": "5", "all_tests_runner": "ubuntu22.04-32cores-128GB", "all_tests_runner_count": "3", "min_pass_ratio": "0", "run_with_race": "false" }'
secrets:
SLACK_BOT_TOKEN: ${{ secrets.QA_SLACK_API_KEY }}

4 changes: 4 additions & 0 deletions common/txmgr/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ type TxMeta[ADDR types.Hashable, TX_HASH types.Hashable] struct {
MessageIDs []string `json:"MessageIDs,omitempty"`
// SeqNumbers is used by CCIP for tx to committed sequence numbers correlation in logs
SeqNumbers []uint64 `json:"SeqNumbers,omitempty"`

// Dual Broadcast
DualBroadcast *bool `json:"DualBroadcast,omitempty"`
DualBroadcastParams *string `json:"DualBroadcastParams,omitempty"`
}

type TxAttempt[
Expand Down
24 changes: 19 additions & 5 deletions core/capabilities/compute/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"net/http"
"strconv"
"strings"
"sync"
"time"
Expand All @@ -20,6 +21,7 @@ import (
capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb"
"github.com/smartcontractkit/chainlink-common/pkg/custmsg"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/metrics"
"github.com/smartcontractkit/chainlink-common/pkg/services"
coretypes "github.com/smartcontractkit/chainlink-common/pkg/types/core"
"github.com/smartcontractkit/chainlink-common/pkg/workflows/wasm/host"
Expand Down Expand Up @@ -75,8 +77,9 @@ var (
var _ capabilities.ActionCapability = (*Compute)(nil)

type Compute struct {
stopCh services.StopChan
log logger.Logger
stopCh services.StopChan
log logger.Logger
metrics *computeMetricsLabeler

// emitter is used to emit messages from the WASM module to a configured collector.
emitter custmsg.MessageEmitter
Expand Down Expand Up @@ -294,7 +297,6 @@ func (c *Compute) createFetcher() func(ctx context.Context, req *wasmpb.FetchReq
)

messageID := strings.Join([]string{
req.Metadata.WorkflowId,
req.Metadata.WorkflowExecutionId,
ghcapabilities.MethodComputeAction,
c.idGenerator(),
Expand Down Expand Up @@ -329,6 +331,13 @@ func (c *Compute) createFetcher() func(ctx context.Context, req *wasmpb.FetchReq
return nil, fmt.Errorf("failed to unmarshal fetch response: %w", err)
}

c.metrics.with(
"status", strconv.FormatUint(uint64(response.StatusCode), 10),
platform.KeyWorkflowID, req.Metadata.WorkflowId,
platform.KeyWorkflowName, req.Metadata.WorkflowName,
platform.KeyWorkflowOwner, req.Metadata.WorkflowOwner,
).incrementHTTPRequestCounter(ctx)

// Only log if the response is not in the 200 range
if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
msg := fmt.Sprintf("compute fetch request failed with status code %d", response.StatusCode)
Expand Down Expand Up @@ -358,17 +367,22 @@ func NewAction(
handler *webapi.OutgoingConnectorHandler,
idGenerator func() string,
opts ...func(*Compute),
) *Compute {
) (*Compute, error) {
if config.NumWorkers == 0 {
config.NumWorkers = defaultNumWorkers
}
metricsLabeler, err := newComputeMetricsLabeler(metrics.NewLabeler().With("capability", CapabilityIDCompute))
if err != nil {
return nil, fmt.Errorf("failed to create compute metrics labeler: %w", err)
}
var (
lggr = logger.Named(log, "CustomCompute")
labeler = custmsg.NewLabeler()
compute = &Compute{
stopCh: make(services.StopChan),
log: lggr,
emitter: labeler,
metrics: metricsLabeler,
registry: registry,
modules: newModuleCache(clockwork.NewRealClock(), 1*time.Minute, 10*time.Minute, 3),
transformer: NewTransformer(lggr, labeler),
Expand All @@ -383,5 +397,5 @@ func NewAction(
opt(compute)
}

return compute
return compute, nil
}
5 changes: 3 additions & 2 deletions core/capabilities/compute/compute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
cappkg "github.com/smartcontractkit/chainlink-common/pkg/capabilities"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink-common/pkg/values"

corecapabilities "github.com/smartcontractkit/chainlink/v2/core/capabilities"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/webapi"
"github.com/smartcontractkit/chainlink/v2/core/services/gateway/api"
Expand Down Expand Up @@ -60,7 +61,8 @@ func setup(t *testing.T, config Config) testHarness {
connectorHandler, err := webapi.NewOutgoingConnectorHandler(connector, config.ServiceConfig, ghcapabilities.MethodComputeAction, log)
require.NoError(t, err)

compute := NewAction(config, log, registry, connectorHandler, idGeneratorFn)
compute, err := NewAction(config, log, registry, connectorHandler, idGeneratorFn)
require.NoError(t, err)
compute.modules.clock = clockwork.NewFakeClock()

return testHarness{
Expand Down Expand Up @@ -189,7 +191,6 @@ func TestComputeFetch(t *testing.T) {
th.connector.EXPECT().GatewayIDs().Return([]string{"gateway1", "gateway2"})

msgID := strings.Join([]string{
workflowID,
workflowExecutionID,
ghcapabilities.MethodComputeAction,
validRequestUUID,
Expand Down
35 changes: 35 additions & 0 deletions core/capabilities/compute/monitoring.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
package compute

import (
"context"
"fmt"

"go.opentelemetry.io/otel/metric"

"github.com/smartcontractkit/chainlink-common/pkg/beholder"
"github.com/smartcontractkit/chainlink-common/pkg/metrics"

localMonitoring "github.com/smartcontractkit/chainlink/v2/core/monitoring"
)

const timestampKey = "computeTimestamp"

type computeMetricsLabeler struct {
metrics.Labeler
computeHTTPRequestCounter metric.Int64Counter
}

func newComputeMetricsLabeler(l metrics.Labeler) (*computeMetricsLabeler, error) {
computeHTTPRequestCounter, err := beholder.GetMeter().Int64Counter("capabilities_compute_http_request_count")
if err != nil {
return nil, fmt.Errorf("failed to register compute http request counter: %w", err)
}

return &computeMetricsLabeler{Labeler: l, computeHTTPRequestCounter: computeHTTPRequestCounter}, nil
}

func (c *computeMetricsLabeler) with(keyValues ...string) *computeMetricsLabeler {
return &computeMetricsLabeler{c.With(keyValues...), c.computeHTTPRequestCounter}
}

func (c *computeMetricsLabeler) incrementHTTPRequestCounter(ctx context.Context) {
otelLabels := localMonitoring.KvMapToOtelAttributes(c.Labels)
c.computeHTTPRequestCounter.Add(ctx, 1, metric.WithAttributes(otelLabels...))
}
4 changes: 2 additions & 2 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ JsonWrapperKey = 'event' # Example
Headers = ['Authorization: token', 'X-SomeOther-Header: value with spaces | and a bar+*'] # Example

[Log]
# Level determines both what is printed on the screen and what is written to the log file.
# Level determines only what is printed on the screen/console. This configuration does not apply to the logs that are recorded in a file (see [`Log.File`](#logfile) for more details).
#
# The available levels are:
# - "debug": Useful for forensic debugging of issues.
Expand All @@ -145,7 +145,7 @@ UnixTS = false # Default
[Log.File]
# Dir sets the log directory. By default, Chainlink nodes write log data to `$ROOT/log.jsonl`.
Dir = '/my/log/directory' # Example
# MaxSize determines the log file's max size in megabytes before file rotation. Having this not set will disable logging to disk. If your disk doesn't have enough disk space, the logging will pause and the application will log errors until space is available again.
# MaxSize determines the log file's max size before file rotation. Having this not set or set to a value smaller than 1Mb will disable logging to disk. If your disk doesn't have enough disk space, the logging will pause and the application will log errors until space is available again.
#
# Values must have suffixes with a unit like: `5120mb` (5,120 megabytes). If no unit suffix is provided, the value defaults to `b` (bytes). The list of valid unit suffixes are:
#
Expand Down
1 change: 1 addition & 0 deletions core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
streamRegistry = streams.NewRegistry(globalLogger, pipelineRunner)
workflowORM = workflowstore.NewDBStore(opts.DS, globalLogger, clockwork.NewRealClock())
)
srvcs = append(srvcs, workflowORM)

promReporter := headreporter.NewPrometheusReporter(opts.DS, legacyEVMChains)
chainIDs := make([]*big.Int, legacyEVMChains.Len())
Expand Down
Loading

0 comments on commit c95ee7f

Please sign in to comment.