Skip to content

Commit

Permalink
Fixes VRF failures for v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kalverra authored Nov 9, 2021
1 parent 072cfa0 commit ab5bd6d
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 35 deletions.
82 changes: 76 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ jobs:
if: steps.cache-packages.outputs.cache-hit != 'true'
run: go mod download
- name: Install Ginkgo CLI
run: go install github.com/onsi/ginkgo/ginkgo
run: |
go get github.com/onsi/ginkgo/ginkgo@v1.16.5
go install github.com/onsi/ginkgo/ginkgo
- name: Run Tests
run: |
export PATH=$PATH:$(go env GOPATH)/bin
Expand All @@ -68,6 +70,7 @@ jobs:
uses: mikepenz/action-junit-report@v2
if: always()
with:
name: Unit Test Report
report_paths: '**/logs/tests-*.xml'
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Artifacts
Expand Down Expand Up @@ -116,15 +119,18 @@ jobs:
if: steps.cache-packages.outputs.cache-hit != 'true'
run: go mod download
- name: Install Ginkgo CLI
run: go install github.com/onsi/ginkgo/ginkgo
run: |
go get github.com/onsi/ginkgo/ginkgo@v1.16.5
go install github.com/onsi/ginkgo/ginkgo
- name: Run Tests
run: |
export PATH=$PATH:$(go env GOPATH)/bin
make test_smoke args="--nodes=15"
make test_smoke args="-nodes=15"
- name: Publish Test Results
uses: mikepenz/action-junit-report@v2
if: always()
with:
name: Smoke Test Report
report_paths: '**/logs/tests-*.xml'
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Artifacts
Expand Down Expand Up @@ -176,20 +182,84 @@ jobs:
if: steps.cache-packages.outputs.cache-hit != 'true'
run: go mod download
- name: Install Ginkgo CLI
run: go install github.com/onsi/ginkgo/ginkgo
run: |
go get github.com/onsi/ginkgo/ginkgo@v1.16.5
go install github.com/onsi/ginkgo/ginkgo
- name: Run Tests
run: |
export PATH=$PATH:$(go env GOPATH)/bin
make test_performance args="--nodes=15"
make test_performance args="-nodes=15"
- name: Publish Test Results
uses: mikepenz/action-junit-report@v2
if: always()
with:
name: Performance Test Report
report_paths: '**/logs/tests-*.xml'
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Artifacts
if: failure()
uses: actions/upload-artifact@v1
with:
name: test-logs
path: ./logs
path: ./logs

# Chaos tests not stable enough for CI yet
# chaos:
# # Only run performance tests on significant PRs / merges to main
# if: startsWith(github.ref, 'v') || contains(github.ref, 'main') || contains(github.ref, 'develop')
# needs: unit
# runs-on: ubuntu-latest
# env:
# CGO_ENABLED: 1
# NETWORK: ethereum_geth_performance
# steps:
# - name: Checkout the repo
# uses: actions/checkout@v2
# - name: Setup Go
# uses: actions/setup-go@v1
# with:
# go-version: 1.17
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ secrets.AWS_REGION }}
# role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
# role-duration-seconds: 3600
# - name: Set Kubernetes Context
# uses: azure/k8s-set-context@v1
# with:
# method: kubeconfig
# kubeconfig: ${{ secrets.KUBECONFIG }}
# - name: Cache Vendor Packages
# uses: actions/cache@v2
# id: cache-packages
# with:
# path: |
# ~/.cache/go-build
# ~/go/pkg/mod
# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
# restore-keys: |
# ${{ runner.os }}-go-
# - name: Download Go Vendor Packages
# if: steps.cache-packages.outputs.cache-hit != 'true'
# run: go mod download
# - name: Install Ginkgo CLI
# run: go install github.com/onsi/ginkgo/ginkgo
# - name: Run Tests
# run: |
# export PATH=$PATH:$(go env GOPATH)/bin
# make test_chaos args="-nodes=15"
# - name: Publish Test Results
# uses: mikepenz/action-junit-report@v2
# if: always()
# with:
# report_paths: '**/logs/tests-*.xml'
# github_token: ${{ secrets.GITHUB_TOKEN }}
# - name: Publish Artifacts
# if: failure()
# uses: actions/upload-artifact@v1
# with:
# name: test-logs
# path: ./logs
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ go_mod:
install: go_mod golangci

test_smoke:
ginkgo -r -p -keepGoing --trace --randomizeAllSpecs --randomizeSuites --progress -skipPackage=./suite/performance,./suite/chaos ./suite/... $(args)
ginkgo -r -keepGoing --trace --randomizeAllSpecs --randomizeSuites --progress $(args) ./suite/smoke

test_performance:
ginkgo -r -p -keepGoing --trace --randomizeAllSpecs --randomizeSuites --progress ./suite/performance ./suite/chaos $(args)
ginkgo -r -keepGoing --trace --randomizeAllSpecs --randomizeSuites --progress $(args) ./suite/performance

test_chaos:
ginkgo -r -keepGoing --trace --randomizeAllSpecs --randomizeSuites --progress $(args) ./suite/chaos
5 changes: 3 additions & 2 deletions actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ package actions
import (
"encoding/json"
"fmt"
"github.com/smartcontractkit/integrations-framework/contracts"
"math/big"
"strings"

"github.com/smartcontractkit/integrations-framework/contracts"

"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
Expand Down Expand Up @@ -80,7 +81,7 @@ func ExtractRequestIDFromJobRun(jobDecodeData client.RunsResponseData) ([]byte,

// EncodeOnChainVRFProvingKey encodes uncompressed public VRF key to on-chain representation
func EncodeOnChainVRFProvingKey(vrfKey client.VRFKey) ([2]*big.Int, error) {
uncompressed := vrfKey.Attributes.Uncompressed
uncompressed := vrfKey.Data.Attributes.Uncompressed
provingKey := [2]*big.Int{}
var set1 bool
var set2 bool
Expand Down
29 changes: 25 additions & 4 deletions client/chainlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ type Chainlink interface {
DeleteP2PKey(id int) error

ReadETHKeys() (*ETHKeys, error)
ReadVRFKeys() (*VRFKeys, error)
PrimaryEthAddress() (string, error)

CreateVRFKey() (*VRFKey, error)
ReadVRFKeys() (*VRFKeys, error)

CreateEI(eia *EIAttributes) (*EIKeyCreate, error)
ReadEIs() (*EIKeys, error)
DeleteEI(name string) error
Expand Down Expand Up @@ -225,6 +227,11 @@ func (c *chainlink) ReadP2PKeys() (*P2PKeys, error) {
p2pKeys := &P2PKeys{}
log.Info().Str("Node URL", c.Config.URL).Msg("Reading P2P Keys")
_, err := c.do(http.MethodGet, "/v2/keys/p2p", nil, p2pKeys, http.StatusOK)
if len(p2pKeys.Data) == 0 {
err = fmt.Errorf("Found no P2P Keys on the chainlink node. Node URL: %s", c.Config.URL)
log.Err(err).Msg("Error getting P2P keys")
return nil, err
}
for index := range p2pKeys.Data {
p2pKeys.Data[index].Attributes.PeerID = strings.TrimPrefix(p2pKeys.Data[index].Attributes.PeerID, "p2p_")
}
Expand All @@ -243,15 +250,29 @@ func (c *chainlink) ReadETHKeys() (*ETHKeys, error) {
ethKeys := &ETHKeys{}
log.Info().Str("Node URL", c.Config.URL).Msg("Reading ETH Keys")
_, err := c.do(http.MethodGet, "/v2/keys/eth", nil, ethKeys, http.StatusOK)
if len(ethKeys.Data) == 0 {
log.Warn().Str("Node URL", c.Config.URL).Msg("Found no ETH Keys on the node")
}
return ethKeys, err
}

// ReadVRFKeys reads all VRF keys from the Chainlink node
func (c *chainlink) ReadVRFKeys() (*VRFKeys, error) {
ethKeys := &VRFKeys{}
vrfKeys := &VRFKeys{}
log.Info().Str("Node URL", c.Config.URL).Msg("Reading VRF Keys")
_, err := c.do(http.MethodGet, "/v2/keys/vrf", nil, ethKeys, http.StatusOK)
return ethKeys, err
_, err := c.do(http.MethodGet, "/v2/keys/vrf", nil, vrfKeys, http.StatusOK)
if len(vrfKeys.Data) == 0 {
log.Warn().Str("Node URL", c.Config.URL).Msg("Found no VRF Keys on the node")
}
return vrfKeys, err
}

// CreateVRFKey creates a VRF key on the Chainlink node
func (c *chainlink) CreateVRFKey() (*VRFKey, error) {
vrfKey := &VRFKey{}
log.Info().Str("Node URL", c.Config.URL).Msg("Creating VRF Key")
_, err := c.do(http.MethodPost, "/v2/keys/vrf", nil, vrfKey, http.StatusOK)
return vrfKey, err
}

// PrimaryEthAddress returns the primary ETH address for the chainlink node
Expand Down
9 changes: 7 additions & 2 deletions client/chainlink_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,18 @@ type VRFKeyAttributes struct {
DeletedAt interface{} `json:"deletedAt"`
}

// VRFKey is the model that represents the created VRF key when read
type VRFKey struct {
// VRFKeyData is the model that represents the created VRF key's data when read
type VRFKeyData struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes VRFKeyAttributes `json:"attributes"`
}

// VRFKey is the model that represents the created VRF key when read
type VRFKey struct {
Data VRFKeyData `json:"data"`
}

// VRFKeys is the model that represents the created VRF keys when read
type VRFKeys struct {
Data []VRFKey `json:"data"`
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ require (
)

require (
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/spf13/cobra v1.2.1 // indirect
golang.org/x/tools v0.1.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
Expand Down Expand Up @@ -2458,7 +2457,6 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.7 h1:6j8CgantCy3yc8JGBqkDLMKWqZ0RDU2g1HVgacojGWQ=
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
7 changes: 4 additions & 3 deletions suite/performance/vrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package performance

import (
"context"
"math/big"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/onsi/ginkgo"
"github.com/rs/zerolog/log"
Expand All @@ -11,8 +14,6 @@ import (
"github.com/smartcontractkit/integrations-framework/contracts"
"github.com/smartcontractkit/integrations-framework/environment"
"golang.org/x/sync/errgroup"
"math/big"
"time"
)

// VRFProvingData proving key and job ID pair
Expand Down Expand Up @@ -280,7 +281,7 @@ func (f *VRFTest) createChainlinkJobs() error {
if err != nil {
return err
}
pubKeyCompressed := nodeKeys.Data[0].ID
pubKeyCompressed := nodeKeys.Data[0].Data.ID
jobUUID := uuid.NewV4()
os := &client.VRFTxPipelineSpec{
Address: p.coordinator.Address(),
Expand Down
5 changes: 3 additions & 2 deletions suite/smoke/contracts_flux_validate_flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package smoke
import (
"context"
"fmt"
"github.com/smartcontractkit/integrations-framework/hooks"
"github.com/smartcontractkit/integrations-framework/utils"
"math/big"
"strings"
"time"

"github.com/smartcontractkit/integrations-framework/hooks"
"github.com/smartcontractkit/integrations-framework/utils"

"github.com/rs/zerolog/log"

"github.com/ethereum/go-ethereum/common"
Expand Down
14 changes: 9 additions & 5 deletions suite/smoke/contracts_ocr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,26 @@ import (
)

var _ = Describe("OCR Feed @ocr", func() {
var i *actions.OCRSetupInputs

DescribeTable("Deploys and watches an OCR feed @ocr", func(
envInit environment.K8sEnvSpecInit,
) {
i := &actions.OCRSetupInputs{}
i = &actions.OCRSetupInputs{}
By("Deploying environment", actions.DeployOCRForEnv(i, envInit))
By("Funding nodes", actions.FundNodes(i))
By("Deploying OCR contracts", actions.DeployOCRContracts(i, 1))
By("Creating OCR jobs", actions.CreateOCRJobs(i))
By("Checking OCR rounds", actions.CheckRound(i))
By("Printing gas stats", func() {
i.SuiteSetup.DefaultNetwork().Client.GasStats().PrintStats()
})
By("Tearing down the environment", i.SuiteSetup.TearDown())
},
Entry("all the same version", environment.NewChainlinkCluster(6)),
Entry("different versions", environment.NewMixedVersionChainlinkCluster(6, 2)),
)

AfterEach(func() {
By("Calculating gas costs", func() {
i.NetworkInfo.Client.GasStats().PrintStats()
})
By("Tearing down the environment", i.SuiteSetup.TearDown())
})
})
11 changes: 6 additions & 5 deletions suite/smoke/contracts_vrf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package smoke

import (
"context"
"math/big"

"github.com/smartcontractkit/integrations-framework/hooks"
"github.com/smartcontractkit/integrations-framework/utils"
"math/big"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -69,10 +70,10 @@ var _ = Describe("VRF suite @vrf", func() {

By("Creating jobs and registering proving keys", func() {
for _, n := range nodes {
nodeKeys, err := n.ReadVRFKeys()
nodeKey, err := n.CreateVRFKey()
Expect(err).ShouldNot(HaveOccurred())
log.Debug().Interface("Key JSON", nodeKeys).Msg("Created proving key")
pubKeyCompressed := nodeKeys.Data[0].ID
log.Debug().Interface("Key JSON", nodeKey).Msg("Created proving key")
pubKeyCompressed := nodeKey.Data.ID
jobUUID := uuid.NewV4()
os := &client.VRFTxPipelineSpec{
Address: coordinator.Address(),
Expand All @@ -91,7 +92,7 @@ var _ = Describe("VRF suite @vrf", func() {

oracleAddr, err := n.PrimaryEthAddress()
Expect(err).ShouldNot(HaveOccurred())
provingKey, err := actions.EncodeOnChainVRFProvingKey(nodeKeys.Data[0])
provingKey, err := actions.EncodeOnChainVRFProvingKey(*nodeKey)
Expect(err).ShouldNot(HaveOccurred())
err = coordinator.RegisterProvingKey(
networkInfo.Wallets.Default(),
Expand Down

0 comments on commit ab5bd6d

Please sign in to comment.