Skip to content

Commit d7267ca

Browse files
Merge pull request #3 from smartcontractkit/BCFR-940-security-requirements
Repo Setup + MultiNode Extraction
2 parents 3a75eda + 9698192 commit d7267ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+9960
-1106
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# CODEOWNERS Best Practices
2+
# 1. Per Github docs: "Order is important; the last matching pattern takes the most precedence."
3+
# Please define less specific codeowner paths before more specific codeowner paths in order for the more specific rule to have priority
4+
5+
# global ownership
6+
* @smartcontractkit/bix-framework

.github/pull_request_template.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
### Description
2+
3+
<!---
4+
Please include a brief description of changes if not obvious from the PR title
5+
6+
Does this work have a corresponding ticket?
7+
8+
Please link your Jira ticket by including it in one of the following reference:
9+
- the PR title
10+
- branch name
11+
- commit message
12+
- PR description
13+
14+
Example:
15+
16+
[LINK-777](https://smartcontract-it.atlassian.net/browse/LINK-777)
17+
-->
18+
19+
### Requires Dependencies
20+
<!---
21+
Does this work depend on other open PRs?
22+
23+
Please list other PRs that are blocking this PR.
24+
25+
Example:
26+
27+
- https://github.com/smartcontractkit/chainlink-common/pull/7777777
28+
-->
29+
30+
### Resolves Dependencies
31+
<!---
32+
Does this work support other open PRs?
33+
34+
Please list other PRs that are waiting for this PR to be merged.
35+
36+
Example:
37+
38+
- https://github.com/smartcontractkit/ccip/pull/7777777
39+
-->
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Golangci-lint
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
golangci-lint:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
id-token: write
10+
contents: read
11+
actions: read
12+
steps:
13+
- name: golangci-lint
14+
uses: smartcontractkit/.github/actions/ci-lint-go@2ac9d97a83a5edded09af7fcf4ea5bce7a4473a4 # v0.2.6
15+
with:
16+
golangci-lint-version: v1.62.2

.github/workflows/test.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: PKG Build and Test
2+
3+
on: [push]
4+
5+
jobs:
6+
build-test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
11+
12+
- name: Set up Go
13+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
14+
with:
15+
go-version-file: "go.mod"
16+
17+
- name: Build
18+
run: go build -v ./...
19+
20+
- name: Unit Tests
21+
run: GORACE="log_path=$PWD/race" go test -race ./... -coverpkg=./... -coverprofile=coverage.txt
22+
23+
- name: Print Races
24+
if: failure()
25+
id: print-races
26+
run: |
27+
find race.* | xargs cat > race.txt
28+
if [[ -s race.txt ]]; then
29+
cat race.txt
30+
fi
31+
32+
- name: Upload Go test results
33+
if: always()
34+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
35+
with:
36+
name: go-test-results
37+
path: |
38+
./coverage.txt
39+
./race.*
40+
41+
check-tidy:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
46+
- name: Set up Go
47+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
48+
with:
49+
go-version-file: "go.mod"
50+
- name: Ensure "make gomodtidy" has been run
51+
run: |
52+
make gomodtidy
53+
git add --all
54+
git diff --minimal --cached --exit-code
55+
- name: Ensure "make generate" has been run
56+
run: |
57+
make rm-mocked
58+
make generate
59+
git add --all
60+
git diff --stat --cached --exit-code

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Log files
2+
*.log
3+
14
# bin
25
tools/bin/*
36

@@ -15,3 +18,26 @@ generated/
1518
.idea
1619
.vscode/
1720
*.iml
21+
22+
debug.env
23+
*.txt
24+
operator_ui/install
25+
.devenv
26+
27+
# codeship
28+
*.aes
29+
dockercfg
30+
env
31+
credentials.env
32+
gcr_creds.env
33+
34+
# Test & linter reports
35+
*report.xml
36+
*report.json
37+
*.out
38+
dot_graphs/
39+
40+
41+
# Ignore DevSpace cache and log folder
42+
.devspace/
43+
go.work*

.golangci.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
run:
2+
timeout: 15m0s
3+
linters:
4+
enable:
5+
- containedctx
6+
- depguard
7+
- errname
8+
- errorlint
9+
- exhaustive
10+
- exportloopref
11+
- fatcontext
12+
- ginkgolinter
13+
- gocritic
14+
- goimports
15+
- gosec
16+
- loggercheck
17+
- mirror
18+
- misspell
19+
- noctx
20+
- nolintlint
21+
- perfsprint
22+
- prealloc
23+
- revive
24+
- rowserrcheck
25+
- spancheck
26+
- sqlclosecheck
27+
- testifylint
28+
- unconvert
29+
- whitespace
30+
linters-settings:
31+
exhaustive:
32+
default-signifies-exhaustive: true
33+
goimports:
34+
local-prefixes: github.com/smartcontractkit/chainlink
35+
golint:
36+
min-confidence: 1.0
37+
gosec:
38+
excludes:
39+
- G101
40+
- G104
41+
# - G204
42+
# - G304
43+
# - G404
44+
govet:
45+
enable:
46+
- shadow
47+
revive:
48+
confidence: 0.8
49+
rules:
50+
- name: blank-imports
51+
- name: context-as-argument
52+
- name: context-keys-type
53+
- name: dot-imports
54+
- name: error-return
55+
- name: error-strings
56+
- name: error-naming
57+
- name: exported
58+
- name: if-return
59+
- name: increment-decrement
60+
- name: var-naming
61+
- name: var-declaration
62+
- name: package-comments
63+
- name: range
64+
- name: receiver-naming
65+
- name: time-naming
66+
# - name: unexported-return
67+
- name: indent-error-flow
68+
- name: errorf
69+
- name: empty-block
70+
- name: superfluous-else
71+
# - name: unused-parameter
72+
- name: unreachable-code
73+
- name: redefines-builtin-id
74+
- name: waitgroup-by-value
75+
- name: unconditional-recursion
76+
- name: struct-tag
77+
# - name: string-format
78+
- name: string-of-int
79+
- name: range-val-address
80+
- name: range-val-in-closure
81+
- name: modifies-value-receiver
82+
- name: modifies-parameter
83+
- name: identical-branches
84+
- name: get-return
85+
# - name: flag-parameter
86+
- name: early-return
87+
- name: defer
88+
- name: constant-logical-expr
89+
# - name: confusing-naming
90+
# - name: confusing-results
91+
- name: bool-literal-in-expr
92+
- name: atomic
93+
depguard:
94+
rules:
95+
main:
96+
list-mode: lax
97+
deny:
98+
- pkg: cosmossdk.io/errors
99+
desc: Use the standard library instead
100+
- pkg: github.com/gofrs/uuid
101+
desc: Use github.com/google/uuid instead
102+
- pkg: github.com/jackc/pgx3
103+
desc: Use github.com/jackc/pgx4 instead
104+
- pkg: github.com/jackc/pgx5
105+
desc: Use github.com/jackc/pgx4 instead
106+
- pkg: github.com/satori/go.uuid
107+
desc: Use github.com/google/uuid instead
108+
- pkg: github.com/test-go/testify/assert
109+
desc: Use github.com/stretchr/testify/assert instead
110+
- pkg: github.com/test-go/testify/mock
111+
desc: Use github.com/stretchr/testify/mock instead
112+
- pkg: github.com/test-go/testify/require
113+
desc: Use github.com/stretchr/testify/require instead
114+
# TODO https://smartcontract-it.atlassian.net/browse/BCI-2589
115+
# - pkg: go.uber.org/multierr
116+
# desc: Use the standard library instead, for example https://pkg.go.dev/errors#Join
117+
- pkg: gopkg.in/guregu/null.v1
118+
desc: Use gopkg.in/guregu/null.v4 instead
119+
- pkg: gopkg.in/guregu/null.v2
120+
desc: Use gopkg.in/guregu/null.v4 instead
121+
- pkg: gopkg.in/guregu/null.v3
122+
desc: Use gopkg.in/guregu/null.v4 instead
123+
- pkg: github.com/go-gorm/gorm
124+
desc: Use github.com/jmoiron/sqlx directly instead

.mockery.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
dir: "{{ .InterfaceDir }}/mocks"
2+
mockname: "{{ .InterfaceName }}"
3+
outpkg: mocks
4+
filename: "{{ .InterfaceName | snakecase }}.go"
5+
packages:
6+
github.com/smartcontractkit/chainlink-framework/multinode:
7+
config:
8+
dir: "{{ .InterfaceDir }}"
9+
filename: "mock_{{ .InterfaceName | snakecase }}_test.go"
10+
inpackage: true
11+
mockname: "mock{{ .InterfaceName | camelcase }}"
12+
interfaces:
13+
Node:
14+
NodeSelector:
15+
sendOnlyClient:
16+
SendOnlyNode:
17+
RPCClient:
18+
Head:
19+
PoolChainInfoProvider:
20+
Subscription:

LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Copyright (c) 2024 SmartContract ChainLink Limited SEZC
2+
3+
Portions of this software are licensed as follows:
4+
5+
The MIT License (MIT)
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.PHONY: gomods
2+
gomods: ## Install gomods
3+
go install github.com/jmank88/[email protected]
4+
5+
.PHONY: gomodtidy
6+
gomodtidy: gomods
7+
gomods tidy
8+
9+
.PHONY: mockery
10+
mockery: $(mockery) ## Install mockery.
11+
go install github.com/vektra/mockery/[email protected]
12+
13+
.PHONY: generate
14+
generate: mockery
15+
mockery
16+
17+
.PHONY: rm-mocked
18+
rm-mocked:
19+
grep -rl "^// Code generated by mockery" | grep .go$ | xargs -r rm
20+
21+
.PHONY: lint-workspace lint
22+
GOLANGCI_LINT_VERSION := 1.62.2
23+
GOLANGCI_LINT_COMMON_OPTS := --max-issues-per-linter 0 --max-same-issues 0
24+
GOLANGCI_LINT_DIRECTORY := ./golangci-lint
25+
26+
lint-workspace:
27+
@./script/lint.sh $(GOLANGCI_LINT_VERSION) "$(GOLANGCI_LINT_COMMON_OPTS)" $(GOLANGCI_LINT_DIRECTORY)
28+
29+
lint:
30+
@./script/lint.sh $(GOLANGCI_LINT_VERSION) "$(GOLANGCI_LINT_COMMON_OPTS)" $(GOLANGCI_LINT_DIRECTORY) "--new-from-rev=origin/main"

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
# chainlink-framework
1+
# chainlink-framework
2+
3+
This repo contains common components created and maintained by the Blockchain Integrations Framework team.
4+
These components are used across EVM and non-EVM chain integrations.
5+
6+
## Components
7+
8+
### MultiNode
9+
Enables the use of multiple RPCs in chain integrations. Performs critical health checks,
10+
load balancing, node metrics, and is used to send transactions to all RPCs and aggregate results.
11+
MultiNode is used by all other components which require reading from or writing to the chain.
12+

0 commit comments

Comments
 (0)