Skip to content

Commit

Permalink
Merge branch 'develop' into re-2756/goreleaser-build-image
Browse files Browse the repository at this point in the history
* develop:
  [CCIP Merge] Capabilities [CCIP-2943] (#14068)
  add OZ 5.0.2 contracts (#14065)
  enable gomods (#14042)
  auto-10161: replicate v2_3 to v2_3_zksync (#14035)
  chore: update dependabot config gomod (#14063)
  Update log trigger default values (#14051)
  bump solana commit (#14062)
  Update e2e tests definition for CI and automation workflow (#13908)
  use services.Config.NewService/Engine (#13851)
  • Loading branch information
momentmaker committed Aug 7, 2024
2 parents a903b20 + 6ab3eb5 commit 2073502
Show file tree
Hide file tree
Showing 148 changed files with 19,260 additions and 1,143 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-radios-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#added merging core/capabilities/ccip from https://github.com/smartcontractkit/ccip
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ updates:
directory: "/"
schedule:
interval: monthly
open-pull-requests-limit: 10
open-pull-requests-limit: 0
ignore:
# Old versions are pinned for libocr.
- dependency-name: github.com/libp2p/go-libp2p-core
Expand Down
32 changes: 28 additions & 4 deletions .github/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ runner-test-matrix:
test_env_type: k8s-remote-runner
runs_on: ubuntu-latest
test_cmd: cd integration-tests/ && go test soak/ocr_test.go -v -test.run ^TestOCRv1Soak$ -test.parallel=1 -timeout 30m -count=1 -json
test_config_override_required: true
test_secrets_required: true
test_inputs:
test_suite: soak

Expand Down Expand Up @@ -543,15 +545,37 @@ runner-test-matrix:
chainlink_upgrade_version: develop
pyroscope_env: ci-smoke-automation-upgrade-tests

- id: integration-tests/reorg/automation_reorg_test.go
- id: integration-tests/reorg/automation_reorg_test.go^TestAutomationReorg/registry_2_0
path: integration-tests/reorg/automation_reorg_test.go
runs_on: ubuntu-latest
test_env_type: k8s-remote-runner
test_env_type: docker
test_inputs:
test_suite: reorg
workflows:
- Run Automation On Demand Tests (TEST WORKFLOW)
test_cmd: cd integration-tests/reorg && DETACH_RUNNER=false go test -v -test.run ^TestAutomationReorg/registry_2_0 -test.parallel=1 -timeout 30m -count=1 -json
pyroscope_env: ci-automation-on-demand-reorg

- id: integration-tests/reorg/automation_reorg_test.go^TestAutomationReorg/registry_2_1
path: integration-tests/reorg/automation_reorg_test.go
runs_on: ubuntu-latest
test_env_type: docker
test_inputs:
test_suite: reorg
workflows:
- Run Automation On Demand Tests (TEST WORKFLOW)
test_cmd: cd integration-tests/reorg && DETACH_RUNNER=false go test -v -test.run ^TestAutomationReorg/registry_2_1 -test.parallel=2 -timeout 30m -count=1 -json
pyroscope_env: ci-automation-on-demand-reorg

- id: integration-tests/reorg/automation_reorg_test.go^TestAutomationReorg/registry_2_2
path: integration-tests/reorg/automation_reorg_test.go
runs_on: ubuntu-latest
test_env_type: docker
test_inputs:
test_suite: reorg
workflows:
- Run Automation On Demand Tests (TEST WORKFLOW)
test_cmd: cd integration-tests/reorg && DETACH_RUNNER=false go test -v -test.run ^TestAutomationReorg$ -test.parallel=7 -timeout 60m -count=1 -json
test_cmd: cd integration-tests/reorg && DETACH_RUNNER=false go test -v -test.run ^TestAutomationReorg/registry_2_2 -test.parallel=2 -timeout 30m -count=1 -json
pyroscope_env: ci-automation-on-demand-reorg

- id: integration-tests/chaos/automation_chaos_test.go
Expand All @@ -560,7 +584,7 @@ runner-test-matrix:
runs_on: ubuntu-latest
workflows:
- Run Automation On Demand Tests (TEST WORKFLOW)
test_cmd: cd integration-tests/chaos && DETACH_RUNNER=false go test -v -test.run ^TestAutomationChaos$ -test.parallel=15 -timeout 60m -count=1 -json
test_cmd: cd integration-tests/chaos && DETACH_RUNNER=false go test -v -test.run ^TestAutomationChaos$ -test.parallel=20 -timeout 60m -count=1 -json
pyroscope_env: ci-automation-on-demand-chaos
test_inputs:
test_suite: chaos
Expand Down
4 changes: 4 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ packages:
github.com/smartcontractkit/chainlink/v2/core/bridges:
interfaces:
ORM:
github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types:
interfaces:
CCIPOracle:
OracleCreator:
github.com/smartcontractkit/chainlink/v2/core/capabilities/remote/types:
interfaces:
Dispatcher:
Expand Down
18 changes: 5 additions & 13 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ gomod: ## Ensure chainlink's go dependencies are installed.
go mod download

.PHONY: gomodtidy
gomodtidy: ## Run go mod tidy on all modules.
go mod tidy
cd ./core/scripts && go mod tidy
cd ./integration-tests && go mod tidy
cd ./integration-tests/load && go mod tidy
cd ./dashboard-lib && go mod tidy
gomodtidy: gomods ## Run go mod tidy on all modules.
gomods tidy

.PHONY: docs
docs: ## Install and run pkgsite to view Go docs
Expand Down Expand Up @@ -89,12 +85,8 @@ abigen: ## Build & install abigen.
./tools/bin/build_abigen

.PHONY: generate
generate: abigen codecgen mockery protoc ## Execute all go:generate commands.
go generate -x ./...
cd ./core/scripts && go generate -x ./...
cd ./integration-tests && go generate -x ./...
cd ./integration-tests/load && go generate -x ./...
cd ./dashboard-lib && go generate -x ./...
generate: abigen codecgen mockery protoc gomods ## Execute all go:generate commands.
gomods -w go generate -x ./...
mockery

.PHONY: rm-mocked
Expand Down Expand Up @@ -136,7 +128,7 @@ presubmit: ## Format go files and imports.

.PHONY: gomods
gomods: ## Install gomods
go install github.com/jmank88/[email protected].1
go install github.com/jmank88/[email protected].3

.PHONY: mockery
mockery: $(mockery) ## Install mockery.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ THE SOFTWARE.


*All content residing under (1) “/contracts/src/v0.8/ccip”; (2)
“/core/gethwrappers/ccip”; (3) “/core/services/ocr2/plugins/ccip” are licensed
“/core/gethwrappers/ccip”; (3) “/core/services/ocr2/plugins/ccip”; (4) "/core/capabilities/ccip" are licensed
under “Business Source License 1.1” with a Change Date of May 23, 2027 and
Change License to “MIT License”

Expand Down
70 changes: 26 additions & 44 deletions common/headtracker/head_broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ type HeadBroadcaster[H types.Head[BLOCK_HASH], BLOCK_HASH types.Hashable] interf
}

type headBroadcaster[H types.Head[BLOCK_HASH], BLOCK_HASH types.Hashable] struct {
services.StateMachine
logger logger.Logger
services.Service
eng *services.Engine

callbacks callbackSet[H, BLOCK_HASH]
mailbox *mailbox.Mailbox[H]
mutex sync.Mutex
chClose services.StopChan
wgDone sync.WaitGroup
latest H
lastCallbackID int
}
Expand All @@ -60,41 +59,29 @@ func NewHeadBroadcaster[
](
lggr logger.Logger,
) HeadBroadcaster[H, BLOCK_HASH] {
return &headBroadcaster[H, BLOCK_HASH]{
logger: logger.Named(lggr, "HeadBroadcaster"),
hb := &headBroadcaster[H, BLOCK_HASH]{
callbacks: make(callbackSet[H, BLOCK_HASH]),
mailbox: mailbox.NewSingle[H](),
chClose: make(chan struct{}),
}
hb.Service, hb.eng = services.Config{
Name: "HeadBroadcaster",
Start: hb.start,
Close: hb.close,
}.NewServiceEngine(lggr)
return hb
}

func (hb *headBroadcaster[H, BLOCK_HASH]) Start(context.Context) error {
return hb.StartOnce("HeadBroadcaster", func() error {
hb.wgDone.Add(1)
go hb.run()
return nil
})
}

func (hb *headBroadcaster[H, BLOCK_HASH]) Close() error {
return hb.StopOnce("HeadBroadcaster", func() error {
hb.mutex.Lock()
// clear all callbacks
hb.callbacks = make(callbackSet[H, BLOCK_HASH])
hb.mutex.Unlock()

close(hb.chClose)
hb.wgDone.Wait()
return nil
})
func (hb *headBroadcaster[H, BLOCK_HASH]) start(context.Context) error {
hb.eng.Go(hb.run)
return nil
}

func (hb *headBroadcaster[H, BLOCK_HASH]) Name() string {
return hb.logger.Name()
}

func (hb *headBroadcaster[H, BLOCK_HASH]) HealthReport() map[string]error {
return map[string]error{hb.Name(): hb.Healthy()}
func (hb *headBroadcaster[H, BLOCK_HASH]) close() error {
hb.mutex.Lock()
// clear all callbacks
hb.callbacks = make(callbackSet[H, BLOCK_HASH])
hb.mutex.Unlock()
return nil
}

func (hb *headBroadcaster[H, BLOCK_HASH]) BroadcastNewLongestChain(head H) {
Expand All @@ -121,26 +108,24 @@ func (hb *headBroadcaster[H, BLOCK_HASH]) Subscribe(callback HeadTrackable[H, BL
return
}

func (hb *headBroadcaster[H, BLOCK_HASH]) run() {
defer hb.wgDone.Done()

func (hb *headBroadcaster[H, BLOCK_HASH]) run(ctx context.Context) {
for {
select {
case <-hb.chClose:
case <-ctx.Done():
return
case <-hb.mailbox.Notify():
hb.executeCallbacks()
hb.executeCallbacks(ctx)
}
}
}

// DEV: the head relayer makes no promises about head delivery! Subscribing
// Jobs should expect to the relayer to skip heads if there is a large number of listeners
// and all callbacks cannot be completed in the allotted time.
func (hb *headBroadcaster[H, BLOCK_HASH]) executeCallbacks() {
func (hb *headBroadcaster[H, BLOCK_HASH]) executeCallbacks(ctx context.Context) {
head, exists := hb.mailbox.Retrieve()
if !exists {
hb.logger.Info("No head to retrieve. It might have been skipped")
hb.eng.Info("No head to retrieve. It might have been skipped")
return
}

Expand All @@ -149,17 +134,14 @@ func (hb *headBroadcaster[H, BLOCK_HASH]) executeCallbacks() {
hb.latest = head
hb.mutex.Unlock()

hb.logger.Debugw("Initiating callbacks",
hb.eng.Debugw("Initiating callbacks",
"headNum", head.BlockNumber(),
"numCallbacks", len(callbacks),
)

wg := sync.WaitGroup{}
wg.Add(len(callbacks))

ctx, cancel := hb.chClose.NewCtx()
defer cancel()

for _, callback := range callbacks {
go func(trackable HeadTrackable[H, BLOCK_HASH]) {
defer wg.Done()
Expand All @@ -168,7 +150,7 @@ func (hb *headBroadcaster[H, BLOCK_HASH]) executeCallbacks() {
defer cancel()
trackable.OnNewLongestChain(cctx, head)
elapsed := time.Since(start)
hb.logger.Debugw(fmt.Sprintf("Finished callback in %s", elapsed),
hb.eng.Debugw(fmt.Sprintf("Finished callback in %s", elapsed),
"callbackType", reflect.TypeOf(trackable), "blockNumber", head.BlockNumber(), "time", elapsed)
}(callback)
}
Expand Down
Loading

0 comments on commit 2073502

Please sign in to comment.