Skip to content

Commit

Permalink
Initial commit from v2
Browse files Browse the repository at this point in the history
  • Loading branch information
chray-zhang committed Jan 3, 2025
1 parent fe0c38b commit 8937472
Show file tree
Hide file tree
Showing 13 changed files with 443 additions and 318 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/integration-tests-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ env:
TEST_LOG_LEVEL: debug
CL_ECR: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/chainlink
ENV_JOB_IMAGE: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/chainlink-starknet-tests:${{ github.sha }}
GAUNTLET_PP_IMAGE: ${{ secrets.PROD_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.PROD_AWS_REGION }}.amazonaws.com/gauntlet-plus-plus:v2.5.0

jobs:
build_chainlink_image:
Expand Down Expand Up @@ -78,7 +79,7 @@ jobs:
echo "CUSTOM_CORE_REF=${{ github.event.inputs.cl_branch_ref }}" >> "${GITHUB_ENV}"
- name: Build Image ${{ matrix.image.name }}
if: steps.check-image.outputs.exists == 'false'
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/build-image@fc3e0df622521019f50d772726d6bf8dc919dd38 # v2.3.19
uses: smartcontractkit/.github/actions/ctf-build-image@c4705bfdbf6c8e57c080d82a3c4f013aa96a2dfb # v2.3.19
with:
cl_repo: smartcontractkit/chainlink
cl_ref: ${{ env.CUSTOM_CORE_REF }}
Expand Down Expand Up @@ -203,7 +204,7 @@ jobs:
# shellcheck disable=SC2086
echo "BASE64_CONFIG_OVERRIDE=$BASE64_CONFIG_OVERRIDE" >> $GITHUB_ENV
- name: Run Tests ${{ matrix.image.name }}
uses: smartcontractkit/.github/actions/ctf-run-tests@002596f65dc8eb807f5c8729dc1080921f7d0b24 # 0.2.1
uses: smartcontractkit/.github/actions/ctf-run-tests@4229fea727f6eb36b4559c6eefbbf9f3825fa677 # 0.2.1
with:
aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
test_command_to_run: nix develop -c sh -c "make test=${{ matrix.image.test-name }} test-integration-smoke-ci"
Expand All @@ -215,7 +216,11 @@ jobs:
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}
PROD_AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_OIDC_IAM_PROD_INTEGRATION_ROLE_ARN }}
artifacts_location: /home/runner/work/chainlink-starknet/chainlink-starknet/integration-tests/smoke/logs
PROD_AWS_REGION: ${{ secrets.PROD_AWS_REGION}}
PROD_AWS_ACCOUNT_NUMBER: ${{ secrets.PROD_AWS_ACCOUNT_NUMBER }}
gauntlet_plus_plus_image: ${{ secrets.PROD_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.PROD_AWS_REGION }}.amazonaws.com/gauntlet-plus-plus:v2.5.0
gati_token: ${{ steps.setup-github-token.outputs.access-token }}
env:
KILLGRAVE_INTERNAL_IMAGE: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/friendsofgo/killgrave
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/integration-tests-soak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable
- name: Install Cairo
uses: ./.github/actions/install-cairo
- name: Setup GitHub Token
id: setup-github-token
uses: smartcontractkit/.github/actions/setup-github-token@9e7cc0779934cae4a9028b8588c9adb64d8ce68c # setup-github-token@0.1.2
with:
aws-role-arn: ${{ secrets.AWS_OIDC_GLOBAL_READ_ONLY_TOKEN_ISSUER_ROLE_ARN }}
aws-lambda-url: ${{ secrets.GATI_RELENG_LAMBDA_URL }}
aws-region: ${{ secrets.QA_AWS_REGION }}
- name: Build contracts
run: |
cd contracts && scarb --profile release build
Expand All @@ -72,7 +79,7 @@ jobs:
echo "::add-mask::$BASE64_CONFIG_OVERRIDE"
echo "BASE64_CONFIG_OVERRIDE=$BASE64_CONFIG_OVERRIDE" >> "$GITHUB_ENV"
- name: Run Tests
uses: smartcontractkit/.github/actions/ctf-run-tests@002596f65dc8eb807f5c8729dc1080921f7d0b24 # 0.2.1
uses: smartcontractkit/.github/actions/ctf-run-tests@4229fea727f6eb36b4559c6eefbbf9f3825fa677 # 0.2.1
with:
aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
test_command_to_run: cd ./integration-tests && go test -timeout 24h -count=1 -run TestOCRBasicSoak/embedded ./soak
Expand All @@ -84,9 +91,12 @@ jobs:
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}
artifacts_location: /home/runner/work/chainlink-starknet/chainlink-starknet/integration-tests/soak/logs
PROD_AWS_REGION: ${{ secrets.PROD_AWS_REGION}}
PROD_AWS_ACCOUNT_NUMBER: ${{ secrets.PROD_AWS_ACCOUNT_NUMBER }}
gauntlet_plus_plus_image: ${{ secrets.PROD_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.PROD_AWS_REGION }}.amazonaws.com/gauntlet-plus-plus:v2.5.0
gati_token: ${{ steps.setup-github-token.outputs.access-token }}
env:
KILLGRAVE_INTERNAL_IMAGE: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/friendsofgo/killgrave
CHAINLINK_IMAGE: ${{ env.CL_ECR }}
CHAINLINK_VERSION: starknet.${{ github.sha }}${{ matrix.image.tag-suffix }}
CHAINLINK_USER_TEAM: ${{ github.event.inputs.team || 'BIX' }}

147 changes: 0 additions & 147 deletions integration-tests/common/gauntlet_common.go

This file was deleted.

137 changes: 128 additions & 9 deletions integration-tests/common/gauntlet_plus_plus_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,81 @@ package common

import (
"encoding/json"
"errors"
"fmt"
"os"
"github.com/smartcontractkit/chainlink-starknet/integration-tests/utils"
)

func (m *OCRv2TestState) fundNodesWithGPP() ([]string, error) {
l := utils.GetTestLogger(m.TestConfig.T)
var nAccounts []string
err := m.Clients.GauntletPPClient.DeclareOzAccount()
if err != nil {
return nil, err
}
for _, key := range m.GetNodeKeys() {
if key.TXKey.Data.Attributes.StarkKey == "" {
return nil, errors.New("stark key can't be empty")
}
//nAccount, err := m.Clients.GauntletClient.DeployAccountContract(100, key.TXKey.Data.Attributes.StarkKey)
nAccount, err := m.Clients.GauntletPPClient.DeployOzAccount(key.TXKey.Data.Attributes.StarkKey)
if err != nil {
return nil, err
}
nAccounts = append(nAccounts, nAccount)
}

if *m.Common.TestConfig.Common.Network == "testnet" {
for _, key := range nAccounts {
// We are not deploying in parallel here due to testnet limitations (429 too many requests)
l.Debug().Msg(fmt.Sprintf("Funding node with address: %s", key))
//_, err := m.Clients.GauntletClient.TransferToken(m.Common.ChainDetails.StarkTokenAddress, key, "10000000000000000000") // Transferring 10 STRK to each node
err := m.Clients.GauntletPPClient.TransferToken(m.Common.ChainDetails.StarkTokenAddress, key, "10000000000000000000")
if err != nil {
return nil, err
}
}
} else {
// The starknet provided mint method does not work so we send a req directly
for _, key := range nAccounts {
res, err := m.TestConfig.Resty.R().SetBody(map[string]any{
"address": key,
"amount": 900000000000000000,
}).Post("/mint")
if err != nil {
return nil, err
}
l.Info().Msg(fmt.Sprintf("Funding account (WEI): %s", string(res.Body())))
res, err = m.TestConfig.Resty.R().SetBody(map[string]any{
"address": key,
"amount": 900000000000000000,
"unit": m.Common.ChainDetails.TokenName,
}).Post("/mint")
if err != nil {
return nil, err
}
l.Info().Msg(fmt.Sprintf("Funding account (FRI): %s", string(res.Body())))
}
}

return nAccounts, nil
}

func (m *OCRv2TestState) deployAccessControllerWithGpp() error {
var err error
m.Contracts.AccessControllerAddr, err = m.Clients.GauntletPPClient.DeployAccessControllerContract(m.Account.Account)
err := m.Clients.GauntletPPClient.DeclareAccessControllerContract()
if err != nil {
return err
}
err = os.Setenv("BILLING_ACCESS_CONTROLLER", m.Contracts.AccessControllerAddr)

m.Contracts.AccessControllerAddr, err = m.Clients.GauntletPPClient.DeployAccessControllerContract(m.Account.Account)
if err != nil {
return err
}
return nil
}

func (m *OCRv2TestState) declareLinkToken() error {
err := m.Clients.GauntletPPClient.DeclareLinkTokenContract()
err = os.Setenv("BILLING_ACCESS_CONTROLLER", m.Contracts.AccessControllerAddr)
if err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -55,3 +108,69 @@ func (m *OCRv2TestState) setConfigDetailsWithGpp(ocrAddress string) error {
_, err = m.Clients.GauntletPPClient.SetConfigDetails(string(parsedConfig), ocrAddress)
return err
}

func (m *OCRv2TestState) setConfigDetails(ocrAddress string) error {
cfg, err := m.LoadOCR2Config()
if err != nil {
return err
}
var parsedConfig []byte
parsedConfig, err = json.Marshal(cfg)
if err != nil {
return err
}
_, err = m.Clients.GauntletClient.SetConfigDetails(string(parsedConfig), ocrAddress)
return err
}

func (m *OCRv2TestState) DeployGauntletPP(minSubmissionValue int64, maxSubmissionValue int64, decimals int, name string, observationPaymentGjuels int64, transmissionPaymentGjuels int64) error {
err := m.Clients.GauntletClient.InstallDependencies()
if err != nil {
return err
}

m.Clients.ChainlinkClient.AccountAddresses, err = m.fundNodesWithGPP()
if err != nil {
return err
}

err = m.deployLinkTokenWithGpp()
if err != nil {
return err
}

err = m.deployAccessControllerWithGpp()
if err != nil {
return err
}

m.Contracts.OCRAddr, err = m.Clients.GauntletPPClient.DeployOCR2ControllerContract(minSubmissionValue, maxSubmissionValue, decimals, name,
m.Contracts.LinkTokenAddr, m.Account.Account, m.Contracts.AccessControllerAddr)
if err != nil {
return err
}

m.Contracts.ProxyAddr, err = m.Clients.GauntletPPClient.DeployOCR2ControllerProxyContract(m.Account.Account, m.Contracts.OCRAddr)
if err != nil {
return err
}

err = m.Clients.GauntletPPClient.AddAccess(m.Contracts.OCRAddr, m.Contracts.ProxyAddr)
if err != nil {
return err
}

// Gauntlet PP does not have a mint op. We will use legacy gauntlet until we implement one
_, err = m.Clients.GauntletClient.MintLinkToken(m.Contracts.LinkTokenAddr, m.Contracts.OCRAddr, "100000000000000000000")
if err != nil {
return err
}

_, err = m.Clients.GauntletPPClient.SetOCRBilling(observationPaymentGjuels, transmissionPaymentGjuels, m.Contracts.OCRAddr)
if err != nil {
return err
}

err = m.setConfigDetails(m.Contracts.OCRAddr)
return err
}
Loading

0 comments on commit 8937472

Please sign in to comment.