Skip to content

Commit 5d83a28

Browse files
authored
Merge pull request #695 from smartcontractkit/feature/bump-starknet-go
Starknet 0.14.3 readiness: starknet.go v0.17.1, devnet-rs 0.8.2, G++ 2.6.6
2 parents 175063b + e9743dd commit 5d83a28

84 files changed

Lines changed: 2220 additions & 1290 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.envrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
watch_file shell.nix
1+
watch_file shell.nix shell-ci.nix
22
use flake

.github/actions/build-test-image/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ runs:
2828
- name: Install Cairo
2929
uses: ./.github/actions/install-cairo
3030
with:
31-
use_musl_libc: "true"
31+
use_musl_libc: "false"
32+
- name: Build Cairo contracts
33+
shell: bash
34+
run: cd contracts && scarb --profile release build
3235
- name: Check if image exists
3336
id: check-image
3437
uses: smartcontractkit/chainlink-github-actions/docker/image-exists@fc3e0df622521019f50d772726d6bf8dc919dd38 # v2.3.19

.github/workflows/integration-tests-smoke.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ jobs:
131131
aws-role-arn: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
132132
aws-account-number: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
133133

134-
134+
# Validates chainlink-starknet-tests Docker build (smoke + soak compile). Runs in
135+
# parallel with Chainlink image builds; does not gate Run Smoke Tests.
135136
build_test_image:
136137
environment: integration
137138
permissions:
@@ -163,7 +164,7 @@ jobs:
163164
run_tests:
164165
name: Run Smoke Tests
165166
runs-on: ubuntu24.04-16cores-64GB
166-
needs: [build_multiplatform_image, build_test_image]
167+
needs: [build_multiplatform_image]
167168
environment: integration
168169
env:
169170
INTERNAL_DOCKER_REPO: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com
@@ -177,10 +178,6 @@ jobs:
177178
uses: actions/checkout@v5
178179
with:
179180
persist-credentials: false
180-
- name: Install Nix
181-
uses: cachix/install-nix-action@3715ab1a11cac9e991980d7b4a28d80c7ebdd8f9 # nix:v2.24.6
182-
with:
183-
nix_path: nixpkgs=channel:nixos-unstable
184181
- name: Install Cairo
185182
uses: ./.github/actions/install-cairo
186183
- name: Setup GitHub Token
@@ -190,6 +187,10 @@ jobs:
190187
aws-role-arn: ${{ secrets.AWS_OIDC_CHAINLINK_READ_ONLY_TOKEN_ISSUER_ROLE_ARN }}
191188
aws-lambda-url: ${{ secrets.GATI_RELENG_LAMBDA_URL }}
192189
aws-region: ${{ secrets.QA_AWS_REGION }}
190+
- name: Setup GitHub private repo access
191+
uses: ./.github/actions/setup-github-private-access
192+
with:
193+
gati_token: ${{ steps.setup-github-token.outputs.access-token }}
193194
- name: Build contracts
194195
run: |
195196
cd contracts && scarb --profile release build
@@ -217,8 +218,8 @@ jobs:
217218
with:
218219
cl_internal_docker_repo: ${{ env.INTERNAL_DOCKER_REPO }}
219220
aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
220-
test_command_to_run: nix develop -c sh -c "make test-integration-smoke-ci"
221-
test_download_vendor_packages_command: cd integration-tests && nix develop -c go mod download
221+
test_command_to_run: make test-integration-smoke-ci
222+
test_download_vendor_packages_command: cd integration-tests && go mod download
222223
cl_repo: ${{ env.CL_ECR }}/chainlink
223224
cl_image_tag: starknet.${{ env.SN_SHA }}
224225
token: ${{ secrets.GITHUB_TOKEN }}
@@ -230,11 +231,12 @@ jobs:
230231
artifacts_location: /home/runner/work/chainlink-starknet/chainlink-starknet/integration-tests/smoke/logs
231232
PROD_AWS_REGION: ${{ secrets.PROD_AWS_REGION}}
232233
PROD_AWS_ACCOUNT_NUMBER: ${{ secrets.PROD_AWS_ACCOUNT_NUMBER }}
233-
gauntlet_plus_plus_image: ${{ secrets.PROD_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.PROD_AWS_REGION }}.amazonaws.com/gauntlet-plus-plus:v2.5.20
234234
gati_token: ${{ steps.setup-github-token.outputs.access-token }}
235235
enable-gap: false
236236
env:
237237
KILLGRAVE_INTERNAL_IMAGE: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/friendsofgo/killgrave
238238
CHAINLINK_IMAGE: ${{ env.CL_ECR }}/chainlink
239239
CHAINLINK_VERSION: starknet.${{ env.SN_SHA }}
240240
CHAINLINK_USER_TEAM: ${{ github.event.inputs.team || 'DF' }}
241+
GATI_TOKEN: ${{ steps.setup-github-token.outputs.access-token }}
242+
GAUNTLET_PLUS_PLUS_VERSION: "2.6.6"

.github/workflows/integration-tests-soak.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ jobs:
4444
uses: actions/checkout@v5
4545
with:
4646
persist-credentials: false
47-
- name: Install Nix
48-
uses: cachix/install-nix-action@3715ab1a11cac9e991980d7b4a28d80c7ebdd8f9 # nix:v2.24.6
49-
with:
50-
nix_path: nixpkgs=channel:nixos-unstable
5147
- name: Install Cairo
5248
uses: ./.github/actions/install-cairo
5349
- name: Setup GitHub Token
@@ -57,6 +53,10 @@ jobs:
5753
aws-role-arn: ${{ secrets.AWS_OIDC_CHAINLINK_READ_ONLY_TOKEN_ISSUER_ROLE_ARN }}
5854
aws-lambda-url: ${{ secrets.GATI_RELENG_LAMBDA_URL }}
5955
aws-region: ${{ secrets.QA_AWS_REGION }}
56+
- name: Setup GitHub private repo access
57+
uses: ./.github/actions/setup-github-private-access
58+
with:
59+
gati_token: ${{ steps.setup-github-token.outputs.access-token }}
6060
- name: Build contracts
6161
run: |
6262
cd contracts && scarb --profile release build
@@ -73,8 +73,8 @@ jobs:
7373
uses: smartcontractkit/.github/actions/ctf-run-tests@4229fea727f6eb36b4559c6eefbbf9f3825fa677 # 0.2.1
7474
with:
7575
aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
76-
test_command_to_run: cd ./integration-tests && go test -timeout 24h -count=1 -run TestOCRBasicSoak ./soak
77-
test_download_vendor_packages_command: cd integration-tests && nix develop -c go mod download
76+
test_command_to_run: eval "$(./integration-tests/scripts/download-gauntlet-plus-plus.sh)" && cd ./integration-tests && go test -timeout 24h -count=1 -run TestOCRBasicSoak ./soak
77+
test_download_vendor_packages_command: cd integration-tests && go mod download
7878
cl_repo: ${{ env.CL_ECR }}
7979
token: ${{ secrets.GITHUB_TOKEN }}
8080
go_mod_path: ./integration-tests/go.mod
@@ -84,10 +84,11 @@ jobs:
8484
artifacts_location: /home/runner/work/chainlink-starknet/chainlink-starknet/integration-tests/soak/logs
8585
PROD_AWS_REGION: ${{ secrets.PROD_AWS_REGION}}
8686
PROD_AWS_ACCOUNT_NUMBER: ${{ secrets.PROD_AWS_ACCOUNT_NUMBER }}
87-
gauntlet_plus_plus_image: ${{ secrets.PROD_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.PROD_AWS_REGION }}.amazonaws.com/gauntlet-plus-plus:v2.5.20
8887
gati_token: ${{ steps.setup-github-token.outputs.access-token }}
8988
env:
9089
KILLGRAVE_INTERNAL_IMAGE: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/friendsofgo/killgrave
9190
CHAINLINK_IMAGE: ${{ env.CL_ECR }}
9291
CHAINLINK_VERSION: starknet.${{ github.sha }}${{ matrix.image.tag-suffix }}
9392
CHAINLINK_USER_TEAM: ${{ github.event.inputs.team || 'BIX' }}
93+
GATI_TOKEN: ${{ steps.setup-github-token.outputs.access-token }}
94+
GAUNTLET_PLUS_PLUS_VERSION: "2.6.6"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,4 @@ eslint-report.json
168168
.run.id
169169
.local-mock-server
170170
override*.toml
171+
.cache/

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,32 +207,43 @@ test-integration-go: env-devnet-hardhat
207207
cd ./relayer && go test -json ./... -run TestIntegration -tags integration 2>&1 | tee $(LOG_PATH) | gotestloghelper -ci
208208

209209
.PHONY: test-integration-prep
210-
test-integration-prep:
211-
cd ./contracts
212-
make build
210+
test-integration-prep: build-go-relayer build-cairo-contracts
211+
212+
# Used by integration-tests/test.Dockerfile: Cairo is built on the CI runner before
213+
# docker build (see build-test-image action); the minimal .#ci shell only compiles Go.
214+
.PHONY: test-integration-docker-prep
215+
test-integration-docker-prep: build-go-relayer
213216

214217
.PHONY: test-integration
215218
test-integration: test-integration-smoke test-integration-contracts test-integration-gauntlet
216219

220+
.PHONY: download-gauntlet-plus-plus
221+
download-gauntlet-plus-plus:
222+
@eval "$$(./integration-tests/scripts/download-gauntlet-plus-plus.sh)"
223+
217224
.PHONY: test-integration-smoke
218225
test-integration-smoke: test-integration-prep
226+
@eval "$$(./integration-tests/scripts/download-gauntlet-plus-plus.sh)" && \
219227
cd integration-tests/ && \
220228
go test --timeout=2h -v ./smoke
221229

222230
# CI Already has already ran test-integration-prep
223231
.PHONY: test-integration-smoke-ci
224232
test-integration-smoke-ci:
233+
@eval "$$(./integration-tests/scripts/download-gauntlet-plus-plus.sh)" && \
225234
cd integration-tests/ && \
226235
go test --timeout=2h -v -count=1 -run TestOCRBasic -json ./smoke | tee /tmp/gotest.log | gotestloghelper -ci -singlepackage
227236

228237
.PHONY: test-integration-soak
229238
test-integration-soak: test-integration-prep
239+
@eval "$$(./integration-tests/scripts/download-gauntlet-plus-plus.sh)" && \
230240
cd integration-tests/ && \
231241
go test --timeout=1h -v -json ./soak
232242

233243
# CI Already has already ran test-integration-prep
234244
.PHONY: test-integration-soak-ci
235245
test-integration-soak-ci:
246+
@eval "$$(./integration-tests/scripts/download-gauntlet-plus-plus.sh)" && \
236247
cd integration-tests/ && \
237248
go test --timeout=1h -v -count=1 -json ./soak
238249

contracts/test/account.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ class AllowanceFundingStrategy implements IFundingStrategy {
7676
nodeUrl: constants.NetworkName.SN_SEPOLIA,
7777
})
7878

79-
const operator = new Account(provider, opts.accountAddr, opts.keyPair)
79+
const operator = new Account({
80+
provider,
81+
address: opts.accountAddr,
82+
signer: opts.keyPair,
83+
})
8084

8185
for (const account of accounts) {
8286
const data = [

contracts/test/emergency/StarknetValidator.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import { abi as starknetMessagingAbi } from '../../artifacts/vendor/starkware-li
22
import { abi as accessControllerAbi } from '../../artifacts/@chainlink/contracts/src/v0.8/interfaces/AccessControllerInterface.sol/AccessControllerInterface.json'
33
import { abi as aggregatorAbi } from '../../artifacts/@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol/AggregatorV3Interface.json'
44
import { fetchStarknetAccount, getStarknetContractArtifacts, waitForTransactions } from '../utils'
5-
import { Contract as StarknetContract, RpcProvider, CallData, Account, hash } from 'starknet'
5+
import {
6+
Contract as StarknetContract,
7+
RpcProvider,
8+
CallData,
9+
Account,
10+
hash,
11+
BlockTag,
12+
} from 'starknet'
613
import { deployMockContract, MockContract } from '@ethereum-waffle/mock-contract'
714
import { BigNumber, Contract as EthersContract, ContractFactory } from 'ethers'
815
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
@@ -13,7 +20,10 @@ import { ethers } from 'hardhat'
1320
import { expect } from 'chai'
1421

1522
describe('StarknetValidator', () => {
16-
const provider = new RpcProvider({ nodeUrl: STARKNET_DEVNET_URL })
23+
const provider = new RpcProvider({
24+
nodeUrl: STARKNET_DEVNET_URL,
25+
blockIdentifier: BlockTag.LATEST,
26+
})
1727
const opts = account.makeFunderOptsFromEnv()
1828
const funder = new account.Funder(opts)
1929

@@ -48,7 +58,11 @@ describe('StarknetValidator', () => {
4858

4959
// Creates a starknet contract instance for the l2 feed
5060
const { abi: l2FeedAbi } = await provider.getClassByHash(ddL2Contract.declare.class_hash)
51-
l2Contract = new StarknetContract(l2FeedAbi, ddL2Contract.deploy.address, provider)
61+
l2Contract = new StarknetContract({
62+
abi: l2FeedAbi,
63+
address: ddL2Contract.deploy.address,
64+
providerOrAccount: provider,
65+
})
5266

5367
// Fetch predefined L1 EOA accounts
5468
const accounts = await ethers.getSigners()

contracts/test/l1-l2-messaging.ts

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,63 @@
11
import { ETH_DEVNET_URL, STARKNET_DEVNET_URL } from './constants'
22

33
//
4-
// Docs: https://github.com/0xSpaceShard/starknet-devnet-rs/blob/main/contracts/l1-l2-messaging/README.md#ethereum-setup
4+
// Docs: https://0xspaceshard.github.io/starknet-devnet/docs/postman
55
//
66

77
/*
8-
* https://github.com/0xSpaceShard/starknet-devnet-rs/blob/7e5ff351198f799816c1857c1048bf8ee7f89428/crates/starknet-devnet-server/src/api/http/models.rs#L23
8+
* https://github.com/0xSpaceShard/starknet-devnet-rs/blob/main/crates/starknet-devnet-server/src/api/http/models.rs#L23
99
*/
1010
export type PostmanLoadL1MessagingContract = Readonly<{
1111
networkUrl?: string
1212
address?: string
1313
}>
1414

1515
/*
16-
* https://github.com/0xSpaceShard/starknet-devnet-rs/blob/7e5ff351198f799816c1857c1048bf8ee7f89428/crates/starknet-devnet-server/src/api/http/models.rs#L132
16+
* https://github.com/0xSpaceShard/starknet-devnet-rs/blob/main/crates/starknet-devnet-server/src/api/http/models.rs#L132
1717
*/
1818
export type MessagingLoadAddress = Readonly<{
1919
messaging_contract_address: string
2020
}>
2121

22-
/*
23-
* https://github.com/0xSpaceShard/starknet-devnet-rs/blob/7e5ff351198f799816c1857c1048bf8ee7f89428/crates/starknet-devnet-server/src/api/http/endpoints/postman.rs#L12
24-
*/
25-
export const loadL1MessagingContract = async (
26-
params?: PostmanLoadL1MessagingContract,
27-
): Promise<MessagingLoadAddress> => {
28-
const res = await fetch(`${STARKNET_DEVNET_URL}/postman/load_l1_messaging_contract`, {
22+
type JsonRpcResponse<T> = {
23+
result?: T
24+
error?: { message: string }
25+
}
26+
27+
const devnetRpc = async <T>(method: string, params: Record<string, unknown>): Promise<T> => {
28+
const res = await fetch(`${STARKNET_DEVNET_URL}/rpc`, {
2929
method: 'POST',
3030
headers: {
3131
'Content-Type': 'application/json',
3232
},
3333
body: JSON.stringify({
34-
network_url: params?.networkUrl ?? ETH_DEVNET_URL,
35-
address: params?.address,
34+
jsonrpc: '2.0',
35+
id: 1,
36+
method,
37+
params,
3638
}),
3739
})
3840

39-
const result = await res.json()
40-
if (result.error != null) {
41-
throw new Error(result.error)
41+
const data = (await res.json()) as JsonRpcResponse<T>
42+
if (data.error != null) {
43+
throw new Error(data.error.message)
44+
}
45+
if (data.result == null) {
46+
throw new Error(`${method} returned no result`)
4247
}
43-
return result
48+
return data.result
49+
}
50+
51+
/*
52+
* starknet-devnet-rs 0.8+ removed HTTP /postman/load_l1_messaging_contract; use devnet_postmanLoad.
53+
*/
54+
export const loadL1MessagingContract = async (
55+
params?: PostmanLoadL1MessagingContract,
56+
): Promise<MessagingLoadAddress> => {
57+
return devnetRpc<MessagingLoadAddress>('devnet_postmanLoad', {
58+
network_url: params?.networkUrl ?? ETH_DEVNET_URL,
59+
...(params?.address != null && { messaging_contract_address: params.address }),
60+
})
4461
}
4562

4663
/*
@@ -82,22 +99,10 @@ export type FlushedMessages = Readonly<{
8299
}>
83100

84101
/*
85-
* https://github.com/0xSpaceShard/starknet-devnet-rs/blob/7e5ff351198f799816c1857c1048bf8ee7f89428/crates/starknet-devnet-server/src/api/http/endpoints/postman.rs#L26
102+
* starknet-devnet-rs 0.8+ removed HTTP /postman/flush; use devnet_postmanFlush.
86103
*/
87104
export const flush = async (params?: FlushParameters): Promise<FlushedMessages> => {
88-
const res = await fetch(`${STARKNET_DEVNET_URL}/postman/flush`, {
89-
method: 'POST',
90-
headers: {
91-
'Content-Type': 'application/json',
92-
},
93-
body: JSON.stringify({
94-
dry_run: params?.dryRun ?? false,
95-
}),
105+
return devnetRpc<FlushedMessages>('devnet_postmanFlush', {
106+
dry_run: params?.dryRun ?? false,
96107
})
97-
98-
const result = await res.json()
99-
if (result.error != null) {
100-
throw new Error(result.error)
101-
}
102-
return result
103108
}

contracts/test/ocr2/aggregator.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
hash,
1717
num,
1818
ec,
19+
BlockTag,
1920
} from 'starknet'
2021

2122
type Oracle = Readonly<{
@@ -31,7 +32,10 @@ const UINT128_MAX = BigInt(2) ** BigInt(128) - BigInt(1)
3132

3233
describe('Aggregator', function () {
3334
this.timeout(TIMEOUT)
34-
const provider = new RpcProvider({ nodeUrl: STARKNET_DEVNET_URL })
35+
const provider = new RpcProvider({
36+
nodeUrl: STARKNET_DEVNET_URL,
37+
blockIdentifier: BlockTag.LATEST,
38+
})
3539
const opts = account.makeFunderOptsFromEnv()
3640
const funder = new account.Funder(opts)
3741

@@ -64,7 +68,11 @@ describe('Aggregator', function () {
6468

6569
// Creates a starknet contract instance for token
6670
const { abi: tokenAbi } = await provider.getClassByHash(ddToken.declare.class_hash)
67-
token = new Contract(tokenAbi, ddToken.deploy.address, provider)
71+
token = new Contract({
72+
abi: tokenAbi,
73+
address: ddToken.deploy.address,
74+
providerOrAccount: provider,
75+
})
6876

6977
// Funds the owner account with some LINK
7078
await owner.execute(
@@ -109,7 +117,11 @@ describe('Aggregator', function () {
109117

110118
// Creates a starknet contract instance for aggregator
111119
const { abi: aggregatorAbi } = await provider.getClassByHash(ddAggregator.declare.class_hash)
112-
aggregator = new Contract(aggregatorAbi, ddAggregator.deploy.address, provider)
120+
aggregator = new Contract({
121+
abi: aggregatorAbi,
122+
address: ddAggregator.deploy.address,
123+
providerOrAccount: provider,
124+
})
113125

114126
// Defines the offchain config
115127
const onchain_config = new Array<number>()

0 commit comments

Comments
 (0)