Skip to content

Commit

Permalink
Gauntlet implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
smickovskid committed Jul 10, 2023
1 parent 23201d2 commit 646bcad
Show file tree
Hide file tree
Showing 21 changed files with 954 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ tests/e2e/smoke/logs
tests/e2e/smoke/contracts-chaos-state.json
tmp-manifest-*
tests-smoke-report.xml
.env.test*
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[88,83,177,128,199,1,114,89,250,247,46,18,107,162,26,125,19,233,229,58,251,38,17,221,10,202,45,185,250,64,243,39,24,4,109,145,171,35,102,148,236,12,238,74,222,116,201,243,109,158,98,122,7,32,21,13,158,190,72,124,157,104,243,12]
[76,70,87,251,132,192,249,37,211,14,64,138,123,157,67,141,21,91,254,135,15,92,31,128,175,8,219,92,171,165,185,183,63,120,90,114,57,160,88,241,225,90,224,15,109,133,181,138,161,247,250,74,62,231,236,114,163,56,253,193,245,54,133,38]
2 changes: 1 addition & 1 deletion contracts/artifacts/localnet/access_controller-keypair.pub
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2ckhep7Mvy1dExenBqpcdevhRu7CLuuctMcx7G9mWEvo
5Gm8JySC3RzGonihF1hj1kZkjHyyW7qxJNvyzq1ieAY5
2 changes: 1 addition & 1 deletion contracts/artifacts/localnet/ocr2-keypair.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[9,218,36,113,218,176,180,196,27,75,171,187,105,81,84,58,52,79,85,169,125,13,0,102,214,246,82,252,133,222,160,252,193,218,154,28,253,34,136,185,53,68,165,141,248,188,247,143,17,100,91,130,75,49,212,131,37,18,151,175,201,153,131,185]
[147,156,90,33,172,253,32,40,142,95,165,27,216,156,10,128,72,6,229,255,104,31,98,168,73,90,39,104,165,203,211,84,132,118,199,245,159,246,74,198,107,52,202,251,246,140,133,15,19,176,2,184,11,151,23,172,232,85,166,253,164,118,91,48]
2 changes: 1 addition & 1 deletion contracts/artifacts/localnet/ocr2-keypair.pub
Original file line number Diff line number Diff line change
@@ -1 +1 @@
E3j24rx12SyVsG6quKuZPbQqZPkhAUCh8Uek4XrKYD2x
9v5sGbNhyTM23yVvczzPbk5NtCqrARQpZjuzebBur43h
2 changes: 1 addition & 1 deletion contracts/artifacts/localnet/store-keypair.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[189,212,127,119,126,129,229,12,201,157,100,223,53,182,209,144,82,137,39,42,199,212,116,181,52,188,127,6,123,161,148,74,129,253,6,129,56,138,171,117,217,146,177,54,182,120,125,247,100,54,203,214,204,177,0,83,158,177,77,195,0,245,49,223]
[30,72,16,94,28,30,190,184,210,18,22,97,115,213,52,14,152,142,137,21,86,150,183,172,161,106,37,110,215,87,49,232,139,79,75,93,190,229,125,33,186,3,117,59,155,239,31,42,172,253,255,242,81,180,243,88,210,14,164,205,236,26,23,178]
2 changes: 1 addition & 1 deletion contracts/artifacts/localnet/store-keypair.pub
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9kRNTZmoZSiTBuXC62dzK9E7gC7huYgcmRRhYv3i4osC
ANooJg7j9UxgJ2DNuLqUJs5h956qzc5LdPLFFtQdDb8M
2 changes: 1 addition & 1 deletion contracts/programs/access-controller/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::mem;

use arrayvec::arrayvec;

declare_id!("9xi644bRR8birboDGdTiwBq3C7VEeR7VuamRYYXCubUW");
declare_id!("5Gm8JySC3RzGonihF1hj1kZkjHyyW7qxJNvyzq1ieAY5");

#[constant]
pub const MAX_ADDRS: usize = 64;
Expand Down
2 changes: 1 addition & 1 deletion contracts/programs/ocr2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anchor_spl::token;
use arrayref::{array_ref, array_refs};
use state::{Billing, Proposal, ProposedOracle, STATE_VERSION};

declare_id!("cjg3oHmg9uuPsP8D6g29NWvhySJkdYdAo9D25PRbKXJ");
declare_id!("9v5sGbNhyTM23yVvczzPbk5NtCqrARQpZjuzebBur43h");

mod context;
pub mod event;
Expand Down
2 changes: 1 addition & 1 deletion contracts/programs/store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod state;
use crate::state::with_store;
pub use crate::state::{NewTransmission, Store as State, Transmission, Transmissions};

declare_id!("HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny");
declare_id!("ANooJg7j9UxgJ2DNuLqUJs5h956qzc5LdPLFFtQdDb8M");

static THRESHOLD_MULTIPLIER: u128 = 100000;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
NODE_URL=https://api.devnet.solana.com

PROGRAM_ID_OCR2=cjg3oHmg9uuPsP8D6g29NWvhySJkdYdAo9D25PRbKXJ
PROGRAM_ID_ACCESS_CONTROLLER=9xi644bRR8birboDGdTiwBq3C7VEeR7VuamRYYXCubUW
PROGRAM_ID_STORE=HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny
PROGRAM_ID_OCR2=9v5sGbNhyTM23yVvczzPbk5NtCqrARQpZjuzebBur43h
PROGRAM_ID_ACCESS_CONTROLLER=5Gm8JySC3RzGonihF1hj1kZkjHyyW7qxJNvyzq1ieAY5
PROGRAM_ID_STORE=ANooJg7j9UxgJ2DNuLqUJs5h956qzc5LdPLFFtQdDb8M

LINK=684pDdcVZ8f4kwXjqwgkAJ7JuC6ry5U7qydwBkHvfSX

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ type Oracle = {
apis: string[]
}

type Transmission = {
latestTransmissionNo: number
roundId: number
answer: any
transmitter: string
}

// Returns a formatted oracle log given a list of addresses and a start tab
// if a list of oracles is provided, add context to logs
const makeOracleLog = (addresses: string[], startTab = 2, oracles?: Oracle[]): string[] => {
Expand Down Expand Up @@ -116,7 +123,7 @@ export default class OCR2InspectResponses extends SolanaCommand {

// Store observers from each transmission
const observerRounds: PublicKey[][] = []

const transmissionDetails: Transmission[] = []
events.forEach((event, i) => {
// Map observer indices into addresses
const observers = (event.observers as []).slice(0, event.observerCount).map((observer) => transmitters[observer])
Expand Down Expand Up @@ -144,7 +151,14 @@ export default class OCR2InspectResponses extends SolanaCommand {
${event.observerCount}/${transmitters.length} oracles are responding
`,
)

transmissionDetails.push(
{
latestTransmissionNo: i + 1,
roundId: event.roundId,
answer: parseInt(event.answer.toString(), 2),
transmitter: transmitters[event.transmitter].toString()
}
)
// Log oracles that are not responsive
var notResponding: number = 0
transmitters.forEach((transmitter) => {
Expand Down Expand Up @@ -185,10 +199,11 @@ export default class OCR2InspectResponses extends SolanaCommand {
const successfulInspection = inspection.inspect(inspections)

return {
data: transmissionDetails,
responses: [
{
tx: this.wrapInspectResponse(successfulInspection, state.toString()),
contract: state.toString(),
contract: state.toString()
},
],
} as Result<TransactionResponse>
Expand Down
50 changes: 31 additions & 19 deletions integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ import (
)

const (
ChainName = "solana"
ChainID = "localnet"
DefaultNodeCount = 5
DefaultTTL = "3h"
SolanaURL = "http://sol:8899"
ChainName = "solana"
LocalnetChainID = "localnet"
DevnetChainID = "devnet"
DefaultNodeCount = 5
DefaultTTL = "3h"
SolanaLocalNetURL = "http://sol:8899"
SolanaDevnetURL = "https://api.devnet.solana.com"
)

type Common struct {
Expand Down Expand Up @@ -94,11 +96,21 @@ func stripKeyPrefix(key string) string {
return key
}

func New() *Common {
func New(env string) *Common {
var err error
c := &Common{
ChainName: ChainName,
ChainId: ChainID,
var c *Common
if env == "devnet" {
c = &Common{
ChainName: ChainName,
ChainId: DevnetChainID,
SolanaUrl: SolanaDevnetURL,
}
} else {
c = &Common{
ChainName: ChainName,
ChainId: LocalnetChainID,
SolanaUrl: SolanaLocalNetURL,
}
}
// Checking if count of OCR nodes is defined in ENV
nodeCountSet, nodeCountDefined := os.LookupEnv("NODE_COUNT")
Expand Down Expand Up @@ -138,14 +150,14 @@ func New() *Common {

func (c *Common) CreateSolanaChainAndNode(nodes []*client.Chainlink) error {
for _, n := range nodes {
_, _, err := n.CreateSolanaChain(&client.SolanaChainAttributes{ChainID: ChainID})
_, _, err := n.CreateSolanaChain(&client.SolanaChainAttributes{ChainID: c.ChainId})
if err != nil {
return err
}
_, _, err = n.CreateSolanaNode(&client.SolanaNodeAttributes{
Name: ChainName,
SolanaChainID: ChainID,
SolanaURL: SolanaURL,
SolanaChainID: c.ChainId,
SolanaURL: c.SolanaUrl,
})
if err != nil {
return err
Expand All @@ -154,7 +166,7 @@ func (c *Common) CreateSolanaChainAndNode(nodes []*client.Chainlink) error {
return nil
}

func CreateNodeKeysBundle(nodes []*client.Chainlink) ([]client.NodeKeysBundle, error) {
func (c *Common) CreateNodeKeysBundle(nodes []*client.Chainlink) ([]client.NodeKeysBundle, error) {
nkb := make([]client.NodeKeysBundle, 0)
for _, n := range nodes {
p2pkeys, err := n.MustReadP2PKeys()
Expand All @@ -163,7 +175,7 @@ func CreateNodeKeysBundle(nodes []*client.Chainlink) ([]client.NodeKeysBundle, e
}

peerID := p2pkeys.Data[0].Attributes.PeerID
txKey, _, err := n.CreateTxKey(ChainName, ChainID)
txKey, _, err := n.CreateTxKey(ChainName, c.ChainId)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -327,19 +339,19 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo,
return nil
}

func pluginConfigToTomlFormat(pluginConfig string) job.JSONConfig {
func PluginConfigToTomlFormat(pluginConfig string) job.JSONConfig {
return job.JSONConfig{
"juelsPerFeeCoinSource": fmt.Sprintf("\"\"\"\n%s\n\"\"\"", pluginConfig),
}
}

func (c *Common) CreateJobsForContract(contractNodeInfo *ContractNodeInfo) error {
relayConfig := job.JSONConfig{
"nodeEndpointHTTP": fmt.Sprintf("\"%s\"", SolanaURL),
"nodeEndpointHTTP": fmt.Sprintf("\"%s\"", SolanaLocalNetURL),
"ocr2ProgramID": fmt.Sprintf("\"%s\"", contractNodeInfo.OCR2.ProgramAddress()),
"transmissionsID": fmt.Sprintf("\"%s\"", contractNodeInfo.Store.TransmissionsAddress()),
"storeProgramID": fmt.Sprintf("\"%s\"", contractNodeInfo.Store.ProgramAddress()),
"chainID": fmt.Sprintf("\"%s\"", ChainID),
"chainID": fmt.Sprintf("\"%s\"", LocalnetChainID),
}
bootstrapPeers := []client.P2PData{
{
Expand Down Expand Up @@ -381,7 +393,7 @@ func (c *Common) CreateJobsForContract(contractNodeInfo *ContractNodeInfo) error
ContractConfigConfirmations: 1,
ContractConfigTrackerPollInterval: models.Interval(15 * time.Second),
PluginType: "median",
PluginConfig: pluginConfigToTomlFormat(contractNodeInfo.BridgeInfos[nIdx].JuelsSource),
PluginConfig: PluginConfigToTomlFormat(contractNodeInfo.BridgeInfos[nIdx].JuelsSource),
},
}
if _, err := n.MustCreateJob(jobSpec); err != nil {
Expand Down Expand Up @@ -426,7 +438,7 @@ Enabled = true
DeltaDial = '5s'
DeltaReconcile = '5s'
ListenAddresses = ['0.0.0.0:6690']
`, ChainID, SolanaURL)
`, c.ChainId, c.SolanaUrl)
c.Env = environment.New(c.K8Config).
AddHelm(mockservercfg.New(nil)).
AddHelm(mockserver.New(nil)).
Expand Down
Loading

0 comments on commit 646bcad

Please sign in to comment.