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

Merge latest v2.12 into release branch #1021

Merged
merged 33 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b3d431c
core/services: fix ocrWrapper saveError contexts (#13139)
jmank88 May 8, 2024
40a16b4
Merge pull request #13151 from smartcontractkit/BCF-3221-ocr-wrapper-…
snehaagni May 8, 2024
33bd15d
changed spammy error log to debug (#13153)
patrickhuie19 May 9, 2024
19967d4
Merge pull request #13160 from smartcontractkit/release/2.12.0-log-fix
snehaagni May 9, 2024
5ce0eb2
Updating changelog for 2.12.0 with cherry pick fix
snehaagni May 9, 2024
3c10100
Merge pull request #13163 from smartcontractkit/chore/update_changelo…
snehaagni May 9, 2024
119df08
BCF-3225 - Implement forwarder fallback if forwarder not present as a…
ilija42 May 17, 2024
1d0b861
Merge pull request #13246 from smartcontractkit/BCF-3225-forwarders-f…
ilija42 May 20, 2024
d133da4
Fix panic on mercury server error (#13231) (#13256)
samsondav May 20, 2024
5daefad
Fixed CPU usage issues caused by inefficiencies in HeadTracker (#13230)
dhaidashenko May 17, 2024
de1503c
Merge branch 'release/2.12.0' into hotfix/BCI-3285-optimise-headtrack…
dhaidashenko May 20, 2024
fa33885
Merge pull request #13260 from smartcontractkit/hotfix/BCI-3285-optim…
snehaagni May 20, 2024
88a27f4
Update CHANGELOG for 2.12.0 bugfixes
snehaagni May 20, 2024
b38cb0c
Merge pull request #13264 from smartcontractkit/chore/update-release-…
snehaagni May 20, 2024
4fbcf7d
Decouple ChainType from config string [SHIP-2001] (#13272)
friedemannf May 23, 2024
9dc5e51
Merge pull request #13316 from smartcontractkit/cherrypick-c7a6356
snehaagni May 24, 2024
0abe09d
Index only the fifth word to reduce the db size overhead (#13315)
mateusz-sekara May 24, 2024
19e366b
Merge branch 'release/2.12.0' into release-2.12.2-beta-only-fifth-word
reductionista May 24, 2024
5e27b2f
Merge pull request #13327 from smartcontractkit/release-2.12.2-beta-o…
snehaagni May 25, 2024
8585cc9
Add special transmitter for OCR2 feeds (#13323)
ilija42 May 28, 2024
636c5e1
Improve ocr2FeedsTransmitter FromAddress() fallback (#13343)
ilija42 May 28, 2024
aad0d68
Merge pull request #13341 from smartcontractkit/2.12.0-cherry-pick-oc…
ilija42 May 28, 2024
dc74f20
Update 2.12.0 Changelog with bugfixes
snehaagni May 28, 2024
a06b2f2
Merge pull request #13347 from smartcontractkit/chore/release-2.12.0-…
snehaagni May 28, 2024
b95fe98
core/services/pipeline: bridge task must continue after cancellation
jmank88 May 31, 2024
7e536c1
Merge pull request #13388 from smartcontractkit/release2.12.0-fix-bri…
momentmaker May 31, 2024
d202837
core/services/pipeline: use request context for deletion (#13404)
jmank88 Jun 3, 2024
2cf506b
core/services/pipeline: hide deadline from monitor
jmank88 Jun 4, 2024
4f1cb37
Merge pull request #13410 from smartcontractkit/overtime-query-logs
snehaagni Jun 5, 2024
5204bf9
Finalize date on changelog for 2.12.0
snehaagni Jun 5, 2024
ef8a79c
Merge pull request #13434 from smartcontractkit/chore/update-release-…
snehaagni Jun 5, 2024
ca19c40
Merge tag 'v2.12.0' into merge2.12-release
mateusz-sekara Jun 14, 2024
ad8b7f3
Bumping selectors and post merge fixes
mateusz-sekara Jun 14, 2024
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
86 changes: 20 additions & 66 deletions CHANGELOG.md

Large diffs are not rendered by default.

117 changes: 93 additions & 24 deletions common/config/chaintype.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import (
"strings"
)

// ChainType denotes the chain or network to work with
type ChainType string

// nolint
const (
ChainArbitrum ChainType = "arbitrum"
ChainCelo ChainType = "celo"
Expand All @@ -18,11 +16,103 @@ const (
ChainOptimismBedrock ChainType = "optimismBedrock"
ChainScroll ChainType = "scroll"
ChainWeMix ChainType = "wemix"
ChainXDai ChainType = "xdai" // Deprecated: use ChainGnosis instead
ChainXLayer ChainType = "xlayer"
ChainZkSync ChainType = "zksync"
)

// IsL2 returns true if this chain is a Layer 2 chain. Notably:
// - the block numbers used for log searching are different from calling block.number
// - gas bumping is not supported, since there is no tx mempool
func (c ChainType) IsL2() bool {
switch c {
case ChainArbitrum, ChainMetis:
return true
default:
return false
}
}

func (c ChainType) IsValid() bool {
switch c {
case "", ChainArbitrum, ChainCelo, ChainGnosis, ChainKroma, ChainMetis, ChainOptimismBedrock, ChainScroll, ChainWeMix, ChainXLayer, ChainZkSync:
return true
}
return false
}

func ChainTypeFromSlug(slug string) ChainType {
switch slug {
case "arbitrum":
return ChainArbitrum
case "celo":
return ChainCelo
case "gnosis", "xdai":
return ChainGnosis
case "kroma":
return ChainKroma
case "metis":
return ChainMetis
case "optimismBedrock":
return ChainOptimismBedrock
case "scroll":
return ChainScroll
case "wemix":
return ChainWeMix
case "xlayer":
return ChainXLayer
case "zksync":
return ChainZkSync
default:
return ChainType(slug)
}
}

type ChainTypeConfig struct {
value ChainType
slug string
}

func NewChainTypeConfig(slug string) *ChainTypeConfig {
return &ChainTypeConfig{
value: ChainTypeFromSlug(slug),
slug: slug,
}
}

func (c *ChainTypeConfig) MarshalText() ([]byte, error) {
if c == nil {
return nil, nil
}
return []byte(c.slug), nil
}

func (c *ChainTypeConfig) UnmarshalText(b []byte) error {
c.slug = string(b)
c.value = ChainTypeFromSlug(c.slug)
return nil
}

func (c *ChainTypeConfig) Slug() string {
if c == nil {
return ""
}
return c.slug
}

func (c *ChainTypeConfig) ChainType() ChainType {
if c == nil {
return ""
}
return c.value
}

func (c *ChainTypeConfig) String() string {
if c == nil {
return ""
}
return string(c.value)
}

var ErrInvalidChainType = fmt.Errorf("must be one of %s or omitted", strings.Join([]string{
string(ChainArbitrum),
string(ChainCelo),
Expand All @@ -35,24 +125,3 @@ var ErrInvalidChainType = fmt.Errorf("must be one of %s or omitted", strings.Joi
string(ChainXLayer),
string(ChainZkSync),
}, ", "))

// IsValid returns true if the ChainType value is known or empty.
func (c ChainType) IsValid() bool {
switch c {
case "", ChainArbitrum, ChainCelo, ChainGnosis, ChainKroma, ChainMetis, ChainOptimismBedrock, ChainScroll, ChainWeMix, ChainXDai, ChainXLayer, ChainZkSync:
return true
}
return false
}

// IsL2 returns true if this chain is a Layer 2 chain. Notably:
// - the block numbers used for log searching are different from calling block.number
// - gas bumping is not supported, since there is no tx mempool
func (c ChainType) IsL2() bool {
switch c {
case ChainArbitrum, ChainMetis:
return true
default:
return false
}
}
46 changes: 37 additions & 9 deletions common/txmgr/mocks/tx_manager.go

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

22 changes: 18 additions & 4 deletions common/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ type TxManager[
services.Service
Trigger(addr ADDR)
CreateTransaction(ctx context.Context, txRequest txmgrtypes.TxRequest[ADDR, TX_HASH]) (etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
GetForwarderForEOA(eoa ADDR) (forwarder ADDR, err error)
GetForwarderForEOA(ctx context.Context, eoa ADDR) (forwarder ADDR, err error)
GetForwarderForEOAOCR2Feeds(ctx context.Context, eoa, ocr2AggregatorID ADDR) (forwarder ADDR, err error)
RegisterResumeCallback(fn ResumeCallback)
SendNativeToken(ctx context.Context, chainID CHAIN_ID, from, to ADDR, value big.Int, gasLimit uint64) (etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
Reset(addr ADDR, abandon bool) error
Expand Down Expand Up @@ -545,11 +546,20 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) CreateTran
}

// Calls forwarderMgr to get a proper forwarder for a given EOA.
func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) GetForwarderForEOA(eoa ADDR) (forwarder ADDR, err error) {
func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) GetForwarderForEOA(ctx context.Context, eoa ADDR) (forwarder ADDR, err error) {
if !b.txConfig.ForwardersEnabled() {
return forwarder, fmt.Errorf("forwarding is not enabled, to enable set Transactions.ForwardersEnabled =true")
}
forwarder, err = b.fwdMgr.ForwarderFor(eoa)
forwarder, err = b.fwdMgr.ForwarderFor(ctx, eoa)
return
}

// GetForwarderForEOAOCR2Feeds calls forwarderMgr to get a proper forwarder for a given EOA and checks if its set as a transmitter on the OCR2Aggregator contract.
func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) GetForwarderForEOAOCR2Feeds(ctx context.Context, eoa, ocr2Aggregator ADDR) (forwarder ADDR, err error) {
if !b.txConfig.ForwardersEnabled() {
return forwarder, fmt.Errorf("forwarding is not enabled, to enable set Transactions.ForwardersEnabled =true")
}
forwarder, err = b.fwdMgr.ForwarderForOCR2Feeds(ctx, eoa, ocr2Aggregator)
return
}

Expand Down Expand Up @@ -646,9 +656,13 @@ func (n *NullTxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) Tri
func (n *NullTxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) CreateTransaction(ctx context.Context, txRequest txmgrtypes.TxRequest[ADDR, TX_HASH]) (etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error) {
return etx, errors.New(n.ErrMsg)
}
func (n *NullTxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) GetForwarderForEOA(addr ADDR) (fwdr ADDR, err error) {
func (n *NullTxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) GetForwarderForEOA(ctx context.Context, addr ADDR) (fwdr ADDR, err error) {
return fwdr, err
}
func (n *NullTxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) GetForwarderForEOAOCR2Feeds(ctx context.Context, _, _ ADDR) (fwdr ADDR, err error) {
return fwdr, err
}

func (n *NullTxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) Reset(addr ADDR, abandon bool) error {
return nil
}
Expand Down
6 changes: 5 additions & 1 deletion common/txmgr/types/forwarder_manager.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package types

import (
"context"

"github.com/smartcontractkit/chainlink-common/pkg/services"

"github.com/smartcontractkit/chainlink/v2/common/types"
)

//go:generate mockery --quiet --name ForwarderManager --output ./mocks/ --case=underscore
type ForwarderManager[ADDR types.Hashable] interface {
services.Service
ForwarderFor(addr ADDR) (forwarder ADDR, err error)
ForwarderFor(ctx context.Context, addr ADDR) (forwarder ADDR, err error)
ForwarderForOCR2Feeds(ctx context.Context, eoa, ocr2Aggregator ADDR) (forwarder ADDR, err error)
// Converts payload to be forwarder-friendly
ConvertPayload(dest ADDR, origPayload []byte) ([]byte, error)
}
46 changes: 37 additions & 9 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.

3 changes: 2 additions & 1 deletion core/chains/evm/client/config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"go.uber.org/multierr"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink/v2/common/config"

commonclient "github.com/smartcontractkit/chainlink/v2/common/client"
evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config"
Expand Down Expand Up @@ -55,7 +56,7 @@ func NewClientConfigs(
chainConfig := &evmconfig.EVMConfig{
C: &toml.EVMConfig{
Chain: toml.Chain{
ChainType: &chainType,
ChainType: config.NewChainTypeConfig(chainType),
FinalityDepth: finalityDepth,
FinalityTagEnabled: finalityTagEnabled,
NoNewHeadsThreshold: commonconfig.MustNewDuration(noNewHeadsThreshold),
Expand Down
2 changes: 0 additions & 2 deletions core/chains/evm/client/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ func TestPool_Dial(t *testing.T) {
if err == nil {
t.Cleanup(func() { assert.NoError(t, p.Close()) })
}
assert.True(t, p.ChainType().IsValid())
assert.False(t, p.ChainType().IsL2())
if test.errStr != "" {
require.Error(t, err)
Expand Down Expand Up @@ -333,7 +332,6 @@ func TestUnit_Pool_BatchCallContextAll(t *testing.T) {

p := evmclient.NewPool(logger.Test(t), defaultConfig.NodeSelectionMode(), defaultConfig.LeaseDuration(), time.Second*0, nodes, sendonlys, &cltest.FixtureChainID, "")

assert.True(t, p.ChainType().IsValid())
assert.False(t, p.ChainType().IsL2())
require.NoError(t, p.BatchCallContextAll(ctx, b))
}
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/chain_scoped.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (e *EVMConfig) ChainType() commonconfig.ChainType {
if e.C.ChainType == nil {
return ""
}
return commonconfig.ChainType(*e.C.ChainType)
return e.C.ChainType.ChainType()
}

func (e *EVMConfig) ChainID() *big.Int {
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func Test_chainScopedConfig_Validate(t *testing.T) {
t.Run("arbitrum-estimator", func(t *testing.T) {
t.Run("custom", func(t *testing.T) {
cfg := configWithChains(t, 0, &toml.Chain{
ChainType: ptr(string(commonconfig.ChainArbitrum)),
ChainType: commonconfig.NewChainTypeConfig(string(commonconfig.ChainArbitrum)),
GasEstimator: toml.GasEstimator{
Mode: ptr("BlockHistory"),
},
Expand Down Expand Up @@ -437,7 +437,7 @@ func Test_chainScopedConfig_Validate(t *testing.T) {
t.Run("optimism-estimator", func(t *testing.T) {
t.Run("custom", func(t *testing.T) {
cfg := configWithChains(t, 0, &toml.Chain{
ChainType: ptr(string(commonconfig.ChainOptimismBedrock)),
ChainType: commonconfig.NewChainTypeConfig(string(commonconfig.ChainOptimismBedrock)),
GasEstimator: toml.GasEstimator{
Mode: ptr("BlockHistory"),
},
Expand Down
Loading
Loading