Skip to content

Commit

Permalink
Merge branch 'develop' into rtinianov_wasmDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
nolag committed Sep 24, 2024
2 parents 7a0df5c + 8905e88 commit d5cd788
Show file tree
Hide file tree
Showing 14 changed files with 318 additions and 38 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-walls-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#added Soneium testnet chain configs
32 changes: 32 additions & 0 deletions core/chains/evm/config/toml/defaults/Soneium_Sepolia.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ChainID = '1946'
ChainType = 'optimismBedrock'
LinkContractAddress = '0x7ea13478Ea3961A0e8b538cb05a9DF0477c79Cd2'
FinalityDepth = 200
LogPollInterval = '2s'
NoNewHeadsThreshold = '40s'
MinIncomingConfirmations = 1
NoNewFinalizedHeadsThreshold = '120m' # Soneium can take upto 2Hours to finalize
FinalityTagEnabled = true

[GasEstimator]
EIP1559DynamicFees = true
PriceMin = '1 wei'
BumpMin = '1 mwei'

[GasEstimator.BlockHistory]
BlockHistorySize = 60

[Transactions]
ResendAfterThreshold = '30s'

[HeadTracker]
HistoryDepth = 300

[NodePool]
SyncThreshold = 10

[OCR]
ContractConfirmations = 1

[OCR2.Automation]
GasLimit = 6500000
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,29 @@ var (
Signer: "0x1a684B3d8f917fe496b7B1A8b29EDDAED64F649f",
},
}

aptosTargetDonPeers = []peer{
{
PeerID: "12D3KooWNBr1AD3vD3dzSLgg1tK56qyJoenDx7EYNnZpbr1g4jD6",
Signer: "a41f9a561ff2266d94240996a76f9c2b3b7d8184",
},
{
PeerID: "12D3KooWRRgWiZGw5GYsPa62CkwFNKJb5u4hWo4DinnvjG6GE6Nj",
Signer: "e4f3c7204776530fb7833db6f9dbfdb8bd0ec96892965324a71c20d6776f67f0",
},
{
PeerID: "12D3KooWKwzgUHw5YbqUsYUVt3yiLSJcqc8ANofUtqHX6qTm7ox2",
Signer: "4071ea00e2e2c76b3406018ba9f66bf6b9aee3a6762e62ac823b1ee91ba7d7b0",
},
{
PeerID: "12D3KooWBRux5o2bw1j3SQwEHzCspjkt7Xe3Y3agRUuab2SUnExj",
Signer: "6f5180c7d276876dbe413bf9b0efff7301d1367f39f4bac64180090cab70989b",
},
{
PeerID: "12D3KooWFqvDaMSDGa6eMSTF9en6G2c3ZbGLmaA5Xs3AgxVBPb8B",
Signer: "dbce9a6df8a04d54e52a109d01ee9b5d32873b1d2436cf7b7fae61fd6eca46f8",
},
}
)

type deployAndInitializeCapabilitiesRegistryCommand struct{}
Expand Down Expand Up @@ -236,6 +259,16 @@ func (c *deployAndInitializeCapabilitiesRegistryCommand) Run(args []string) {
log.Printf("failed to call GetHashedCapabilityId: %s", err)
}

aptosWriteChain := kcr.CapabilitiesRegistryCapability{
LabelledName: "write_aptos",
Version: "1.0.0",
CapabilityType: uint8(3), // target
}
awid, err := reg.GetHashedCapabilityId(&bind.CallOpts{}, aptosWriteChain.LabelledName, aptosWriteChain.Version)
if err != nil {
log.Printf("failed to call GetHashedCapabilityId: %s", err)
}

ocr := kcr.CapabilitiesRegistryCapability{
LabelledName: "offchain_reporting",
Version: "1.0.0",
Expand All @@ -249,6 +282,7 @@ func (c *deployAndInitializeCapabilitiesRegistryCommand) Run(args []string) {
tx, err := reg.AddCapabilities(env.Owner, []kcr.CapabilitiesRegistryCapability{
streamsTrigger,
writeChain,
aptosWriteChain,
ocr,
})
if err != nil {
Expand Down Expand Up @@ -306,6 +340,16 @@ func (c *deployAndInitializeCapabilitiesRegistryCommand) Run(args []string) {
nodes = append(nodes, n)
}

for _, targetPeer := range aptosTargetDonPeers {
n, innerErr := peerToNode(nopID, targetPeer)
if innerErr != nil {
panic(innerErr)
}

n.HashedCapabilityIds = [][32]byte{awid}
nodes = append(nodes, n)
}

tx, err = reg.AddNodes(env.Owner, nodes)
if err != nil {
log.Printf("failed to AddNodes: %s", err)
Expand Down Expand Up @@ -396,6 +440,35 @@ func (c *deployAndInitializeCapabilitiesRegistryCommand) Run(args []string) {
if err != nil {
log.Printf("targetDON: failed to AddDON: %s", err)
}

// Aptos target DON
ps, err = peers(aptosTargetDonPeers)
if err != nil {
panic(err)
}

targetCapabilityConfig = newCapabilityConfig()
targetCapabilityConfig.RemoteConfig = &capabilitiespb.CapabilityConfig_RemoteTargetConfig{
RemoteTargetConfig: &capabilitiespb.RemoteTargetConfig{
RequestHashExcludedAttributes: []string{"signed_report.Signatures"},
},
}

remoteTargetConfigBytes, err = proto.Marshal(targetCapabilityConfig)
if err != nil {
panic(err)
}

cfgs = []kcr.CapabilitiesRegistryCapabilityConfiguration{
{
CapabilityId: awid,
Config: remoteTargetConfigBytes,
},
}
_, err = reg.AddDON(env.Owner, ps, cfgs, true, false, 1)
if err != nil {
log.Printf("targetDON: failed to AddDON: %s", err)
}
}

func deployCapabilitiesRegistry(env helpers.Environment) *kcr.CapabilitiesRegistry {
Expand Down
5 changes: 3 additions & 2 deletions core/scripts/keystone/src/88_gen_jobspecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func genSpecs(

bootstrapSpecLines, err := readLines(filepath.Join(templatesDir, bootstrapSpecTemplate))
helpers.PanicErr(err)
bootHost := nodes[0].url.Hostname()
bootHost := nodes[0].remoteURL.Hostname()
bootstrapSpecLines = replacePlaceholders(
bootstrapSpecLines,
chainID, p2pPort,
Expand All @@ -59,7 +59,7 @@ func genSpecs(
ocrConfigContractAddress, bootHost,
bootstrapNode, nca[i],
)
oracles = append(oracles, hostSpec{oracleSpecLines, nodes[i].url.Host})
oracles = append(oracles, hostSpec{oracleSpecLines, nodes[i].remoteURL.Host})
}

return donHostSpec{
Expand All @@ -82,6 +82,7 @@ func replacePlaceholders(
l = strings.Replace(l, "{{ ocr_config_contract_address }}", contractAddress, 1)
l = strings.Replace(l, "{{ transmitter_id }}", node.EthAddress, 1)
l = strings.Replace(l, "{{ ocr_key_bundle_id }}", node.OCR2BundleID, 1)
l = strings.Replace(l, "{{ aptos_key_bundle_id }}", node.AptosBundleID, 1)
l = strings.Replace(l, "{{ bootstrapper_p2p_id }}", bootstrapper, 1)
output = append(output, l)
}
Expand Down
24 changes: 16 additions & 8 deletions core/scripts/keystone/src/88_gen_ocr3_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ type OracleConfigSource struct {
}

type NodeKeys struct {
EthAddress string
P2PPeerID string // p2p_<key>
OCR2BundleID string // used only in job spec
OCR2OnchainPublicKey string // ocr2on_evm_<key>
OCR2OffchainPublicKey string // ocr2off_evm_<key>
OCR2ConfigPublicKey string // ocr2cfg_evm_<key>
CSAPublicKey string
EthAddress string `json:"EthAddress"`
AptosAccount string `json:"AptosAccount"`
AptosBundleID string `json:"AptosBundleID"`
AptosOnchainPublicKey string `json:"AptosOnchainPublicKey"`
P2PPeerID string `json:"P2PPeerID"` // p2p_<key>
OCR2BundleID string `json:"OCR2BundleID"` // used only in job spec
OCR2OnchainPublicKey string `json:"OCR2OnchainPublicKey"` // ocr2on_evm_<key>
OCR2OffchainPublicKey string `json:"OCR2OffchainPublicKey"` // ocr2off_evm_<key>
OCR2ConfigPublicKey string `json:"OCR2ConfigPublicKey"` // ocr2cfg_evm_<key>
CSAPublicKey string `json:"CSAPublicKey"`
}

type orc2drOracleConfig struct {
Expand Down Expand Up @@ -107,8 +110,13 @@ func generateOCR3Config(nodeList string, configFile string, chainID int64, pubKe
allPubKeys := map[string]any{}
for _, n := range nca {
ethPubKey := common.HexToAddress(n.OCR2OnchainPublicKey)
aptosPubKey, err := hex.DecodeString(n.AptosOnchainPublicKey)
if err != nil {
panic(err)
}
pubKeys := map[string]types.OnchainPublicKey{
"evm": ethPubKey[:],
"evm": ethPubKey[:],
"aptos": aptosPubKey,
}
// validate uniqueness of each individual key
for _, key := range pubKeys {
Expand Down
58 changes: 50 additions & 8 deletions core/scripts/keystone/src/99_fetch_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

helpers "github.com/smartcontractkit/chainlink/core/scripts/common"
ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big"
"github.com/smartcontractkit/chainlink/v2/core/cmd"
"github.com/smartcontractkit/chainlink/v2/core/web/presenters"
)

Expand Down Expand Up @@ -118,6 +119,19 @@ func mustFetchNodesKeys(chainID int64, nodes []*node) (nca []NodeKeys) {
helpers.PanicErr(err)
output.Reset()

keysClient := cmd.NewAptosKeysClient(client)
err = keysClient.ListKeys(&cli.Context{
App: app,
})
helpers.PanicErr(err)
var aptosKeys []presenters.AptosKeyResource
helpers.PanicErr(json.Unmarshal(output.Bytes(), &aptosKeys))
if len(aptosKeys) != 1 {
helpers.PanicErr(errors.New("node must have single aptos key"))
}
aptosAccount := aptosKeys[0].Account
output.Reset()

err = client.ListP2PKeys(&cli.Context{
App: app,
})
Expand All @@ -130,18 +144,20 @@ func mustFetchNodesKeys(chainID int64, nodes []*node) (nca []NodeKeys) {
peerID := strings.TrimPrefix(p2pKeys[0].PeerID, "p2p_")
output.Reset()

chainType := "evm"

var ocr2Bundles []ocr2Bundle
err = client.ListOCR2KeyBundles(&cli.Context{
App: app,
})
helpers.PanicErr(err)
helpers.PanicErr(json.Unmarshal(output.Bytes(), &ocr2Bundles))
ocr2BundleIndex := findEvmOCR2Bundle(ocr2Bundles)
ocr2BundleIndex := findOCR2Bundle(ocr2Bundles, chainType)
output.Reset()
if ocr2BundleIndex == -1 {
fmt.Println("WARN: node does not have EVM OCR2 bundle, creating one")
fs := flag.NewFlagSet("test", flag.ContinueOnError)
err = fs.Parse([]string{"evm"})
err = fs.Parse([]string{chainType})
helpers.PanicErr(err)
ocr2CreateBundleCtx := cli.NewContext(app, fs, nil)
err = client.CreateOCR2KeyBundle(ocr2CreateBundleCtx)
Expand All @@ -153,12 +169,35 @@ func mustFetchNodesKeys(chainID int64, nodes []*node) (nca []NodeKeys) {
})
helpers.PanicErr(err)
helpers.PanicErr(json.Unmarshal(output.Bytes(), &ocr2Bundles))
ocr2BundleIndex = findEvmOCR2Bundle(ocr2Bundles)
ocr2BundleIndex = findOCR2Bundle(ocr2Bundles, chainType)
output.Reset()
}

ocr2Bndl := ocr2Bundles[ocr2BundleIndex]

aptosBundleIndex := findOCR2Bundle(ocr2Bundles, "aptos")
if aptosBundleIndex == -1 {
chainType2 := "aptos"
fmt.Println("WARN: node does not have Aptos OCR2 bundle, creating one")
fs := flag.NewFlagSet("test", flag.ContinueOnError)
err = fs.Parse([]string{chainType2})
helpers.PanicErr(err)
ocr2CreateBundleCtx := cli.NewContext(app, fs, nil)
err = client.CreateOCR2KeyBundle(ocr2CreateBundleCtx)
helpers.PanicErr(err)
output.Reset()

err = client.ListOCR2KeyBundles(&cli.Context{
App: app,
})
helpers.PanicErr(err)
helpers.PanicErr(json.Unmarshal(output.Bytes(), &ocr2Bundles))
aptosBundleIndex = findOCR2Bundle(ocr2Bundles, chainType2)
output.Reset()
}

aptosBundle := ocr2Bundles[aptosBundleIndex]

err = client.ListCSAKeys(&cli.Context{
App: app,
})
Expand All @@ -171,11 +210,14 @@ func mustFetchNodesKeys(chainID int64, nodes []*node) (nca []NodeKeys) {

nc := NodeKeys{
EthAddress: ethAddress,
AptosAccount: aptosAccount,
P2PPeerID: peerID,
AptosBundleID: aptosBundle.ID,
AptosOnchainPublicKey: strings.TrimPrefix(aptosBundle.OnchainPublicKey, fmt.Sprintf("ocr2on_%s_", "aptos")),
OCR2BundleID: ocr2Bndl.ID,
OCR2ConfigPublicKey: strings.TrimPrefix(ocr2Bndl.ConfigPublicKey, "ocr2cfg_evm_"),
OCR2OnchainPublicKey: strings.TrimPrefix(ocr2Bndl.OnchainPublicKey, "ocr2on_evm_"),
OCR2OffchainPublicKey: strings.TrimPrefix(ocr2Bndl.OffchainPublicKey, "ocr2off_evm_"),
OCR2ConfigPublicKey: strings.TrimPrefix(ocr2Bndl.ConfigPublicKey, fmt.Sprintf("ocr2cfg_%s_", chainType)),
OCR2OnchainPublicKey: strings.TrimPrefix(ocr2Bndl.OnchainPublicKey, fmt.Sprintf("ocr2on_%s_", chainType)),
OCR2OffchainPublicKey: strings.TrimPrefix(ocr2Bndl.OffchainPublicKey, fmt.Sprintf("ocr2off_%s_", chainType)),
CSAPublicKey: csaPubKey,
}

Expand All @@ -191,9 +233,9 @@ func findFirstCSAPublicKey(csaKeyResources []presenters.CSAKeyResource) (string,
return "", errors.New("did not find any CSA Key Resources")
}

func findEvmOCR2Bundle(ocr2Bundles []ocr2Bundle) int {
func findOCR2Bundle(ocr2Bundles []ocr2Bundle, chainType string) int {
for i, b := range ocr2Bundles {
if b.ChainType == "evm" {
if b.ChainType == chainType {
return i
}
}
Expand Down
17 changes: 10 additions & 7 deletions core/scripts/keystone/src/99_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
)

type node struct {
url *url.URL
login string
password string
url *url.URL
remoteURL *url.URL
login string
password string
}

func (n node) IsTerminal() bool {
Expand Down Expand Up @@ -50,19 +51,21 @@ func mustReadNodesList(path string) []*node {
continue
}
s := strings.Split(rr, " ")
if len(s) != 3 {
if len(s) != 4 {
helpers.PanicErr(errors.New("wrong nodes list format"))
}
if strings.Contains(s[0], "boot") && hasBoot {
helpers.PanicErr(errors.New("the single boot node must come first"))
}
hasBoot = true
url, err := url.Parse(s[0])
remoteURL, err := url.Parse(s[1])
helpers.PanicErr(err)
nodes = append(nodes, &node{
url: url,
login: s[1],
password: s[2],
url: url,
remoteURL: remoteURL,
login: s[2],
password: s[3],
})
}
return nodes
Expand Down
Loading

0 comments on commit d5cd788

Please sign in to comment.