Skip to content

Commit e9ce873

Browse files
authored
Merge branch 'main' into cre-1322
2 parents 9247261 + 36f3382 commit e9ce873

File tree

9 files changed

+114
-56
lines changed

9 files changed

+114
-56
lines changed

.github/workflows/golangci_lint.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
name: Golangci-lint
22

3-
on: [pull_request]
3+
on: [pull_request, merge_group]
44

55
jobs:
66
golangci-lint:
7+
# Avoid running in merge queue since we run in PR's and have an optional
8+
# label to skip lint issues on a PR which would be ignored in the merge queue.
9+
if: ${{ github.event_name != 'merge_group' }}
710
runs-on: ubuntu-latest
811
permissions:
912
id-token: write
1013
contents: read
1114
actions: read
15+
pull-requests: read
1216
steps:
1317
- name: Checkout code
1418
uses: actions/checkout@v5

.github/workflows/keystore.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Keystore Checks
22
permissions:
33
contents: read
44

5-
on: push
5+
on: [push, merge_group]
66

77
jobs:
88
changes:

.github/workflows/pkg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: PKG Build and Test
22

3-
on: [push]
3+
on: [push, merge_group]
44

55
jobs:
66
build-test:

pkg/settings/cresettings/defaults.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"LogLineLimit": "1kb",
4343
"LogEventLimit": "1000",
4444
"CRONTrigger": {
45+
"FastestScheduleInterval": "30s",
4546
"RateLimit": "every30s:1"
4647
},
4748
"HTTPTrigger": {

pkg/settings/cresettings/defaults.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ LogLineLimit = '1kb'
4343
LogEventLimit = '1000'
4444

4545
[PerWorkflow.CRONTrigger]
46+
FastestScheduleInterval = '30s'
4647
RateLimit = 'every30s:1'
4748

4849
[PerWorkflow.HTTPTrigger]

pkg/settings/cresettings/settings.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ import (
1616
. "github.com/smartcontractkit/chainlink-common/pkg/settings"
1717
)
1818

19-
func init() {
20-
if v, ok := os.LookupEnv("CL_CRE_SETTINGS_DEFAULT"); ok {
19+
const (
20+
envNameSettings = "CL_CRE_SETTINGS"
21+
envNameSettingsDefault = "CL_CRE_SETTINGS_DEFAULT"
22+
)
23+
24+
func init() { reinit() }
25+
func reinit() {
26+
if v, ok := os.LookupEnv(envNameSettingsDefault); ok {
2127
err := json.Unmarshal([]byte(v), &Default)
2228
if err != nil {
2329
log.Fatalf("failed to initialize defaults: %v", err)
@@ -29,7 +35,7 @@ func init() {
2935
}
3036
Config = Default
3137

32-
if v, ok := os.LookupEnv("CL_CRE_SETTINGS"); ok {
38+
if v, ok := os.LookupEnv(envNameSettings); ok {
3339
DefaultGetter, err = NewJSONGetter([]byte(v))
3440
if err != nil {
3541
log.Fatalf("failed to initialize settings: %v", err)
@@ -99,7 +105,8 @@ var Default = Schema{
99105
LogEventLimit: Int(1_000),
100106

101107
CRONTrigger: cronTrigger{
102-
RateLimit: Rate(rate.Every(30*time.Second), 1),
108+
FastestScheduleInterval: Duration(30 * time.Second),
109+
RateLimit: Rate(rate.Every(30*time.Second), 1),
103110
},
104111
HTTPTrigger: httpTrigger{
105112
RateLimit: Rate(rate.Every(30*time.Second), 3),
@@ -214,6 +221,7 @@ type Workflows struct {
214221
}
215222

216223
type cronTrigger struct {
224+
FastestScheduleInterval Setting[time.Duration]
217225
// Deprecated: to be removed
218226
RateLimit Setting[config.Rate]
219227
}

pkg/settings/cresettings/settings_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"golang.org/x/time/rate"
1616

1717
"github.com/smartcontractkit/chainlink-common/pkg/config"
18+
"github.com/smartcontractkit/chainlink-common/pkg/contexts"
1819
)
1920

2021
var update = flag.Bool("update", false, "update the golden files of this test")
@@ -110,3 +111,50 @@ func TestSchema_Unmarshal(t *testing.T) {
110111
assert.Equal(t, uint64(500000), cfg.PerWorkflow.ChainWrite.EVM.TransactionGasLimit.DefaultValue)
111112
assert.Equal(t, 3, cfg.PerWorkflow.ChainRead.CallLimit.DefaultValue)
112113
}
114+
115+
func TestDefaultGetter(t *testing.T) {
116+
limit := Default.PerWorkflow.HTTPAction.CallLimit
117+
118+
ctx := contexts.WithCRE(t.Context(), contexts.CRE{Owner: "owner-id", Workflow: "foo"})
119+
overrideCtx := contexts.WithCRE(t.Context(), contexts.CRE{Owner: "owner-id", Workflow: "test-wf-id"})
120+
121+
// Default 5
122+
got, err := limit.GetOrDefault(ctx, DefaultGetter)
123+
require.NoError(t, err)
124+
require.Equal(t, 5, got)
125+
126+
// No override
127+
got, err = limit.GetOrDefault(overrideCtx, DefaultGetter)
128+
require.NoError(t, err)
129+
require.Equal(t, 5, got)
130+
131+
t.Cleanup(reinit) // restore default vars
132+
t.Setenv(envNameSettings, `{
133+
"workflow": {
134+
"test-wf-id": {
135+
"PerWorkflow": {
136+
"HTTPAction": {
137+
"CallLimit": "20"
138+
}
139+
}
140+
}
141+
}
142+
}`)
143+
reinit() // set default vars
144+
145+
_ = `
146+
[workflow.test-wf-id]
147+
PerWorkflow.HTTPAction.CallLimit = 20
148+
`
149+
150+
// Default unchanged
151+
got, err = limit.GetOrDefault(ctx, DefaultGetter)
152+
require.NoError(t, err)
153+
require.Equal(t, 5, got)
154+
155+
// Override applied
156+
got, err = limit.GetOrDefault(overrideCtx, DefaultGetter)
157+
require.NoError(t, err)
158+
require.Equal(t, 20, got)
159+
160+
}

pkg/settings/toml.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func CombineTOMLFiles(files fs.FS) ([]byte, error) {
4444
tree.Set("workflow", workflows)
4545
var b bytes.Buffer
4646
e := toml.NewEncoder(&b).Indentation("")
47+
e.Order(toml.OrderAlphabetical)
4748
err = e.Encode(tree)
4849
return b.Bytes(), err
4950
}

pkg/types/ccipocr3/chainaccessor.go

Lines changed: 44 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,9 @@ import (
88
"github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives"
99
)
1010

11-
// ChainFeeComponents redeclares the ChainFeeComponents type from the chainlink-common/pkg/types to avoid
12-
// a cyclic dependency caused by provider_ccip_ocr3.go importing this package.
13-
type ChainFeeComponents struct {
14-
// The cost of executing transaction in the chain's EVM (or the L2 environment).
15-
ExecutionFee *big.Int
16-
17-
// The cost associated with an L2 posting a transaction's data to the L1.
18-
DataAvailabilityFee *big.Int
19-
}
20-
21-
// ChainAccessor for all direct chain access. The accessor is responsible for
22-
// in addition to direct access to the chain, this interface also translates
23-
// onchain representations of data to the plugin representation.
11+
// ChainAccessor is responsible for direct access to the chain. In addition
12+
// to direct access, this interface also translates onchain representations
13+
// of data to the plugin representation.
2414
type ChainAccessor interface {
2515
AllAccessors
2616
SourceAccessor
@@ -29,12 +19,10 @@ type ChainAccessor interface {
2919
PriceReader
3020
}
3121

32-
// AllAccessors contains functionality that is available to all types of accessors.
22+
// AllAccessors contains functionality that is available to all types of accessors (source and dest).
3323
type AllAccessors interface {
34-
// GetContractAddress returns the contract address that is registered for the provided contract name and chain.
35-
// WARNING: This function will fail if the oracle does not support the requested chain.
36-
//
37-
// TODO(NONEVM-1865): do we want to mark this as deprecated in favor of Metadata()?
24+
// GetContractAddress returns the contract address that is registered for the provided contract name
25+
// on the chain associated with the specific accessor implementation.
3826
GetContractAddress(contractName string) ([]byte, error)
3927

4028
// GetAllConfig is the next iteration of GetAllConfigsLegacy(). Instead of returning a large snapshot
@@ -49,19 +37,18 @@ type AllAccessors interface {
4937
// GetAllConfigsLegacy returns a snapshot of all chain configurations for this chain using the legacy
5038
// config structs.
5139
//
52-
// destChainSelector is used to determine whether or not destination chain specific configs should be fetched.
53-
// sourceChainSelectors is used to determine which source chain configs should be fetched.
40+
// When called on a destination chain accessor:
41+
// - destChainSelector should match the accessor's chain
42+
// - sourceChainSelectors determines which source chain configs to fetch from the OffRamp
43+
// - Returns ChainConfigSnapshot with OffRamp, FeeQuoter, RMNProxy, RMNRemote, CurseInfo configs
44+
// - Returns map of SourceChainConfig for each requested source chain
5445
//
55-
// This includes the following contracts:
56-
// - Router
57-
// - OffRamp
58-
// - OnRamp
59-
// - FeeQuoter
60-
// - RMNProxy
61-
// - RMNRemote
62-
// - CurseInfo
46+
// When called on a source chain accessor:
47+
// - destChainSelector is used to fetch OnRamp dest chain specific configs
48+
// - sourceChainSelectors will likely be empty and/or ignored by the accessor impl
49+
// - Returns ChainConfigSnapshot with OnRamp, FeeQuoter, Router configs
50+
// - Returns empty map for source chain configs
6351
//
64-
// Access Type: Method(many, see code)
6552
// Contract: Many
6653
// Confidence: Unconfirmed
6754
GetAllConfigsLegacy(
@@ -70,24 +57,24 @@ type AllAccessors interface {
7057
sourceChainSelectors []ChainSelector,
7158
) (ChainConfigSnapshot, map[ChainSelector]SourceChainConfig, error)
7259

73-
// GetChainFeeComponents Returns all fee components for given chains if corresponding
74-
// chain writer is available.
60+
// GetChainFeeComponents returns all fee components for the chain.
7561
//
76-
// Access Type: ChainWriter
7762
// Contract: N/A
7863
// Confidence: N/A
7964
GetChainFeeComponents(ctx context.Context) (ChainFeeComponents, error)
8065

81-
// Sync can be used to perform frequent syncing operations inside the reader implementation.
82-
// Returns an error if the sync operation failed.
66+
// Sync binds a contract to the accessor implementation by contract name and address so the accessor
67+
// can use the contract addresses for subsequent calls. This is used to dynamically discover and bind
68+
// contracts (e.g., OnRamps, FeeQuoter, RMNRemote).
69+
// Returns an error if the bind operation failed.
8370
Sync(ctx context.Context, contractName string, contractAddress UnknownAddress) error
8471
}
8572

86-
// DestinationAccessor contains all functions typically associated by the destination chain.
73+
// DestinationAccessor contains all functions typically associated with the destination chain.
8774
type DestinationAccessor interface {
8875

8976
// CommitReportsGTETimestamp reads CommitReportAccepted events starting from a given timestamp.
90-
// The number of results are limited according to limit.
77+
// The number of results is limited according to the limit parameter.
9178
//
9279
// Access Type: Event(CommitReportAccepted)
9380
// Contract: OffRamp
@@ -113,31 +100,32 @@ type DestinationAccessor interface {
113100
confidence primitives.ConfidenceLevel,
114101
) (map[ChainSelector][]SeqNum, error)
115102

116-
// NextSeqNum reads the source chain config to get the next expected
117-
// sequence number for the given source chains.
103+
// NextSeqNum reads the source chain config from the OffRamp to get the next expected
104+
// sequence number (MinSeqNr) for the given source chains.
118105
//
119-
// Access Type: Method(NextSeqNum)
106+
// Access Type: Method(GetSourceChainConfig)
120107
// Contract: OffRamp
121108
// Confidence: Unconfirmed
122109
NextSeqNum(ctx context.Context, sources []ChainSelector) (map[ChainSelector]SeqNum, error)
123110

124-
// Nonces for all provided selector/address pairs. Addresses must be encoded
111+
// Nonces returns nonces for all provided selector/address pairs. Addresses must be encoded
125112
// according to the source chain requirements by using the AddressCodec.
126113
//
127114
// Access Type: Method(GetInboundNonce)
128115
// Contract: NonceManager
129116
// Confidence: Unconfirmed
130117
Nonces(ctx context.Context, addresses map[ChainSelector][]UnknownEncodedAddress) (map[ChainSelector]map[string]uint64, error)
131118

132-
// GetChainFeePriceUpdate Gets latest chain fee price update for the provided chains.
119+
// GetChainFeePriceUpdate returns the latest chain fee price update for the provided selectors. This queries
120+
// the FeeQuoter contract on the chain accociated with this accessor.
133121
//
134122
// Access Type: Method(GetChainFeePriceUpdate)
135123
// Contract: FeeQuoter
136124
// Confidence: Unconfirmed
137125
GetChainFeePriceUpdate(ctx context.Context, selectors []ChainSelector) (map[ChainSelector]TimestampedUnixBig, error)
138126

139127
// GetLatestPriceSeqNr returns the latest price sequence number for the destination chain.
140-
// Not to confuse with the sequence number of the messages. This is the OCR sequence number.
128+
// Not to be confused with the sequence number of the messages. This is the OCR sequence number.
141129
//
142130
// Access Type: Method(GetLatestPriceSequenceNumber)
143131
// Contract: OffRamp
@@ -164,23 +152,20 @@ type SourceAccessor interface {
164152
LatestMessageTo(ctx context.Context, dest ChainSelector) (SeqNum, error)
165153

166154
// GetExpectedNextSequenceNumber returns the expected next sequence number
167-
// messages being sent to the provided destination.
155+
// for messages being sent to the provided destination.
168156
//
169157
// Access Type: Method(GetExpectedNextSequenceNumber)
170158
// Contract: OnRamp
171159
// Confidence: Unconfirmed
172160
GetExpectedNextSequenceNumber(ctx context.Context, dest ChainSelector) (SeqNum, error)
173161

174-
// GetTokenPriceUSD looks up a token price in USD. The address value should
175-
// be retrieved from a configuration cache (i.e. ConfigPoller).
162+
// GetTokenPriceUSD looks up a token price in USD for the provided address.
163+
// Serves as a general price interface for fetching both LINK price and wrapped
164+
// native token price in USD.
176165
//
177166
// Access Type: Method(GetTokenPrice)
178167
// Contract: FeeQuoter
179168
// Confidence: Unconfirmed
180-
//
181-
// Notes: This function is new and serves as a general price interface for
182-
// both LinkPriceUSD and GetWrappedNativeTokenPriceUSD.
183-
// See Design Doc (Combined Token Price Helper) for notes.
184169
GetTokenPriceUSD(ctx context.Context, address UnknownAddress) (TimestampedUnixBig, error)
185170

186171
// GetFeeQuoterDestChainConfig returns the fee quoter destination chain config.
@@ -222,3 +207,13 @@ type PriceReader interface {
222207
tokensBytes []UnknownAddress,
223208
) (map[UnknownEncodedAddress]TimestampedUnixBig, error)
224209
}
210+
211+
// ChainFeeComponents redeclares the ChainFeeComponents type from the chainlink-common/pkg/types to avoid
212+
// a cyclic dependency caused by provider_ccip_ocr3.go importing this package.
213+
type ChainFeeComponents struct {
214+
// The cost of executing transaction in the chain's EVM (or the L2 environment).
215+
ExecutionFee *big.Int
216+
217+
// The cost associated with an L2 posting a transaction's data to the L1.
218+
DataAvailabilityFee *big.Int
219+
}

0 commit comments

Comments
 (0)