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

[TT-1608] Utilize Parrot #16574

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
82 changes: 44 additions & 38 deletions integration-tests/README_SETH.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
# Seth-Specific Instructions

## Table of Contents
1. [Introduction](#introduction)
2. [How to Set Configuration Values](#how-to-set-configuration-values)
1. [Example](#example)
2. [Documentation and Further Details](#documentation-and-further-details)
3. [How to Set Seth Logging Level](#how-to-set-seth-logging-level)
1. [Locally](#locally)
2. [Remote Runner](#remote-runner)
4. [How to Set Seth Network Configuration](#how-to-set-seth-network-configuration)
1. [Overview of Configuration Usage](#overview-of-configuration-usage)
2. [Seth-Specific Network Configuration](#seth-specific-network-configuration)
3. [Steps for Adding a New Network](#steps-for-adding-a-new-network)
1. [Network is Already Defined in known_networks.go](#network-is-already-defined-in-known_networksgo)
2. [It's a New Network](#its-a-new-network)
5. [How to Use Seth CLI](#how-to-use-seth-cli)
6. [How to Get Fallback (Hardcoded) Values](#how-to-get-fallback-hardcoded-values)
1. [Steps to Use Seth CLI for Fallback Values](#steps-to-use-seth-cli-for-fallback-values)
7. [Ephemeral and Static Keys Explained](#ephemeral-and-static-keys-explained)
1. [Understanding the Keys](#understanding-the-keys)
2. [How to Set Ephemeral Keys in the TOML](#how-to-set-ephemeral-keys-in-the-toml)
3. [How to Set Static Keys in the TOML](#how-to-set-static-keys-in-the-toml)
1. [As a List of Wallet Keys in Your Network Configuration](#as-a-list-of-wallet-keys-in-your-network-configuration)
2. [As Base64-Encoded Keyfile Stored as GHA Secret](#as-base64-encoded-keyfile-stored-as-gha-secret)
8. [How to Split Funds Between Static Keys](#how-to-split-funds-between-static-keys)
9. [How to Return Funds From Static Keys to the Root Key](#how-to-return-funds-from-static-keys-to-the-root-key)
1. [How to Rebalance or Top Up Static Keys](#how-to-rebalance-or-top-up-static-keys)
10. [How to Deal with "TX Fee Exceeds the Configured Cap" Error](#how-to-deal-with-tx-fee-exceeds-the-configured-cap-error)
11. [How to Use Seth's Synchronous API](#how-to-use-seths-synchronous-api)
12. [How to Read Event Data from Transactions](#how-to-read-event-data-from-transactions)
13. [How to Deal with Failed Transactions](#how-to-deal-with-failed-transactions)
14. [How Automated Gas Estimation Works](#how-automated-gas-estimation-works)
1. [Legacy Transactions](#legacy-transactions)
2. [EIP-1559 Transactions](#eip-1559-transactions)
3. [Adjustment Factor](#adjustment-factor)
4. [Buffer Percents](#buffer-percents)
18. [How to Tweak Automated Gas Estimation](#how-to-tweak-automated-gas-estimation)
19. [How to debug with 'execution reverted' error](#how-to-debug-with-execution-reverted-error)
20. [How to split non-native tokens between keys](#how-to-split-non-native-tokens-between-keys)
- [Seth-Specific Instructions](#seth-specific-instructions)
- [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
- [How to Set Configuration Values](#how-to-set-configuration-values)
- [Example:](#example)
- [Documentation and Further Details](#documentation-and-further-details)
- [How to set Seth logging level](#how-to-set-seth-logging-level)
- [Locally](#locally)
- [Remote Runner](#remote-runner)
- [How to set Seth Network Configuration](#how-to-set-seth-network-configuration)
- [Overview of Configuration Usage](#overview-of-configuration-usage)
- [Seth-Specific Network Configuration](#seth-specific-network-configuration)
- [Steps for adding a new network](#steps-for-adding-a-new-network)
- [Network is already defined in known\_networks.go](#network-is-already-defined-in-known_networksgo)
- [It's a new network](#its-a-new-network)
- [Things to remember:](#things-to-remember)
- [How to use Seth CLI](#how-to-use-seth-cli)
- [How to get Fallback (Hardcoded) Values](#how-to-get-fallback-hardcoded-values)
- [Steps to Use Seth CLI for Fallback Values](#steps-to-use-seth-cli-for-fallback-values)
- [Ephemeral and Static Keys explained](#ephemeral-and-static-keys-explained)
- [Understanding the Keys](#understanding-the-keys)
- [How to Set Ephemeral Keys in the TOML](#how-to-set-ephemeral-keys-in-the-toml)
- [How to Set Static Keys in the TOML](#how-to-set-static-keys-in-the-toml)
- [As a List of Wallet Keys in Your Network Configuration](#as-a-list-of-wallet-keys-in-your-network-configuration)
- [As Base64-Encoded Keyfile Stored as GHA Secret](#as-base64-encoded-keyfile-stored-as-gha-secret)
- [Setting Up Your Pipeline](#setting-up-your-pipeline)
- [How to Split Funds Between Static Keys](#how-to-split-funds-between-static-keys)
- [How to Return Funds From Static Keys to the Root Key](#how-to-return-funds-from-static-keys-to-the-root-key)
- [How to Rebalance or Top Up Static Keys](#how-to-rebalance-or-top-up-static-keys)
- [Rebalancing Static Keys](#rebalancing-static-keys)
- [Topping Up Static Keys](#topping-up-static-keys)
- [How to Deal with "TX Fee Exceeds the Configured Cap" Error](#how-to-deal-with-tx-fee-exceeds-the-configured-cap-error)
- [How to use Seth's synchronous API](#how-to-use-seths-synchronous-api)
- [How to read Event Data from transactions](#how-to-read-event-data-from-transactions)
- [How to deal with Failed Transactions](#how-to-deal-with-failed-transactions)
- [How Automated Gas Estimation works](#how-automated-gas-estimation-works)
- [Legacy Transactions](#legacy-transactions)
- [EIP-1559 Transactions](#eip-1559-transactions)
- [Adjustment factor](#adjustment-factor)
- [Buffer percents](#buffer-percents)
- [How to tweak Automated Gas Estimation](#how-to-tweak-automated-gas-estimation)
- [How to debug with 'execution reverted' error](#how-to-debug-with-execution-reverted-error)
- [How to split non-native tokens between keys](#how-to-split-non-native-tokens-between-keys)

## Introduction

Expand Down Expand Up @@ -354,7 +360,7 @@ If you suspect your tests might run into failed transactions in hard to reproduc
Example of loading contract using `ContractLoader`:
```go
func LoadOffchainAggregator(client *seth.Client, contractAddress common.Address) (offchainaggregator.OffchainAggregator, error) {
// intialize contract loader with the generic type of the Geth contract wrapper
// initialize contract loader with the generic type of the Geth contract wrapper
loader := seth.NewContractLoader[offchainaggregator.OffchainAggregator](client)
// call load function with contract name, address, ABI getter function and Geth wrapper constructor function
ocr, err := loader.LoadContract("OffChainAggregator", contractAddress, offchainaggregator.OffchainAggregatorMetaData.GetAbi, offchainaggregator.NewOffchainAggregator)
Expand Down
14 changes: 0 additions & 14 deletions integration-tests/actions/automationv2/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
ocr2keepers20config "github.com/smartcontractkit/chainlink-automation/pkg/v2/config"
ocr2keepers30config "github.com/smartcontractkit/chainlink-automation/pkg/v3/config"
ctf_concurrency "github.com/smartcontractkit/chainlink-testing-framework/lib/concurrency"
ctftestenv "github.com/smartcontractkit/chainlink-testing-framework/lib/docker/test_env"
"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
"github.com/smartcontractkit/chainlink-testing-framework/seth"
"github.com/smartcontractkit/chainlink/deployment/environment/nodeclient"
Expand Down Expand Up @@ -866,19 +865,6 @@ func (a *AutomationTest) AddJobsAndSetConfig(t *testing.T) {
l.Info().Str("Registry Address", a.Registry.Address()).Msg("Successfully setConfig on registry")
}

func (a *AutomationTest) SetupMercuryMock(t *testing.T, imposters []ctftestenv.KillgraveImposter) {
if a.IsOnk8s {
t.Error("mercury mock is not supported on k8s")
}
if a.DockerEnv == nil {
t.Error("docker env is not set")
}
err := a.DockerEnv.MockAdapter.AddImposter(imposters)
if err != nil {
require.NoError(t, err, "Error adding mock imposter")
}
}

func (a *AutomationTest) SetupAutomationDeployment(t *testing.T) {
a.setupDeployment(t, true)
}
Expand Down
25 changes: 16 additions & 9 deletions integration-tests/actions/ocr2_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"fmt"
"net/http"
"path/filepath"
"strings"
"time"

Expand All @@ -20,6 +21,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/codec"
"github.com/smartcontractkit/chainlink-testing-framework/lib/docker/test_env"
"github.com/smartcontractkit/chainlink-testing-framework/parrot"

"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
Expand All @@ -35,9 +37,8 @@ func CreateOCRv2JobsLocal(
ocrInstances []contracts.OffchainAggregatorV2,
bootstrapNode *nodeclient.ChainlinkClient,
workerChainlinkNodes []*nodeclient.ChainlinkClient,
mockAdapter *test_env.Killgrave,
mockAdapterPath string, // Path on the mock server for the Chainlink nodes to query
mockAdapterValue int, // Value to get from the mock server when querying the path
mockAdapter *test_env.Parrot,
valueRoute *parrot.Route,
chainId uint64, // EVM chain ID
forwardingAllowed bool,
enableChainReaderAndCodec bool,
Expand All @@ -49,12 +50,18 @@ func CreateOCRv2JobsLocal(
}
p2pV2Bootstrapper := fmt.Sprintf("%s@%s:%d", bootstrapP2PIds.Data[0].Attributes.PeerID, bootstrapNode.InternalIP(), 6690)
// Set the value for the jobs to report on
err = mockAdapter.SetAdapterBasedIntValuePath(mockAdapterPath, []string{http.MethodGet, http.MethodPost}, mockAdapterValue)
err = mockAdapter.SetAdapterRoute(valueRoute)
if err != nil {
return err
}
// Set the juelsPerFeeCoinSource config value
err = mockAdapter.SetAdapterBasedIntValuePath(fmt.Sprintf("%s/juelsPerFeeCoinSource", mockAdapterPath), []string{http.MethodGet, http.MethodPost}, mockAdapterValue)
juelsRoute := &parrot.Route{
Method: parrot.MethodAny,
Path: filepath.Join(valueRoute.Path, "juelsPerFeeCoinSource"),
ResponseBody: valueRoute.ResponseBody,
ResponseStatusCode: http.StatusOK,
}
err = mockAdapter.SetAdapterRoute(juelsRoute)
if err != nil {
return err
}
Expand All @@ -69,7 +76,7 @@ func CreateOCRv2JobsLocal(
RelayConfig: map[string]interface{}{
"chainID": chainId,
},
MonitoringEndpoint: null.StringFrom(fmt.Sprintf("%s/%s", mockAdapter.InternalEndpoint, mockAdapterPath)),
MonitoringEndpoint: null.StringFrom(fmt.Sprintf("%s/%s", mockAdapter.InternalEndpoint, valueRoute.Path)),
ContractConfigTrackerPollInterval: *models.NewInterval(15 * time.Second),
},
}
Expand All @@ -90,12 +97,12 @@ func CreateOCRv2JobsLocal(
nodeOCRKeyId := nodeOCRKeys.Data[0].ID

bta := &nodeclient.BridgeTypeAttributes{
Name: fmt.Sprintf("%s-%s", mockAdapterPath, uuid.NewString()),
URL: fmt.Sprintf("%s/%s", mockAdapter.InternalEndpoint, mockAdapterPath),
Name: fmt.Sprintf("%s-%s", valueRoute.Path, uuid.NewString()),
URL: fmt.Sprintf("%s/%s", mockAdapter.InternalEndpoint, valueRoute.Path),
}
juelsBridge := &nodeclient.BridgeTypeAttributes{
Name: fmt.Sprintf("juels-%s", uuid.NewString()),
URL: fmt.Sprintf("%s/%s/juelsPerFeeCoinSource", mockAdapter.InternalEndpoint, mockAdapterPath),
URL: fmt.Sprintf("%s/%s/juelsPerFeeCoinSource", mockAdapter.InternalEndpoint, valueRoute.Path),
}
err = chainlinkNode.MustCreateBridge(bta)
if err != nil {
Expand Down
20 changes: 14 additions & 6 deletions integration-tests/actions/ocr_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"golang.org/x/sync/errgroup"

"github.com/smartcontractkit/chainlink-testing-framework/lib/docker/test_env"
"github.com/smartcontractkit/chainlink-testing-framework/parrot"

"github.com/smartcontractkit/chainlink/deployment/environment/nodeclient"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
Expand Down Expand Up @@ -38,7 +39,7 @@
bootstrapNode *nodeclient.ChainlinkClient,
workerNodes []*nodeclient.ChainlinkClient,
mockValue int,
mockAdapter *test_env.Killgrave,
mockAdapter *test_env.Parrot,
evmChainID *big.Int,
) error {
for _, ocrInstance := range ocrInstances {
Expand Down Expand Up @@ -111,29 +112,36 @@
return nil
}

// SetAdapterResponseLocal sets the response of the mock adapter for a given OCR instance and Chainlink node
func SetAdapterResponseLocal(
response int,
ocrInstance contracts.OffchainAggregator,
chainlinkNode *nodeclient.ChainlinkClient,
mockAdapter *test_env.Killgrave,
mockAdapter *test_env.Parrot,
) error {
nodeContractPairID, err := BuildNodeContractPairID(chainlinkNode, ocrInstance)
if err != nil {
return err
}
path := fmt.Sprintf("/%s", nodeContractPairID)
err = mockAdapter.SetAdapterBasedIntValuePath(path, []string{http.MethodGet, http.MethodPost}, response)
route := &parrot.Route{
Method: parrot.MethodAny,
Path: fmt.Sprintf("/%s", nodeContractPairID),

Check failure on line 128 in integration-tests/actions/ocr_helpers_local.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (integration-tests)

fmt.Sprintf can be replaced with string concatenation (perfsprint)
ResponseBody: response,
ResponseStatusCode: http.StatusOK,
}
err = mockAdapter.SetAdapterRoute(route)
if err != nil {
return fmt.Errorf("setting mock adapter value path failed: %w", err)
}
return nil
}

// SetAllAdapterResponsesToTheSameValueLocal sets the response of the mock adapter for all OCR instances and Chainlink nodes to the same value
func SetAllAdapterResponsesToTheSameValueLocal(
response int,
ocrInstances []contracts.OffchainAggregator,
chainlinkNodes []*nodeclient.ChainlinkClient,
mockAdapter *test_env.Killgrave,
mockAdapter *test_env.Parrot,
) error {
eg := &errgroup.Group{}
for _, o := range ocrInstances {
Expand All @@ -153,7 +161,7 @@
bootstrapNode *nodeclient.ChainlinkClient,
workerNodes []*nodeclient.ChainlinkClient,
mockValue int,
mockAdapter *test_env.Killgrave,
mockAdapter *test_env.Parrot,
evmChainID string,
) error {
for _, ocrInstance := range ocrInstances {
Expand Down
Loading
Loading