Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo Setup + MultiNode Extraction #3

Merged
merged 12 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# CODEOWNERS Best Practices
# 1. Per Github docs: "Order is important; the last matching pattern takes the most precedence."
# Please define less specific codeowner paths before more specific codeowner paths in order for the more specific rule to have priority

# global ownership
* @smartcontractkit/bix-framework
39 changes: 39 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
### Description

<!---
Please include a brief description of changes if not obvious from the PR title

Does this work have a corresponding ticket?

Please link your Jira ticket by including it in one of the following reference:
- the PR title
- branch name
- commit message
- PR description

Example:

[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
-->

### 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
-->
16 changes: 16 additions & 0 deletions .github/workflows/golangci_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Golangci-lint

on: [pull_request]

jobs:
golangci-lint:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
actions: read
steps:
- name: golangci-lint
uses: smartcontractkit/.github/actions/ci-lint-go@2ac9d97a83a5edded09af7fcf4ea5bce7a4473a4 # v0.2.6
with:
golangci-lint-version: v1.62.2
60 changes: 60 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: PKG Build and Test

on: [push]

jobs:
build-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: "go.mod"

- name: Build
run: go build -v ./...

- name: Unit Tests
run: GORACE="log_path=$PWD/race" go test -race ./... -coverpkg=./... -coverprofile=coverage.txt

- name: Print Races
if: failure()
id: print-races
run: |
find race.* | xargs cat > race.txt
if [[ -s race.txt ]]; then
cat race.txt
fi

- name: Upload Go test results
if: always()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: go-test-results
path: |
./coverage.txt
./race.*

check-tidy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: "go.mod"
- name: Ensure "make gomodtidy" has been run
run: |
make gomodtidy
git add --all
git diff --minimal --cached --exit-code
- name: Ensure "make generate" has been run
run: |
make rm-mocked
make generate
git add --all
git diff --stat --cached --exit-code
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Log files
*.log

# bin
tools/bin/*

Expand All @@ -15,3 +18,26 @@ generated/
.idea
.vscode/
*.iml

debug.env
*.txt
operator_ui/install
.devenv

# codeship
*.aes
dockercfg
env
credentials.env
gcr_creds.env

# Test & linter reports
*report.xml
*report.json
*.out
dot_graphs/


# Ignore DevSpace cache and log folder
.devspace/
go.work*
124 changes: 124 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
run:
timeout: 15m0s
linters:
enable:
- containedctx
- depguard
- errname
- errorlint
- exhaustive
- exportloopref
- fatcontext
- ginkgolinter
- gocritic
- goimports
- gosec
- loggercheck
- mirror
- misspell
- noctx
- nolintlint
- perfsprint
- prealloc
- revive
- rowserrcheck
- spancheck
- sqlclosecheck
- testifylint
- unconvert
- whitespace
linters-settings:
exhaustive:
default-signifies-exhaustive: true
goimports:
local-prefixes: github.com/smartcontractkit/chainlink
golint:
min-confidence: 1.0
gosec:
excludes:
- G101
- G104
# - G204
# - G304
# - G404
govet:
enable:
- shadow
revive:
confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
# - name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
# - name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
- name: waitgroup-by-value
- name: unconditional-recursion
- name: struct-tag
# - name: string-format
- name: string-of-int
- name: range-val-address
- name: range-val-in-closure
- name: modifies-value-receiver
- name: modifies-parameter
- name: identical-branches
- name: get-return
# - name: flag-parameter
- name: early-return
- name: defer
- name: constant-logical-expr
# - name: confusing-naming
# - name: confusing-results
- name: bool-literal-in-expr
- name: atomic
depguard:
rules:
main:
list-mode: lax
deny:
- pkg: cosmossdk.io/errors
desc: Use the standard library instead
- pkg: github.com/gofrs/uuid
desc: Use github.com/google/uuid instead
- pkg: github.com/jackc/pgx3
desc: Use github.com/jackc/pgx4 instead
- pkg: github.com/jackc/pgx5
desc: Use github.com/jackc/pgx4 instead
- pkg: github.com/satori/go.uuid
desc: Use github.com/google/uuid instead
- pkg: github.com/test-go/testify/assert
desc: Use github.com/stretchr/testify/assert instead
- pkg: github.com/test-go/testify/mock
desc: Use github.com/stretchr/testify/mock instead
- pkg: github.com/test-go/testify/require
desc: Use github.com/stretchr/testify/require instead
# TODO https://smartcontract-it.atlassian.net/browse/BCI-2589
# - pkg: go.uber.org/multierr
# desc: Use the standard library instead, for example https://pkg.go.dev/errors#Join
- pkg: gopkg.in/guregu/null.v1
desc: Use gopkg.in/guregu/null.v4 instead
- pkg: gopkg.in/guregu/null.v2
desc: Use gopkg.in/guregu/null.v4 instead
- pkg: gopkg.in/guregu/null.v3
desc: Use gopkg.in/guregu/null.v4 instead
- pkg: github.com/go-gorm/gorm
desc: Use github.com/jmoiron/sqlx directly instead
20 changes: 20 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
dir: "{{ .InterfaceDir }}/mocks"
mockname: "{{ .InterfaceName }}"
outpkg: mocks
filename: "{{ .InterfaceName | snakecase }}.go"
packages:
github.com/smartcontractkit/chainlink-framework/multinode:
config:
dir: "{{ .InterfaceDir }}"
filename: "mock_{{ .InterfaceName | snakecase }}_test.go"
inpackage: true
mockname: "mock{{ .InterfaceName | camelcase }}"
interfaces:
Node:
NodeSelector:
sendOnlyClient:
SendOnlyNode:
RPCClient:
Head:
PoolChainInfoProvider:
Subscription:
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (c) 2024 SmartContract ChainLink Limited SEZC

Portions of this software are licensed as follows:

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.PHONY: gomods
gomods: ## Install gomods
go install github.com/jmank88/gomods@v0.1.3

.PHONY: gomodtidy
gomodtidy: gomods
gomods tidy

.PHONY: mockery
mockery: $(mockery) ## Install mockery.
go install github.com/vektra/mockery/v2@v2.46.3

.PHONY: generate
generate: mockery
mockery

.PHONY: rm-mocked
rm-mocked:
grep -rl "^// Code generated by mockery" | grep .go$ | xargs -r rm

.PHONY: lint-workspace lint
GOLANGCI_LINT_VERSION := 1.62.2
GOLANGCI_LINT_COMMON_OPTS := --max-issues-per-linter 0 --max-same-issues 0
GOLANGCI_LINT_DIRECTORY := ./golangci-lint

lint-workspace:
@./script/lint.sh $(GOLANGCI_LINT_VERSION) "$(GOLANGCI_LINT_COMMON_OPTS)" $(GOLANGCI_LINT_DIRECTORY)

lint:
@./script/lint.sh $(GOLANGCI_LINT_VERSION) "$(GOLANGCI_LINT_COMMON_OPTS)" $(GOLANGCI_LINT_DIRECTORY) "--new-from-rev=origin/main"
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# chainlink-framework
# chainlink-framework

This repo contains common components created and maintained by the Blockchain Integrations Framework team.
These components are used across EVM and non-EVM chain integrations.

## Components

### MultiNode
Enables the use of multiple RPCs in chain integrations. Performs critical health checks,
load balancing, node metrics, and is used to send transactions to all RPCs and aggregate results.
MultiNode is used by all other components which require reading from or writing to the chain.

Loading
Loading