Skip to content

Commit

Permalink
Merge branch 'develop' into feat/block-history-est
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 authored Jun 5, 2024
2 parents 3cdce0a + eef8bfb commit 157da2b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 108 deletions.
96 changes: 0 additions & 96 deletions integration-tests/common/common.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
package common

import (
"bytes"
"encoding/hex"
"fmt"
"math/big"
"sort"
"strings"
"testing"
"time"

"github.com/gagliardetto/solana-go"
"github.com/google/uuid"
"github.com/lib/pq"
"github.com/rs/zerolog/log"
"golang.org/x/crypto/curve25519"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/libocr/offchainreporting2/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2/types"

ctfconfig "github.com/smartcontractkit/chainlink-testing-framework/config"
ctf_test_env "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/environment"
Expand All @@ -29,7 +20,6 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/sol"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"

"github.com/smartcontractkit/chainlink/v2/core/services/job"
Expand Down Expand Up @@ -109,15 +99,6 @@ type NodeKeysBundle struct {
TXKey *client.TxKey
}

// OCR2 keys are in format OCR2<key_type>_<network>_<key>
func stripKeyPrefix(key string) string {
chunks := strings.Split(key, "_")
if len(chunks) == 3 {
return chunks[2]
}
return key
}

func New(testConfig *tc.TestConfig) *Common {
var c *Common

Expand Down Expand Up @@ -196,42 +177,6 @@ func (c *Common) CreateNodeKeysBundle(nodes []*client.ChainlinkClient) ([]client
return nkb, nil
}

func createOracleIdentities(nkb []client.NodeKeysBundle) ([]confighelper.OracleIdentityExtra, error) {
oracleIdentities := make([]confighelper.OracleIdentityExtra, 0)
for _, nodeKeys := range nkb {
offChainPubKeyTemp, err := hex.DecodeString(stripKeyPrefix(nodeKeys.OCR2Key.Data.Attributes.OffChainPublicKey))
if err != nil {
return nil, err
}
onChainPubKey, err := hex.DecodeString(stripKeyPrefix(nodeKeys.OCR2Key.Data.Attributes.OnChainPublicKey))
if err != nil {
return nil, err
}
cfgPubKeyTemp, err := hex.DecodeString(stripKeyPrefix(nodeKeys.OCR2Key.Data.Attributes.ConfigPublicKey))
if err != nil {
return nil, err
}
cfgPubKeyBytes := [curve25519.PointSize]byte{}
copy(cfgPubKeyBytes[:], cfgPubKeyTemp)
offChainPubKey := [curve25519.PointSize]byte{}
copy(offChainPubKey[:], offChainPubKeyTemp)
oracleIdentities = append(oracleIdentities, confighelper.OracleIdentityExtra{
OracleIdentity: confighelper.OracleIdentity{
OffchainPublicKey: offChainPubKey,
OnchainPublicKey: onChainPubKey,
PeerID: nodeKeys.PeerID,
TransmitAccount: types.Account(nodeKeys.TXKey.Data.Attributes.PublicKey),
},
ConfigEncryptionPublicKey: cfgPubKeyBytes,
})
}
// program sorts oracles (need to pre-sort to allow correct onchainConfig generation)
sort.Slice(oracleIdentities, func(i, j int) bool {
return bytes.Compare(oracleIdentities[i].OracleIdentity.OnchainPublicKey, oracleIdentities[j].OracleIdentity.OnchainPublicKey) < 0
})
return oracleIdentities, nil
}

func FundOracles(c *solclient.Client, nkb []client.NodeKeysBundle, amount *big.Float) error {
for _, nk := range nkb {
addr := nk.TXKey.Data.Attributes.PublicKey
Expand All @@ -242,47 +187,6 @@ func FundOracles(c *solclient.Client, nkb []client.NodeKeysBundle, amount *big.F
return nil
}

// OffChainConfigParamsFromNodes creates contracts.OffChainAggregatorV2Config
func OffChainConfigParamsFromNodes(nodeCount int, nkb []client.NodeKeysBundle) (contracts.OffChainAggregatorV2Config, error) {
oi, err := createOracleIdentities(nkb)
if err != nil {
return contracts.OffChainAggregatorV2Config{}, err
}
s := make([]int, 0)
for i := 0; i < nodeCount; i++ {
s = append(s, 1)
}
faultyNodes := 0
if nodeCount > 1 {
faultyNodes = nodeCount/3 - 1
}
if faultyNodes == 0 {
faultyNodes = 1
}
log.Debug().Int("Nodes", faultyNodes).Msg("Faulty nodes")
return contracts.OffChainAggregatorV2Config{
DeltaProgress: 2 * time.Second,
DeltaResend: 5 * time.Second,
DeltaRound: 1 * time.Second,
DeltaGrace: 500 * time.Millisecond,
DeltaStage: 10 * time.Second,
RMax: 3,
S: s,
Oracles: oi,
ReportingPluginConfig: median.OffchainConfig{
AlphaReportPPB: uint64(0),
AlphaAcceptPPB: uint64(0),
}.Encode(),
MaxDurationQuery: 20 * time.Millisecond,
MaxDurationObservation: 500 * time.Millisecond,
MaxDurationReport: 500 * time.Millisecond,
MaxDurationShouldAcceptFinalizedReport: 500 * time.Millisecond,
MaxDurationShouldTransmitAcceptedReport: 500 * time.Millisecond,
F: faultyNodes,
OnchainConfig: []byte{},
}, nil
}

func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, mockURL string, isK8s bool) error {
for i, nodesInfo := range ContractsIdxMapToContractsNodeInfo {
// Bootstrap node first
Expand Down
20 changes: 10 additions & 10 deletions integration-tests/config/ocr2_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,22 @@ func (o *OCR2Config) Default() {
UserSecret: o.Secret,
ProposalID: o.ProposalID,
OffchainConfig: OffchainConfig{
DeltaProgressNanoseconds: int64(20000000000),
DeltaResendNanoseconds: int64(50000000000),
DeltaRoundNanoseconds: int64(1000000000),
DeltaGraceNanoseconds: int64(4000000000),
DeltaStageNanoseconds: int64(50000000000),
DeltaProgressNanoseconds: int64(8000000000), // 8s
DeltaResendNanoseconds: int64(5000000000), // 5s
DeltaRoundNanoseconds: int64(3000000000), // 3s
DeltaGraceNanoseconds: int64(400000000), // 400ms
DeltaStageNanoseconds: int64(10000000000), // 10s
RMax: 3,
S: s,
OffchainPublicKeys: offchainPublicKeys,
PeerIds: peerIds,
ConfigPublicKeys: configPublicKeys,
ReportingPluginConfig: o.OffChainConfig.OffchainConfig.ReportingPluginConfig,
MaxDurationQueryNanoseconds: int64(3000000000),
MaxDurationObservationNanoseconds: int64(3000000000),
MaxDurationReportNanoseconds: int64(100000000),
MaxDurationShouldAcceptFinalizedReportNanoseconds: int64(100000000),
MaxDurationShouldTransmitAcceptedReportNanoseconds: int64(100000000),
MaxDurationQueryNanoseconds: int64(0),
MaxDurationObservationNanoseconds: int64(1000000000), // 1s
MaxDurationReportNanoseconds: int64(1000000000), // 1s
MaxDurationShouldAcceptFinalizedReportNanoseconds: int64(1000000000), // 1s
MaxDurationShouldTransmitAcceptedReportNanoseconds: int64(1000000000), // 1s
},
}
o.PayeeConfig = &PayeeConfig{
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ require (
github.com/smartcontractkit/seth v1.0.11
github.com/stretchr/testify v1.9.0
github.com/testcontainers/testcontainers-go v0.28.0
golang.org/x/crypto v0.22.0
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
golang.org/x/sync v0.6.0
golang.org/x/text v0.14.0
Expand Down Expand Up @@ -434,6 +433,7 @@ require (
go.uber.org/zap v1.26.0 // indirect
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/smoke/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ func TestSolanaOCRV2Smoke(t *testing.T) {
RoundID: 0,
}
for successFullRounds < *config.OCR2.Smoke.NumberOfRounds {
time.Sleep(time.Second * 6)
require.Less(t, stuck, 10, fmt.Sprintf("%s: Rounds have been stuck for more than 10 iterations", name))

log.Info().Str("Transmission", sg.OcrAddress).Msg("Inspecting transmissions")
transmissions, err := sg.FetchTransmissions(sg.OcrAddress)
require.NoError(t, err)
Expand All @@ -151,7 +153,6 @@ func TestSolanaOCRV2Smoke(t *testing.T) {
require.Less(t, prevRound.RoundID, currentRound.RoundID, fmt.Sprintf("Expected round %d to be less than %d", prevRound.RoundID, currentRound.RoundID))
prevRound = currentRound
successFullRounds++
time.Sleep(time.Second * 6)
stuck = 0
}
})
Expand Down

0 comments on commit 157da2b

Please sign in to comment.