Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Dec 6, 2024
1 parent 49be084 commit 325463f
Show file tree
Hide file tree
Showing 45 changed files with 628 additions and 147 deletions.
6 changes: 3 additions & 3 deletions common/client/mock_node_selector_test.go

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

6 changes: 3 additions & 3 deletions common/client/mock_node_test.go

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

6 changes: 3 additions & 3 deletions common/client/mock_send_only_node_test.go

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

6 changes: 3 additions & 3 deletions common/headtracker/mocks/head_broadcaster.go

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

6 changes: 3 additions & 3 deletions common/headtracker/mocks/head_tracker.go

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

6 changes: 3 additions & 3 deletions common/txmgr/mocks/tx_manager.go

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

6 changes: 3 additions & 3 deletions common/txmgr/types/mocks/forwarder_manager.go

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

6 changes: 3 additions & 3 deletions common/txmgr/types/mocks/tx_attempt_builder.go

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

9 changes: 9 additions & 0 deletions core/capabilities/ccip/oraclecreator/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr3/promwrapper"

"github.com/smartcontractkit/libocr/commontypes"
libocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus"
Expand Down Expand Up @@ -229,6 +230,12 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter(
) (ocr3types.ReportingPluginFactory[[]byte], ocr3types.ContractTransmitter[[]byte], error) {
var factory ocr3types.ReportingPluginFactory[[]byte]
var transmitter ocr3types.ContractTransmitter[[]byte]

chainID, err := chainsel.GetChainIDFromSelector(uint64(config.Config.ChainSelector))
if err != nil {
return nil, nil, fmt.Errorf("unsupported chain selector %d %w", config.Config.ChainSelector, err)
}

if config.Config.PluginType == uint8(cctypes.PluginTypeCCIPCommit) {
if !i.peerWrapper.IsStarted() {
return nil, nil, fmt.Errorf("peer wrapper is not started")
Expand Down Expand Up @@ -263,6 +270,7 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter(
rmnPeerClient,
rmnCrypto,
)
factory = promwrapper.NewReportingPluginFactory[[]byte](factory, chainID, "CCIPCommit")
transmitter = ocrimpls.NewCommitContractTransmitter[[]byte](destChainWriter,
ocrtypes.Account(destFromAccounts[0]),
hexutil.Encode(config.Config.OfframpAddress), // TODO: this works for evm only, how about non-evm?
Expand All @@ -283,6 +291,7 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter(
contractReaders,
chainWriters,
)
factory = promwrapper.NewReportingPluginFactory[[]byte](factory, chainID, "CCIPExec")
transmitter = ocrimpls.NewExecContractTransmitter[[]byte](destChainWriter,
ocrtypes.Account(destFromAccounts[0]),
hexutil.Encode(config.Config.OfframpAddress), // TODO: this works for evm only, how about non-evm?
Expand Down
10 changes: 10 additions & 0 deletions core/capabilities/compute/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,19 @@ func (c *Compute) worker(ctx context.Context) {
}

func (c *Compute) Close() error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

c.modules.close()
close(c.stopCh)

err := c.registry.Remove(ctx, CapabilityIDCompute)
if err != nil {
return err
}

c.wg.Wait()

return nil
}

Expand Down
15 changes: 15 additions & 0 deletions core/capabilities/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,21 @@ func (r *Registry) Add(ctx context.Context, c capabilities.BaseCapability) error
return nil
}

// Add adds a capability to the registry.
func (r *Registry) Remove(ctx context.Context, id string) error {
r.mu.Lock()
defer r.mu.Unlock()

_, ok := r.m[id]
if !ok {
return fmt.Errorf("unable to remove, capability not found: %s", id)
}

delete(r.m, id)
r.lggr.Infow("capability removed", "id", id)
return nil
}

// NewRegistry returns a new Registry.
func NewRegistry(lggr logger.Logger) *Registry {
return &Registry{
Expand Down
6 changes: 3 additions & 3 deletions core/capabilities/remote/types/mocks/dispatcher.go

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

6 changes: 3 additions & 3 deletions core/capabilities/targets/mocks/contract_writer.go

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

7 changes: 7 additions & 0 deletions core/capabilities/webapi/target/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"strings"
"time"

"github.com/smartcontractkit/chainlink-common/pkg/capabilities"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
Expand Down Expand Up @@ -57,6 +58,12 @@ func (c *Capability) Start(ctx context.Context) error {
}

func (c *Capability) Close() error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
err := c.registry.Remove(ctx, c.capabilityInfo.ID)
if err != nil {
return err
}
return nil
}

Expand Down
7 changes: 7 additions & 0 deletions core/capabilities/webapi/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"sync"
"time"

ethCommon "github.com/ethereum/go-ethereum/common"

Expand Down Expand Up @@ -256,6 +257,12 @@ func (h *triggerConnectorHandler) Start(ctx context.Context) error {
}
func (h *triggerConnectorHandler) Close() error {
return h.StopOnce("GatewayConnectorServiceWrapper", func() error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
err := h.registry.Remove(ctx, h.ID)
if err != nil {
return err
}
return nil
})
}
Expand Down
Loading

0 comments on commit 325463f

Please sign in to comment.