Skip to content

Commit

Permalink
cleanup: remove db config (#709)
Browse files Browse the repository at this point in the history
* remove db config

* gomodtidy

* prevent overflow on MaxRetries

* move config.go -> config/toml.go

* bump + fix e2e tests

* use multierr.append for proper delineation

* bump core commit

* SolanaNodes -> Nodes

* use errors.Join

* pin core integration tests

* flatten validation errors

* nobuild optimization for running gauntlet within e2e tests

* parallelize e2e tests

* reduce round count

* add ticket to revisit errors.Join issue
  • Loading branch information
aalu1418 authored May 23, 2024
1 parent 822b5f3 commit 45db170
Show file tree
Hide file tree
Showing 20 changed files with 162 additions and 346 deletions.
1 change: 1 addition & 0 deletions gauntlet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"bin": "packages/gauntlet-solana-contracts/dist/cli.js",
"scripts": {
"gauntlet": "yarn build && node ./packages/gauntlet-solana-contracts/dist/cli.js",
"gauntlet-nobuild": "node ./packages/gauntlet-solana-contracts/dist/cli.js",
"gauntlet-serum-multisig": "yarn build && node ./packages/gauntlet-serum-multisig/dist/index.js",
"lint": "tsc -b ./tsconfig.json",
"eslint": "eslint -f json -o eslint-report.json ./packages || true",
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ require (
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/sync v0.6.0
golang.org/x/text v0.14.0
gopkg.in/guregu/null.v4 v4.0.0
)

require (
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/guregu/null.v4 v4.0.0 h1:1Wm3S1WEA2I26Kq+6vcW+w0gcDo44YKYD7YIEJNHDjg=
gopkg.in/guregu/null.v4 v4.0.0/go.mod h1:YoQhUrADuG3i9WqesrCmpNRwm1ypAgSHYqoOcTu/JrI=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/testenv"
"github.com/smartcontractkit/chainlink-solana/integration-tests/solclient"
tc "github.com/smartcontractkit/chainlink-solana/integration-tests/testconfig"
cl_solana "github.com/smartcontractkit/chainlink-solana/pkg/solana"
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
)

Expand Down Expand Up @@ -485,7 +484,7 @@ func BuildNodeContractPairID(node *client.ChainlinkClient, ocr2Addr string) (str
}

func (c *Common) DefaultNodeConfig() *cl.Config {
solConfig := cl_solana.TOMLConfig{
solConfig := solcfg.TOMLConfig{
Enabled: ptr.Ptr(true),
ChainID: ptr.Ptr(c.ChainDetails.ChainID),
Nodes: []*solcfg.Node{
Expand All @@ -496,7 +495,7 @@ func (c *Common) DefaultNodeConfig() *cl.Config {
},
}
baseConfig := node.NewBaseConfig()
baseConfig.Solana = cl_solana.TOMLConfigs{
baseConfig.Solana = solcfg.TOMLConfigs{
&solConfig,
}
baseConfig.OCR2.Enabled = ptr.Ptr(true)
Expand Down
59 changes: 36 additions & 23 deletions integration-tests/gauntlet/gauntlet_solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ type Transmission struct {
// NewSolanaGauntlet Creates a default gauntlet config
func NewSolanaGauntlet(workingDir string) (*SolanaGauntlet, error) {
g, err := gauntlet.NewGauntlet()
g.SetWorkingDir(workingDir)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -117,16 +116,35 @@ func (sg *SolanaGauntlet) SetupNetwork(args map[string]string) error {

func (sg *SolanaGauntlet) InstallDependencies() error {
sg.G.Command = "yarn"
_, err := sg.G.ExecCommand([]string{"install"}, *sg.options)
_, err := sg.G.ExecCommand([]string{"--cwd", sg.Dir, "install"}, *sg.options)
if err != nil {
return err
}
sg.G.Command = "gauntlet"
_, err = sg.G.ExecCommand([]string{"--cwd", sg.Dir, "build"}, *sg.options) // initial build
if err != nil {
return err
}
sg.G.Command = "gauntlet-nobuild" // optimization to not rebuild packages each time
return nil
}

// exect is a custom wrapper to use custom set gauntlet command + error wrapping
func (sg *SolanaGauntlet) exec(args []string, options gauntlet.ExecCommandOptions) (string, error) {
updatedArgs := []string{"--cwd", sg.Dir, sg.G.Command, args[0], sg.G.Flag("network", sg.G.Network)}
if len(args) > 1 {
updatedArgs = append(updatedArgs, args[1:]...)
}

out, err := sg.G.ExecCommand(updatedArgs, options)
// wrapping output into err if err present
if err != nil {
err = fmt.Errorf("%w\ngauntlet command: %s\nstdout: %s", err, updatedArgs, out)
}
return out, err
}

func (sg *SolanaGauntlet) InitializeAccessController() (string, error) {
_, err := sg.G.ExecCommand([]string{"access_controller:initialize"}, *sg.options)
_, err := sg.exec([]string{"access_controller:initialize"}, *sg.options)
if err != nil {
return "", err
}
Expand All @@ -138,7 +156,7 @@ func (sg *SolanaGauntlet) InitializeAccessController() (string, error) {
}

func (sg *SolanaGauntlet) DeployLinkToken() error {
_, err := sg.G.ExecCommand([]string{"token:deploy"}, *sg.options)
_, err := sg.exec([]string{"token:deploy"}, *sg.options)
if err != nil {
return err
}
Expand All @@ -153,7 +171,7 @@ func (sg *SolanaGauntlet) DeployLinkToken() error {
}

func (sg *SolanaGauntlet) InitializeStore(billingController string) (string, error) {
_, err := sg.G.ExecCommand([]string{"store:initialize", fmt.Sprintf("--accessController=%s", billingController)}, *sg.options)
_, err := sg.exec([]string{"store:initialize", fmt.Sprintf("--accessController=%s", billingController)}, *sg.options)
if err != nil {
return "", err
}
Expand All @@ -169,7 +187,7 @@ func (sg *SolanaGauntlet) StoreCreateFeed(length int, feedConfig *ocr2_config.St
if err != nil {
return "", err
}
_, err = sg.G.ExecCommand([]string{"store:create_feed", fmt.Sprintf("--length=%d", length), fmt.Sprintf("--input=%v", string(config))}, *sg.options)
_, err = sg.exec([]string{"store:create_feed", fmt.Sprintf("--length=%d", length), fmt.Sprintf("--input=%v", string(config))}, *sg.options)
if err != nil {
return "", err
}
Expand All @@ -182,7 +200,7 @@ func (sg *SolanaGauntlet) StoreCreateFeed(length int, feedConfig *ocr2_config.St
}

func (sg *SolanaGauntlet) StoreSetValidatorConfig(feedAddress string, threshold int) (string, error) {
_, err := sg.G.ExecCommand([]string{"store:set_validator_config", fmt.Sprintf("--feed=%s", feedAddress), fmt.Sprintf("--threshold=%d", threshold)}, *sg.options)
_, err := sg.exec([]string{"store:set_validator_config", fmt.Sprintf("--feed=%s", feedAddress), fmt.Sprintf("--threshold=%d", threshold)}, *sg.options)
if err != nil {
return "", err
}
Expand All @@ -198,7 +216,7 @@ func (sg *SolanaGauntlet) InitializeOCR2(requesterAccessController string, billi
if err != nil {
return "", err
}
_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:initialize",
fmt.Sprintf("--requesterAccessController=%s", requesterAccessController),
fmt.Sprintf("--billingAccessController=%s", billingAccessController),
Expand All @@ -219,7 +237,7 @@ func (sg *SolanaGauntlet) StoreSetWriter(storeConfig *ocr2_config.StoreWriterCon
if err != nil {
return "", err
}
_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"store:set_writer",
fmt.Sprintf("--input=%v", string(config)),
ocrAddress,
Expand All @@ -243,7 +261,7 @@ func (sg *SolanaGauntlet) OCR2SetBilling(ocr2BillingConfig *ocr2_config.OCR2Bill
if err != nil {
return "", err
}
_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:set_billing",
fmt.Sprintf("--input=%v", string(config)),
ocrAddress,
Expand All @@ -263,7 +281,7 @@ func (sg *SolanaGauntlet) OCR2SetBilling(ocr2BillingConfig *ocr2_config.OCR2Bill
}

func (sg *SolanaGauntlet) OCR2CreateProposal(version int) (string, error) {
_, err := sg.G.ExecCommand([]string{
_, err := sg.exec([]string{
"ocr2:create_proposal",
fmt.Sprintf("--version=%d", version),
},
Expand All @@ -286,7 +304,7 @@ func (sg *SolanaGauntlet) ProposeOnChainConfig(proposalID string, onChainConfig
if err != nil {
return "", err
}
_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:propose_config",
fmt.Sprintf("--proposalId=%s", proposalID),
fmt.Sprintf("--input=%v", string(config)),
Expand All @@ -312,7 +330,7 @@ func (sg *SolanaGauntlet) ProposeOffChainConfig(proposalID string, offChainConfi
return "", err
}

_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:propose_offchain_config",
fmt.Sprintf("--proposalId=%s", proposalID),
fmt.Sprintf("--input=%v", string(config)),
Expand All @@ -338,7 +356,7 @@ func (sg *SolanaGauntlet) ProposePayees(proposalID string, payeesConfig ocr2_con
return "", err
}

_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:propose_payees",
fmt.Sprintf("--proposalId=%s", proposalID),
fmt.Sprintf("--input=%v", string(config)),
Expand All @@ -359,7 +377,7 @@ func (sg *SolanaGauntlet) ProposePayees(proposalID string, payeesConfig ocr2_con
}

func (sg *SolanaGauntlet) FinalizeProposal(proposalID string) (string, error) {
_, err := sg.G.ExecCommand([]string{
_, err := sg.exec([]string{
"ocr2:finalize_proposal",
fmt.Sprintf("--proposalId=%s", proposalID),
},
Expand All @@ -383,7 +401,7 @@ func (sg *SolanaGauntlet) AcceptProposal(proposalID string, secret string, propo
return "", err
}

_, err = sg.G.ExecCommand([]string{
_, err = sg.exec([]string{
"ocr2:accept_proposal",
fmt.Sprintf("--proposalId=%s", proposalID),
fmt.Sprintf("--secret=%s", secret),
Expand All @@ -406,7 +424,7 @@ func (sg *SolanaGauntlet) AcceptProposal(proposalID string, secret string, propo

// FetchTransmissions returns the last 10 transmissions
func (sg *SolanaGauntlet) FetchTransmissions(ocrState string) ([]Transmission, error) {
_, err := sg.G.ExecCommand([]string{
_, err := sg.exec([]string{
"ocr2:inspect:responses",
ocrState,
},
Expand All @@ -426,11 +444,6 @@ func (sg *SolanaGauntlet) FetchTransmissions(ocrState string) ([]Transmission, e

func (sg *SolanaGauntlet) DeployOCR2() (string, error) {
var err error
err = sg.InstallDependencies()
if err != nil {
return "", err
}

sg.AccessControllerAddress, err = sg.InitializeAccessController()
if err != nil {
return "", err
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ require (
github.com/lib/pq v1.10.9
github.com/pelletier/go-toml/v2 v2.1.1
github.com/rs/zerolog v1.30.0
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240510181707-46b1311a5a83
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240517134904-f4446b816a28
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240521200803-6c605f618787
github.com/smartcontractkit/chainlink-testing-framework v1.28.15
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240515225456-aeb9f4d50d65
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240515225456-aeb9f4d50d65
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240521201249-c00f33248fe4
github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c
github.com/smartcontractkit/seth v1.0.9
github.com/stretchr/testify v1.9.0
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1406,8 +1406,8 @@ 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.20240516150131-e1be553a9d10 h1:IwJKWZHPBJbbh4oI3BGX8VNT3c/ChNiPZ/XI4iq6c0E=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10/go.mod h1:sj0pjL+METqeYL9ibp0T8SXquymlaQsofa6bdfLgXX8=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240517134904-f4446b816a28 h1:Pr8/CdiTNnzRwpYc2z7NpHYbw3Dpl1eqiqt9/J/Bcqc=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240517134904-f4446b816a28/go.mod h1:s+68EchlrXqHKRW3JJgZLEARvzMSKRI5+cE5Zx7pVJA=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240508101745-af1ed7bc8a69 h1:Sec/GpBpUVaTEax1kSHlTvkzF/+d3w5roAQXaj5+SLA=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240508101745-af1ed7bc8a69/go.mod h1:ZQKf+0OLzCLYIisH/OdOIQuFRI6bDuw+jPBTATyHfFM=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 h1:xFSv8561jsLtF6gYZr/zW2z5qUUAkcFkApin2mnbYTo=
Expand All @@ -1424,8 +1424,8 @@ github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772 h1:
github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240515225456-aeb9f4d50d65 h1:8AoBDPHOLgZA1JodqysYK/JxcVbjwNhyGfmwzQuep4s=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240515225456-aeb9f4d50d65/go.mod h1:DOeyxJuvSV8No26UHAtmvZTycuGe0S4w/XMMj1EGMV8=
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240515225456-aeb9f4d50d65 h1:ba2ZooA598i9P2qakTggT81f5TIFI9efPVsGy7MjY9Y=
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240515225456-aeb9f4d50d65/go.mod h1:ICLCfUotU6Zk+S2kry3XE6i3lyhk30sr2rz89Y5QkGI=
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240521201249-c00f33248fe4 h1:KrQxqehwHCpbJJtltv2iWlVR+cxNzEoBN8EFtbwWtPg=
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240521201249-c00f33248fe4/go.mod h1:10XUZ0WuFDdW+RYD0PdTpHlnaxkh/sqeAtjrAV6vUvQ=
github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss=
github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4=
github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU=
Expand Down
16 changes: 14 additions & 2 deletions integration-tests/smoke/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package smoke
import (
"fmt"
"maps"
"os/exec"
"testing"
"time"

Expand Down Expand Up @@ -37,7 +38,10 @@ func TestSolanaOCRV2Smoke(t *testing.T) {

test := test
t.Run(test.name, func(t *testing.T) {
state, err := common.NewOCRv2State(t, 1, "gauntlet-"+test.name, &config)
t.Parallel()

name := "gauntlet-" + test.name
state, err := common.NewOCRv2State(t, 1, name, &config)
require.NoError(t, err, "Could not setup the ocrv2 state")
if len(test.env) > 0 {
state.Common.TestEnvDetails.NodeOpts = append(state.Common.TestEnvDetails.NodeOpts, func(n *test_env.ClNode) {
Expand All @@ -50,7 +54,13 @@ func TestSolanaOCRV2Smoke(t *testing.T) {

state.DeployCluster(utils.ContractsDir)

sg, err := gauntlet.NewSolanaGauntlet(fmt.Sprintf("%s/gauntlet", utils.ProjectRoot))
// copy gauntlet folder to run in parallel (gauntlet generates an output file that is read by the e2e tests - causes conflict if shared)
gauntletCopyPath := utils.ProjectRoot + "/" + name
if out, cpErr := exec.Command("cp", "-r", utils.ProjectRoot+"/gauntlet", gauntletCopyPath).Output(); cpErr != nil { // nolint:gosec
require.NoError(t, err, "output: "+string(out))
}

sg, err := gauntlet.NewSolanaGauntlet(gauntletCopyPath)
require.NoError(t, err)
state.Gauntlet = sg

Expand All @@ -73,6 +83,8 @@ func TestSolanaOCRV2Smoke(t *testing.T) {

err = sg.SetupNetwork(gauntletConfig)
require.NoError(t, err, "Error setting gauntlet network")
err = sg.InstallDependencies()
require.NoError(t, err, "Error installing gauntlet dependencies")

if *config.Common.Network == "devnet" {
state.Common.ChainDetails.ProgramAddresses.OCR2 = *config.SolanaConfig.OCR2ProgramID
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/testconfig/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ node_count = 6
test_duration = "50m"

[OCR2.Smoke]
number_of_rounds = 5
number_of_rounds = 2

7 changes: 3 additions & 4 deletions pkg/solana/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

"github.com/smartcontractkit/chainlink-solana/pkg/solana/client"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/db"
)

var mockTransmission = []byte{
Expand Down Expand Up @@ -94,7 +93,7 @@ func testTransmissionsResponse(t *testing.T, body []byte, sub uint64) []byte {

func testSetupReader(t *testing.T, endpoint string) client.Reader {
lggr := logger.Test(t)
cfg := config.NewConfig(db.ChainCfg{}, lggr)
cfg := config.NewDefault()
client, err := client.NewClient(endpoint, cfg, 1*time.Second, lggr)
require.NoError(t, err)
return client
Expand Down Expand Up @@ -170,7 +169,7 @@ func TestCache(t *testing.T) {
lggr := logger.Test(t)
stateCache := StateCache{
StateID: solana.MustPublicKeyFromBase58("11111111111111111111111111111111"),
cfg: config.NewConfig(db.ChainCfg{}, lggr),
cfg: config.NewDefault(),
reader: testSetupReader(t, mockServer.URL),
lggr: lggr,
}
Expand All @@ -182,7 +181,7 @@ func TestCache(t *testing.T) {

transmissionsCache := TransmissionsCache{
TransmissionsID: solana.MustPublicKeyFromBase58("11111111111111111111111111111112"),
cfg: config.NewConfig(db.ChainCfg{}, lggr),
cfg: config.NewDefault(),
reader: testSetupReader(t, mockServer.URL),
lggr: lggr,
}
Expand Down
Loading

0 comments on commit 45db170

Please sign in to comment.