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

Initialization for Crib #15501

Merged
merged 30 commits into from
Dec 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
22fafc1
wip
0xAustinWang Dec 4, 2024
ea946d0
test crib integration flow
0xAustinWang Dec 4, 2024
2deda83
Merge branch 'develop' into aw/cribSetup
0xAustinWang Dec 4, 2024
b05777d
build failures
0xAustinWang Dec 4, 2024
26863f7
changes from ani's comments
0xAustinWang Dec 5, 2024
058bd6e
Merge branch 'develop' into aw/cribSetup
0xAustinWang Dec 5, 2024
6bf1bf6
some changes
0xAustinWang Dec 5, 2024
8b558da
revert isempty check
0xAustinWang Dec 5, 2024
848c49a
go lint and compare integers
0xAustinWang Dec 6, 2024
dc7744b
fix types in test
0xAustinWang Dec 6, 2024
1361cee
check for error if there's already a feeds manager
0xAustinWang Dec 6, 2024
6d799af
check if job distributors exist first
0xAustinWang Dec 9, 2024
5791b42
wip changes
0xAustinWang Dec 9, 2024
df1680c
add retries to consistently failing JD cals
0xAustinWang Dec 10, 2024
af23f93
update retries with static duration
0xAustinWang Dec 10, 2024
c42ac14
remove print statements
0xAustinWang Dec 10, 2024
72c5eed
Merge branch 'develop' into aw/cribSetup
0xAustinWang Dec 10, 2024
52585a6
fix compile error
scheibinger Dec 10, 2024
a05bc79
Merge branch 'develop' into aw/cribSetup
0xAustinWang Dec 10, 2024
50479b7
remove unnecessary mcms changes
0xAustinWang Dec 11, 2024
1083fd0
build issues
0xAustinWang Dec 11, 2024
63c8b1b
passing deployment
0xAustinWang Dec 11, 2024
0dd4fde
clean up code comments
0xAustinWang Dec 11, 2024
791c013
gomodtidy
0xAustinWang Dec 11, 2024
56b5f87
lint
0xAustinWang Dec 11, 2024
1713660
formatting strings
0xAustinWang Dec 11, 2024
a8d7cf9
use the common changeset utilities when deploying home chain as well
0xAustinWang Dec 11, 2024
030ab7a
compare nodes job distributors public key against the one we expect
0xAustinWang Dec 12, 2024
95cd43e
move state reader under deployment module
scheibinger Dec 12, 2024
8b31af9
add RPC type with internal and external rpcs
scheibinger Dec 12, 2024
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
Prev Previous commit
Next Next commit
move state reader under deployment module
  • Loading branch information
scheibinger committed Dec 12, 2024
commit 95cd43ea77ae64c53faec116c24c0e25987a7ad0
95 changes: 95 additions & 0 deletions deployment/environment/crib/data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package crib

import (
"encoding/json"
"fmt"
"io"
"os"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/environment/devenv"
)

type OutputReader struct {
outputDir string
}

func NewOutputReader(outputDir string) *OutputReader {
return &OutputReader{outputDir: outputDir}
}

func (r *OutputReader) ReadNodesDetails() NodesDetails {
byteValue := r.readFile(NodesDetailsFileName)

var result NodesDetails

// Unmarshal the JSON into the map
err := json.Unmarshal(byteValue, &result)
if err != nil {
fmt.Println("Error unmarshalling JSON:", err)
panic(err)
}

return result
}

func (r *OutputReader) ReadChainConfigs() []devenv.ChainConfig {
byteValue := r.readFile(ChainsConfigsFileName)

var result []devenv.ChainConfig

// Unmarshal the JSON into the map
err := json.Unmarshal(byteValue, &result)
if err != nil {
fmt.Println("Error unmarshalling JSON:", err)
panic(err)
}

return result
}

func ToChainConfigs(cc []ChainConfig) []devenv.ChainConfig {
chainConfigs := make([]devenv.ChainConfig, 0)
for _, c := range cc {
chainConfigs = append(chainConfigs, devenv.ChainConfig{
ChainID: c.ChainID,
ChainName: c.ChainName,
ChainType: c.ChainType,
WSRPCs: c.WSRPCs,
HTTPRPCs: c.HTTPRPCs,
})
}
return chainConfigs
}

func (r *OutputReader) ReadAddressBook() *deployment.AddressBookMap {
byteValue := r.readFile(AddressBookFileName)

var result map[uint64]map[string]deployment.TypeAndVersion

// Unmarshal the JSON into the map
err := json.Unmarshal(byteValue, &result)
if err != nil {
fmt.Println("Error unmarshalling JSON:", err)
panic(err)
}

return deployment.NewMemoryAddressBookFromMap(result)
}

func (r *OutputReader) readFile(fileName string) []byte {
file, err := os.Open(fmt.Sprintf("%s/%s", r.outputDir, fileName))
if err != nil {
fmt.Println("Error opening file:", err)
panic(err)
}
defer file.Close()

// Read the file's content into a byte slice
byteValue, err := io.ReadAll(file)
if err != nil {
fmt.Println("Error reading file:", err)
panic(err)
}
return byteValue
}
40 changes: 40 additions & 0 deletions deployment/environment/crib/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package crib

const (
AddressBookFileName = "ccip-v2-scripts-address-book.json"
NodesDetailsFileName = "ccip-v2-scripts-nodes-details.json"
ChainsConfigsFileName = "ccip-v2-scripts-chains-details.json"
)

type CRIBEnv struct {
envStateDir string
}

func NewDevspaceEnvFromStateDir(envStateDir string) CRIBEnv {
return CRIBEnv{
envStateDir: envStateDir,
}
}

func (c CRIBEnv) GetConfig() DeployOutput {
reader := NewOutputReader(c.envStateDir)
nodesDetails := reader.ReadNodesDetails()
chainConfigs := reader.ReadChainConfigs()
return DeployOutput{
AddressBook: reader.ReadAddressBook(),
NodeIDs: nodesDetails.NodeIDs,
Chains: chainConfigs,
}
}

type ChainConfig struct {
ChainID uint64 // chain id as per EIP-155, mainly applicable for EVM chains
ChainName string // name of the chain populated from chainselector repo
ChainType string // should denote the chain family. Acceptable values are EVM, COSMOS, SOLANA, STARKNET, APTOS etc
WSRPCs []string // websocket rpcs to connect to the chain
HTTPRPCs []string // http rpcs to connect to the chain
}

type NodesDetails struct {
NodeIDs []string
}
18 changes: 18 additions & 0 deletions deployment/environment/crib/env_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package crib

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestShouldProvideEnvironmentConfig(t *testing.T) {
t.Parallel()
env := NewDevspaceEnvFromStateDir("testdata/lanes-deployed-state")
config := env.GetConfig()
require.NotNil(t, config)
assert.NotEmpty(t, config.NodeIDs)
assert.NotNil(t, config.AddressBook)
assert.NotEmpty(t, config.Chains)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"12922642891491394802":{"0x05Aa229Aec102f78CE0E852A812a388F076Aa555":{"Type":"CancellerManyChainMultiSig","Version":"1.0.0"},"0x0D4ff719551E23185Aeb16FFbF2ABEbB90635942":{"Type":"TestRouter","Version":"1.2.0"},"0x0f5D1ef48f12b6f691401bfe88c2037c690a6afe":{"Type":"ProposerManyChainMultiSig","Version":"1.0.0"},"0x2dE080e97B0caE9825375D31f5D0eD5751fDf16D":{"Type":"CCIPReceiver","Version":"1.0.0"},"0x2fc631e4B3018258759C52AF169200213e84ABab":{"Type":"OnRamp","Version":"1.6.0-dev"},"0x5C7c905B505f0Cf40Ab6600d05e677F717916F6B":{"Type":"Router","Version":"1.2.0"},"0x63cf2Cd54fE91e3545D1379abf5bfd194545259d":{"Type":"OffRamp","Version":"1.6.0-dev"},"0x712516e61C8B383dF4A63CFe83d7701Bce54B03e":{"Type":"LinkToken","Version":"1.0.0"},"0x71C95911E9a5D330f4D621842EC243EE1343292e":{"Type":"PriceFeed","Version":"1.0.0"},"0x73eccD6288e117cAcA738BDAD4FEC51312166C1A":{"Type":"RMNRemote","Version":"1.6.0-dev"},"0x8464135c8F25Da09e49BC8782676a84730C318bC":{"Type":"PriceFeed","Version":"1.0.0"},"0x85C5Dd61585773423e378146D4bEC6f8D149E248":{"Type":"TokenAdminRegistry","Version":"1.5.0"},"0x948B3c65b89DF0B4894ABE91E6D02FE579834F8F":{"Type":"WETH9","Version":"1.0.0"},"0xAfe1b5bdEbD4ae65AF2024738bf0735fbb65d44b":{"Type":"FeeQuoter","Version":"1.6.0-dev"},"0xC6bA8C3233eCF65B761049ef63466945c362EdD2":{"Type":"BypasserManyChainMultiSig","Version":"1.0.0"},"0xbCF26943C0197d2eE0E5D05c716Be60cc2761508":{"Type":"AdminManyChainMultiSig","Version":"1.0.0"},"0xcA03Dc4665A8C3603cb4Fd5Ce71Af9649dC00d44":{"Type":"RBACTimelock","Version":"1.0.0"},"0xe6b98F104c1BEf218F3893ADab4160Dc73Eb8367":{"Type":"ARMProxy","Version":"1.0.0"},"0xfbAb4aa40C202E4e80390171E82379824f7372dd":{"Type":"NonceManager","Version":"1.6.0-dev"}},"3379446385462418246":{"0x09635F643e140090A9A8Dcd712eD6285858ceBef":{"Type":"RMNRemote","Version":"1.6.0-dev"},"0x0B306BF915C4d645ff596e518fAf3F9669b97016":{"Type":"LinkToken","Version":"1.0.0"},"0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8":{"Type":"OnRamp","Version":"1.6.0-dev"},"0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6":{"Type":"CCIPHome","Version":"1.6.0-dev"},"0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44":{"Type":"ProposerManyChainMultiSig","Version":"1.0.0"},"0x3Aa5ebB10DC797CAC828524e59A333d0A371443c":{"Type":"BypasserManyChainMultiSig","Version":"1.0.0"},"0x4A679253410272dd5232B3Ff7cF5dbB88f295319":{"Type":"RBACTimelock","Version":"1.0.0"},"0x59b670e9fA9D0A427751Af201D676719a970857b":{"Type":"CancellerManyChainMultiSig","Version":"1.0.0"},"0x67d269191c92Caf3cD7723F116c85e6E9bf55933":{"Type":"ARMProxy","Version":"1.0.0"},"0x7a2088a1bFc9d81c55368AE168C2C02570cB814F":{"Type":"CCIPReceiver","Version":"1.0.0"},"0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB":{"Type":"TokenAdminRegistry","Version":"1.5.0"},"0x851356ae760d987E095750cCeb3bC6014560891C":{"Type":"OffRamp","Version":"1.6.0-dev"},"0x8A791620dd6260079BF849Dc5567aDC3F2FdC318":{"Type":"RMNHome","Version":"1.6.0-dev"},"0x9A676e781A523b5d0C0e43731313A708CB607508":{"Type":"WETH9","Version":"1.0.0"},"0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE":{"Type":"AdminManyChainMultiSig","Version":"1.0.0"},"0x9E545E3C0baAB3E08CdfD552C960A1050f373042":{"Type":"NonceManager","Version":"1.6.0-dev"},"0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E":{"Type":"Router","Version":"1.2.0"},"0xa513E6E4b8f2a923D98304ec87F64353C4D5C853":{"Type":"CapabilitiesRegistry","Version":"1.0.0"},"0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9":{"Type":"FeeQuoter","Version":"1.6.0-dev"},"0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690":{"Type":"TestRouter","Version":"1.2.0"}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
{
"ChainID": 1337,
"ChainName": "alpha",
"ChainType": "EVM",
"WSRPCs": [
"wss://crib-local-geth-1337-ws.local:443"
],
"HTTPRPCs": [
"https://crib-local-geth-1337-ws.local:443"
]
},
{
"ChainID": 2337,
"ChainName": "alpha",
"ChainType": "EVM",
"WSRPCs": [
"wss://crib-local-geth-2337-ws.local:443"
],
"HTTPRPCs": [
"https://crib-local-geth-2337-ws.local:443"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"NodeIDs":["node_2URuou3RXmtZu5gLQX8qd","node_m9TTQbUxBx3WjDEjmpVDL","node_4FiKVPtuQjCTvHnS7QpES","node_A4VTgecDwMoG2YYicyjuG","node_jQFpzXDadzaADq147nThS"]}
Loading