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

cleanup: remove db config #709

Merged
merged 17 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
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
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
Loading