Skip to content

Commit

Permalink
Merge pull request #13584 from smartcontractkit/augustus.starknet-patch
Browse files Browse the repository at this point in the history
Starknet Custom Release
  • Loading branch information
snehaagni authored Jun 17, 2024
2 parents ef8a79c + bfe8629 commit f5fab34
Show file tree
Hide file tree
Showing 42 changed files with 589 additions and 379 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-experts-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#db_update Add account_address_public_key to feeds_manager_chain_configs
5 changes: 5 additions & 0 deletions .changeset/sharp-plums-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Add option to include GasPriceSubunits pipeline to include gasPriceSubunits in median ocr2 transmission (only to be used with Starknet chain for now) #added #nops #updated
6 changes: 3 additions & 3 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
golang 1.21.7
mockery 2.42.2
nodejs 16.16.0
pnpm 8.11.0
postgres 13.3
nodejs 20.13.1
pnpm 8.15.8
postgres 15.1
helm 3.10.3
zig 0.11.0
golangci-lint 1.55.2
Expand Down
11 changes: 9 additions & 2 deletions core/internal/features/ocr2/features_ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,9 @@ fromBlock = %d
}))
t.Cleanup(servers[s].Close)
u, _ := url.Parse(servers[i].URL)
bridgeName := fmt.Sprintf("bridge%d", i)
require.NoError(t, apps[i].BridgeORM().CreateBridgeType(testutils.Context(t), &bridges.BridgeType{
Name: bridges.BridgeName(fmt.Sprintf("bridge%d", i)),
Name: bridges.BridgeName(bridgeName),
URL: models.WebURL(*u),
}))

Expand Down Expand Up @@ -488,9 +489,15 @@ juelsPerFeeCoinSource = """
answer1 [type=median index=0];
"""
gasPriceSource = """
// data source
dsp [type=bridge name="%s"];
dsp_parse [type=jsonparse path="data"];
dsp -> dsp_parse;
"""
[pluginConfig.juelsPerFeeCoinCache]
updateInterval = "1m"
`, ocrContractAddress, kbs[i].ID(), transmitters[i], fmt.Sprintf("bridge%d", i), i, slowServers[i].URL, i, blockBeforeConfig.Number().Int64(), chainReaderSpec, fmt.Sprintf("bridge%d", i), i, slowServers[i].URL, i), nil)
`, ocrContractAddress, kbs[i].ID(), transmitters[i], bridgeName, i, slowServers[i].URL, i, blockBeforeConfig.Number().Int64(), chainReaderSpec, bridgeName, i, slowServers[i].URL, i, bridgeName), nil)
require.NoError(t, err)
err = apps[i].AddJobV2(testutils.Context(t), &ocrJob)
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/prometheus/client_golang v1.17.0
github.com/shopspring/decimal v1.3.1
github.com/smartcontractkit/chainlink-automation v1.0.3
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240429120925-907b29311feb
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614192253-77cca30c8a12
github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c
Expand Down Expand Up @@ -53,7 +53,7 @@ require (
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/NethermindEth/juno v0.3.1 // indirect
github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1 // indirect
github.com/NethermindEth/starknet.go v0.7.1-0.20240401080518-34a506f3cfdb // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/XSAM/otelsql v0.27.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
Expand Down Expand Up @@ -258,9 +258,9 @@ require (
github.com/smartcontractkit/chain-selectors v1.0.10 // indirect
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240419213354-ea34a948e2ee // indirect
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 // indirect
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240422130241-13c17a91b2ab // indirect
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240617141425-d184a59a6b42 // indirect
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240422172640-59d47c73ba58 // indirect
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240325075535-0f7eb05ee595 // indirect
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240617160336-d23102a8ba32 // indirect
github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1 // indirect
github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230906073235-9e478e5e19f1 // indirect
github.com/smartcontractkit/wsrpc v0.8.1 // indirect
Expand Down
16 changes: 8 additions & 8 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/NethermindEth/juno v0.3.1 h1:AW72LiAm9gqUeCVJWvepnZcTnpU4Vkl0KzPMxS+42FA=
github.com/NethermindEth/juno v0.3.1/go.mod h1:SGbTpgGaCsxhFsKOid7Ylnz//WZ8swtILk+NbHGsk/Q=
github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1 h1:9SBvy3eZut1X+wEyAFqfb7ADGj8IQw7ZnlkMwz0YOTY=
github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1/go.mod h1:V6qrbi1+fTDCftETIT1grBXIf+TvWP/4Aois1a9EF1E=
github.com/NethermindEth/starknet.go v0.7.1-0.20240401080518-34a506f3cfdb h1:Mv8SscePPyw2ju4igIJAjFgcq5zCQfjgbz53DwYu5mc=
github.com/NethermindEth/starknet.go v0.7.1-0.20240401080518-34a506f3cfdb/go.mod h1:gQkhWpAs9/QR6reZU2xoi1UIYlMS64FLTlh9CrgHH/Y=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
Expand Down Expand Up @@ -1185,18 +1185,18 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq
github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.3 h1:h/ijT0NiyV06VxYVgcNfsE3+8OEzT3Q0Z9au0z1BPWs=
github.com/smartcontractkit/chainlink-automation v1.0.3/go.mod h1:RjboV0Qd7YP+To+OrzHGXaxUxoSONveCoAK2TQ1INLU=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240429120925-907b29311feb h1:nJ9dkgvX5vdpFWhYufnRUAiNvNHsXkoBL6C0bDerq/k=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240429120925-907b29311feb/go.mod h1:GTDBbovHUSAUk+fuGIySF2A/whhdtHGaWmU61BoERks=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614192253-77cca30c8a12 h1:L+sWJRyl7veCiHeOAjEaiahodvU+ACRzVKhfVsfQMdg=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614192253-77cca30c8a12/go.mod h1:IZaCD+a40hs6uL7s5r1gBwL5G+hP3LU6lfOVh21c6T8=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240419213354-ea34a948e2ee h1:eFuBKyEbL2b+eyfgV/Eu9+8HuCEev+IcBi+K9l1dG7g=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240419213354-ea34a948e2ee/go.mod h1:uATrrJ8IsuBkOBJ46USuf73gz9gZy5k5bzGE5/ji/rc=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 h1:xFSv8561jsLtF6gYZr/zW2z5qUUAkcFkApin2mnbYTo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540/go.mod h1:sjAmX8K2kbQhvDarZE1ZZgDgmHJ50s0BBc/66vKY2ek=
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240422130241-13c17a91b2ab h1:Ct1oUlyn03HDUVdFHJqtRGRUujMqdoMzvf/Cjhe30Ag=
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240422130241-13c17a91b2ab/go.mod h1:RPUY7r8GxgzXxS1ijtU1P/fpJomOXztXgUbEziNmbCA=
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240617141425-d184a59a6b42 h1:9Xn2xfKdHORnbzU3A5JodXNNLPf8gp0wSaBR5hNFDUA=
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240617141425-d184a59a6b42/go.mod h1:PJlzwLaYsA7YcAKXdysMjNONeIolPrRjT9v/AMo4Er0=
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240422172640-59d47c73ba58 h1:jc4ab5QrKZfkICyxJysCt7mSExuSPbePjgZsnJR3nRQ=
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240422172640-59d47c73ba58/go.mod h1:oV5gIuSKrPEcjQ6uB6smBsm5kXHxyydVLNyAs4V9CoQ=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240325075535-0f7eb05ee595 h1:y6ks0HsSOhPUueOmTcoxDQ50RCS1XINlRDTemZyHjFw=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240325075535-0f7eb05ee595/go.mod h1:vV6WfnVIbK5Q1JsIru4YcTG0T1uRpLJm6t2BgCnCSsg=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240617160336-d23102a8ba32 h1:9yNZQT/Iel7k7Lo/+PKr/F1LXCasF/Mo0Y1SNgzOD/o=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240617160336-d23102a8ba32/go.mod h1:Fqkjgw9r7sT0D6OvRyygm1sqeBE1XNtbmHkz9RFhNZg=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772 h1:LQmRsrzzaYYN3wEU1l5tWiccznhvbyGnu2N+wHSXZAo=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs=
github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo=
Expand Down
8 changes: 1 addition & 7 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ func TestConfig_Validate(t *testing.T) {
toml string
exp string
}{
{name: "invalid", toml: invalidTOML, exp: `invalid configuration: 7 errors:
{name: "invalid", toml: invalidTOML, exp: `invalid configuration: 6 errors:
- P2P.V2.Enabled: invalid value (false): P2P required for OCR or OCR2. Please enable P2P or disable OCR/OCR2.
- Database.Lock.LeaseRefreshInterval: invalid value (6s): must be less than or equal to half of LeaseDuration (10s)
- WebServer: 8 errors:
Expand Down Expand Up @@ -1312,12 +1312,6 @@ func TestConfig_Validate(t *testing.T) {
- 0.URL: missing: required for all nodes
- 1.URL: missing: required for all nodes
- 2: 2 errors:
- ChainID: missing: required for all chains
- Nodes: missing: must have at least one node
- Starknet: 3 errors:
- 0.Nodes.1.Name: invalid value (primary): duplicate - must be unique
- 0.ChainID: missing: required for all chains
- 1: 2 errors:
- ChainID: missing: required for all chains
- Nodes: missing: must have at least one node`},
} {
Expand Down
14 changes: 0 additions & 14 deletions core/services/chainlink/testdata/config-invalid.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,6 @@ Name = 'bar'

[[Solana]]

[[Starknet]]

[[Starknet.Nodes]]
Name = 'primary'
URL = 'http://stark.node'
APIKey = 'key'

[[Starknet.Nodes]]
Name = 'primary'
URL = 'http://second.stark.node'
APIKey = 'key'

[[Starknet]]

[OCR2]
Enabled = true

Expand Down
30 changes: 17 additions & 13 deletions core/services/feeds/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,17 @@ func (p *Plugins) Scan(value interface{}) error {
type ChainType string

const (
ChainTypeUnknown ChainType = "UNKNOWN"
ChainTypeEVM ChainType = "EVM"
ChainTypeUnknown ChainType = "UNKNOWN"
ChainTypeEVM ChainType = "EVM"
ChainTypeStarknet ChainType = "STARKNET"
)

func NewChainType(s string) (ChainType, error) {
switch s {
case "EVM":
return ChainTypeEVM, nil
case "STARKNET":
return ChainTypeStarknet, nil
default:
return ChainTypeUnknown, errors.New("invalid chain type")
}
Expand All @@ -103,17 +106,18 @@ type FeedsManager struct {

// ChainConfig defines the chain configuration for a Feeds Manager.
type ChainConfig struct {
ID int64
FeedsManagerID int64
ChainID string
ChainType ChainType
AccountAddress string
AdminAddress string
FluxMonitorConfig FluxMonitorConfig
OCR1Config OCR1Config
OCR2Config OCR2ConfigModel
CreatedAt time.Time
UpdatedAt time.Time
ID int64
FeedsManagerID int64
ChainID string
ChainType ChainType
AccountAddress string
AccountAddressPublicKey null.String
AdminAddress string
FluxMonitorConfig FluxMonitorConfig
OCR1Config OCR1Config
OCR2Config OCR2ConfigModel
CreatedAt time.Time
UpdatedAt time.Time
}

// FluxMonitorConfig defines configuration for FluxMonitorJobs.
Expand Down
5 changes: 5 additions & 0 deletions core/services/feeds/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func Test_NewChainType(t *testing.T) {
give: "EVM",
want: ChainTypeEVM,
},
{
name: "Starknet Chain Type",
give: "STARKNET",
want: ChainTypeStarknet,
},
{
name: "Invalid Chain Type",
give: "",
Expand Down
22 changes: 13 additions & 9 deletions core/services/feeds/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ RETURNING id;
// CreateChainConfig creates a new chain config.
func (o *orm) CreateChainConfig(ctx context.Context, cfg ChainConfig) (id int64, err error) {
stmt := `
INSERT INTO feeds_manager_chain_configs (feeds_manager_id, chain_id, chain_type, account_address, admin_address, flux_monitor_config, ocr1_config, ocr2_config, created_at, updated_at)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,NOW(),NOW())
INSERT INTO feeds_manager_chain_configs (feeds_manager_id, chain_id, chain_type, account_address, account_address_public_key, admin_address, flux_monitor_config, ocr1_config, ocr2_config, created_at, updated_at)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,NOW(),NOW())
RETURNING id;
`

Expand All @@ -113,6 +113,7 @@ RETURNING id;
cfg.ChainID,
cfg.ChainType,
cfg.AccountAddress,
cfg.AccountAddressPublicKey,
cfg.AdminAddress,
cfg.FluxMonitorConfig,
cfg.OCR1Config,
Expand All @@ -129,7 +130,7 @@ func (o *orm) CreateBatchChainConfig(ctx context.Context, cfgs []ChainConfig) (i
}

stmt := `
INSERT INTO feeds_manager_chain_configs (feeds_manager_id, chain_id, chain_type, account_address, admin_address, flux_monitor_config, ocr1_config, ocr2_config, created_at, updated_at)
INSERT INTO feeds_manager_chain_configs (feeds_manager_id, chain_id, chain_type, account_address, account_address_public_key, admin_address, flux_monitor_config, ocr1_config, ocr2_config, created_at, updated_at)
VALUES %s
RETURNING id;
`
Expand All @@ -141,16 +142,16 @@ RETURNING id;

for i, cfg := range cfgs {
// Generate the placeholders
pnumidx := i * 8
pnumidx := i * 9

lo, hi := pnumidx+1, pnumidx+8
lo, hi := pnumidx+1, pnumidx+9
pnums := make([]any, hi-lo+1)
for i := range pnums {
pnums[i] = i + lo
}

vStrs = append(vStrs, fmt.Sprintf(
"($%d, $%d, $%d, $%d, $%d, $%d, $%d, $%d, NOW(), NOW())", pnums...,
"($%d, $%d, $%d, $%d, $%d, $%d, $%d, $%d, $%d, NOW(), NOW())", pnums...,
))

// Append the values
Expand All @@ -159,6 +160,7 @@ RETURNING id;
cfg.ChainID,
cfg.ChainType,
cfg.AccountAddress,
cfg.AccountAddressPublicKey,
cfg.AdminAddress,
cfg.FluxMonitorConfig,
cfg.OCR1Config,
Expand Down Expand Up @@ -192,7 +194,7 @@ RETURNING id;
// GetChainConfig fetches a chain config.
func (o *orm) GetChainConfig(ctx context.Context, id int64) (*ChainConfig, error) {
stmt := `
SELECT id, feeds_manager_id, chain_id, chain_type, account_address, admin_address, flux_monitor_config, ocr1_config, ocr2_config, created_at, updated_at
SELECT id, feeds_manager_id, chain_id, chain_type, account_address, account_address_public_key, admin_address, flux_monitor_config, ocr1_config, ocr2_config, created_at, updated_at
FROM feeds_manager_chain_configs
WHERE id = $1;
`
Expand All @@ -207,7 +209,7 @@ WHERE id = $1;
// ids.
func (o *orm) ListChainConfigsByManagerIDs(ctx context.Context, mgrIDs []int64) ([]ChainConfig, error) {
stmt := `
SELECT id, feeds_manager_id, chain_id, chain_type, account_address, admin_address, flux_monitor_config, ocr1_config, ocr2_config, created_at, updated_at
SELECT id, feeds_manager_id, chain_id, chain_type, account_address, account_address_public_key, admin_address, flux_monitor_config, ocr1_config, ocr2_config, created_at, updated_at
FROM feeds_manager_chain_configs
WHERE feeds_manager_id = ANY($1)
`
Expand All @@ -227,8 +229,9 @@ SET account_address = $1,
flux_monitor_config = $3,
ocr1_config = $4,
ocr2_config = $5,
account_address_public_key = $6,
updated_at = NOW()
WHERE id = $6
WHERE id = $7
RETURNING id;
`

Expand All @@ -239,6 +242,7 @@ RETURNING id;
cfg.FluxMonitorConfig,
cfg.OCR1Config,
cfg.OCR2Config,
cfg.AccountAddressPublicKey,
cfg.ID,
)

Expand Down
Loading

0 comments on commit f5fab34

Please sign in to comment.