Skip to content

Commit

Permalink
increase finality depth for chains with 1 finality depth to 10 (#12756)
Browse files Browse the repository at this point in the history
* change finality depth from 1 to 10

* run make config-docs

* update changeset

* fix HistoryDepth

* make config-docs

* Added LogPoller replay

* linting fix

* Added replay fix for MercuryV1 integration test

* Updated finality depth commitments

* linting issue fix

* updated comments in tests

---------

Co-authored-by: Silas Lenihan <[email protected]>
Co-authored-by: Silas Lenihan <[email protected]>
Co-authored-by: Prashant Yadav <[email protected]>
  • Loading branch information
4 people authored Jun 4, 2024
1 parent d2cd916 commit 50870c3
Show file tree
Hide file tree
Showing 24 changed files with 99 additions and 83 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-years-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

update finality depth for chains #nops
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Avalanche_Fuji.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ChainID = '43113'
FinalityDepth = 1
FinalityDepth = 10
LinkContractAddress = '0x0b9d5D9136855f6FEc3c0993feE6E9CE8a297846'
LogPollInterval = '3s'
MinIncomingConfirmations = 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ChainID = '43114'
FinalityDepth = 1
FinalityDepth = 10
LinkContractAddress = '0x5947BB275c521040051D82396192181b413227A3'
LogPollInterval = '3s'
MinIncomingConfirmations = 1
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Celo_Mainnet.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ChainID = '42220'
ChainType = 'celo'
FinalityDepth = 1
FinalityDepth = 10
LogPollInterval = '5s'
MinIncomingConfirmations = 1
NoNewHeadsThreshold = '1m'
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Celo_Testnet.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ChainID = '44787'
ChainType = 'celo'
FinalityDepth = 1
FinalityDepth = 10
LogPollInterval = '5s'
MinIncomingConfirmations = 1
NoNewHeadsThreshold = '1m'
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Klaytn_Mainnet.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ChainID = '8217'
FinalityDepth = 1
FinalityDepth = 10
MinIncomingConfirmations = 1
NoNewHeadsThreshold = '30s'
OCR.ContractConfirmations = 1
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Klaytn_Testnet.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ChainID = '1001'
FinalityDepth = 1
FinalityDepth = 10
MinIncomingConfirmations = 1
NoNewHeadsThreshold = '30s'
OCR.ContractConfirmations = 1
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Metis_Mainnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ChainID = '1088'
ChainType = 'metis'
# Sequencer offers absolute finality
FinalityDepth = 1
FinalityDepth = 10
MinIncomingConfirmations = 1
NoNewHeadsThreshold = '0'
OCR.ContractConfirmations = 1
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Metis_Rinkeby.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ChainID = '588'
ChainType = 'metis'
FinalityDepth = 1
FinalityDepth = 10
MinIncomingConfirmations = 1
NoNewHeadsThreshold = '0'
OCR.ContractConfirmations = 1
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Metis_Sepolia.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ChainID = '59902'
ChainType = 'metis'
FinalityDepth = 1
FinalityDepth = 10
MinIncomingConfirmations = 1
NoNewHeadsThreshold = '0'
OCR.ContractConfirmations = 1
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Scroll_Mainnet.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ChainID = '534352'
FinalityDepth = 1
FinalityDepth = 10
ChainType = 'scroll'
LogPollInterval = '3s'
MinIncomingConfirmations = 1
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Scroll_Sepolia.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ChainID = '534351'
FinalityDepth = 1
FinalityDepth = 10
ChainType = 'scroll'
LogPollInterval = '3s'
MinIncomingConfirmations = 1
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Simulated.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ChainID = '1337'
FinalityDepth = 1
FinalityDepth = 10
MinIncomingConfirmations = 1
MinContractPayment = '100'
NoNewHeadsThreshold = '0s'
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/WeMix_Mainnet.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ChainID = '1111'
ChainType = 'wemix'
FinalityDepth = 1
FinalityDepth = 10
MinIncomingConfirmations = 1
# WeMix emits a block every 1 second, regardless of transactions
LogPollInterval = '3s'
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/WeMix_Testnet.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ChainID = '1112'
ChainType = 'wemix'
FinalityDepth = 1
FinalityDepth = 10
MinIncomingConfirmations = 1
# WeMix emits a block every 1 second, regardless of transactions
LogPollInterval = '3s'
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/config/toml/defaults/zkSync_Goerli.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ChainID = '280'
ChainType = 'zksync'
FinalityDepth = 1
FinalityDepth = 10
LogPollInterval = '5s'
MinIncomingConfirmations = 1
NoNewHeadsThreshold = '1m'
Expand All @@ -11,4 +11,4 @@ PriceMax = 18446744073709551615
PriceMin = 0

[HeadTracker]
HistoryDepth = 5
HistoryDepth = 50
4 changes: 2 additions & 2 deletions core/chains/evm/config/toml/defaults/zkSync_Mainnet.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ChainID = '324'
ChainType = 'zksync'
FinalityDepth = 1
FinalityDepth = 10
LogPollInterval = '5s'
MinIncomingConfirmations = 1
NoNewHeadsThreshold = '1m'
Expand All @@ -11,4 +11,4 @@ PriceMax = 18446744073709551615
PriceMin = 0

[HeadTracker]
HistoryDepth = 5
HistoryDepth = 50
4 changes: 2 additions & 2 deletions core/chains/evm/config/toml/defaults/zkSync_Sepolia.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ChainID = '300'
ChainType = 'zksync'
FinalityDepth = 1
FinalityDepth = 10
LogPollInterval = '5s'
MinIncomingConfirmations = 1
NoNewHeadsThreshold = '1m'
Expand All @@ -11,4 +11,4 @@ PriceMax = 18446744073709551615
PriceMin = 0

[HeadTracker]
HistoryDepth = 5
HistoryDepth = 50
2 changes: 1 addition & 1 deletion core/scripts/ocr2vrf/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var (
Enabled = true
[[EVM]]
FinalityDepth = 1
FinalityDepth = 10
ChainID = '%d'
[EVM.Transactions]
Expand Down
9 changes: 4 additions & 5 deletions core/services/ocr2/plugins/llo/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,19 @@ func TestIntegration_LLO(t *testing.T) {
})
}

configDigest := setConfig(t, steve, backend, verifierContract, verifierAddress, nodes, oracles)
channelDefinitions := setChannelDefinitions(t, steve, backend, configStoreContract, streams)

// Bury everything with finality depth
// Commit blocks to finality depth to ensure LogPoller has finalized blocks to read from
ch, err := nodes[0].App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String())
require.NoError(t, err)
finalityDepth := ch.Config().EVM().FinalityDepth()
for i := 0; i < int(finalityDepth); i++ {
backend.Commit()
}

configDigest := setConfig(t, steve, backend, verifierContract, verifierAddress, nodes, oracles)
channelDefinitions := setChannelDefinitions(t, steve, backend, configStoreContract, streams)

addBootstrapJob(t, bootstrapNode, chainID, verifierAddress, "job-1")
addOCRJobs(t, streams, serverPubKey, serverURL, verifierAddress, bootstrapPeerID, bootstrapNodePort, nodes, configStoreAddress, clientPubKeys, chainID, fromBlock)

t.Run("receives at least one report per feed from each oracle when EAs are at 100% reliability", func(t *testing.T) {
// Expect at least one report per channel from each oracle (keyed by transmitter ID)
seen := make(map[ocr2types.Account]map[llotypes.ChannelID]struct{})
Expand Down
73 changes: 38 additions & 35 deletions core/services/ocr2/plugins/mercury/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func integration_MercuryV1(t *testing.T) {
detectPanicLogs(t, logObservers)
})
lggr := logger.TestLogger(t)
const fromBlock = 1 // cannot use zero, start from block 1
testStartTimeStamp := uint32(time.Now().Unix())

// test vars
Expand Down Expand Up @@ -185,6 +184,16 @@ func integration_MercuryV1(t *testing.T) {
bootstrapNode := Node{App: appBootstrap, KeyBundle: bootstrapKb}
logObservers = append(logObservers, observedLogs)

// Commit blocks to finality depth to ensure LogPoller has finalized blocks to read from
ch, err := bootstrapNode.App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String())
require.NoError(t, err)
finalityDepth := ch.Config().EVM().FinalityDepth()
for i := 0; i < int(finalityDepth); i++ {
backend.Commit()
}

fromBlock := int(finalityDepth) // cannot use zero, start from finality depth

// Set up n oracles
var (
oracles []confighelper.OracleIdentityExtra
Expand Down Expand Up @@ -216,7 +225,8 @@ func integration_MercuryV1(t *testing.T) {

createBridge := func(name string, i int, p *big.Int, borm bridges.ORM) (bridgeName string) {
bridge := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
b, err := io.ReadAll(req.Body)
var b []byte
b, err = io.ReadAll(req.Body)
require.NoError(t, err)
require.Equal(t, `{"data":{"from":"ETH","to":"USD"}}`, string(b))

Expand All @@ -225,12 +235,12 @@ func integration_MercuryV1(t *testing.T) {
res.WriteHeader(http.StatusOK)
val := decimal.NewFromBigInt(p, 0).Div(decimal.NewFromInt(multiplier)).Add(decimal.NewFromInt(int64(i)).Div(decimal.NewFromInt(100))).String()
resp := fmt.Sprintf(`{"result": %s}`, val)
_, err := res.Write([]byte(resp))
_, err = res.Write([]byte(resp))
require.NoError(t, err)
} else {
res.WriteHeader(http.StatusInternalServerError)
resp := `{"error": "pError test error"}`
_, err := res.Write([]byte(resp))
_, err = res.Write([]byte(resp))
require.NoError(t, err)
}
}))
Expand Down Expand Up @@ -272,7 +282,6 @@ func integration_MercuryV1(t *testing.T) {
)
}
}

// Setup config on contract
onchainConfig, err := (datastreamsmercury.StandardOnchainConfigCodec{}).Encode(rawOnchainConfig)
require.NoError(t, err)
Expand Down Expand Up @@ -334,14 +343,6 @@ func integration_MercuryV1(t *testing.T) {
backend.Commit()
}

// Bury it with finality depth
ch, err := bootstrapNode.App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String())
require.NoError(t, err)
finalityDepth := ch.Config().EVM().FinalityDepth()
for i := 0; i < int(finalityDepth); i++ {
backend.Commit()
}

t.Run("receives at least one report per feed from each oracle when EAs are at 100% reliability", func(t *testing.T) {
// Expect at least one report per feed from each oracle
seen := make(map[[32]byte]map[credentials.StaticSizedPublicKey]struct{})
Expand Down Expand Up @@ -539,6 +540,14 @@ func integration_MercuryV2(t *testing.T) {
bootstrapNode := Node{App: appBootstrap, KeyBundle: bootstrapKb}
logObservers = append(logObservers, observedLogs)

// Commit blocks to finality depth to ensure LogPoller has finalized blocks to read from
ch, err := bootstrapNode.App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String())
require.NoError(t, err)
finalityDepth := ch.Config().EVM().FinalityDepth()
for i := 0; i < int(finalityDepth); i++ {
backend.Commit()
}

// Set up n oracles
var (
oracles []confighelper.OracleIdentityExtra
Expand Down Expand Up @@ -571,7 +580,8 @@ func integration_MercuryV2(t *testing.T) {

createBridge := func(name string, i int, p *big.Int, borm bridges.ORM) (bridgeName string) {
bridge := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
b, err := io.ReadAll(req.Body)
var b []byte
b, err = io.ReadAll(req.Body)
require.NoError(t, err)
require.Equal(t, `{"data":{"from":"ETH","to":"USD"}}`, string(b))

Expand All @@ -580,12 +590,12 @@ func integration_MercuryV2(t *testing.T) {
res.WriteHeader(http.StatusOK)
val := decimal.NewFromBigInt(p, 0).Div(decimal.NewFromInt(multiplier)).Add(decimal.NewFromInt(int64(i)).Div(decimal.NewFromInt(100))).String()
resp := fmt.Sprintf(`{"result": %s}`, val)
_, err := res.Write([]byte(resp))
_, err = res.Write([]byte(resp))
require.NoError(t, err)
} else {
res.WriteHeader(http.StatusInternalServerError)
resp := `{"error": "pError test error"}`
_, err := res.Write([]byte(resp))
_, err = res.Write([]byte(resp))
require.NoError(t, err)
}
}))
Expand Down Expand Up @@ -673,14 +683,6 @@ func integration_MercuryV2(t *testing.T) {
backend.Commit()
}

// Bury it with finality depth
ch, err := bootstrapNode.App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String())
require.NoError(t, err)
finalityDepth := ch.Config().EVM().FinalityDepth()
for i := 0; i < int(finalityDepth); i++ {
backend.Commit()
}

runTestSetup := func() {
// Expect at least one report per feed from each oracle
seen := make(map[[32]byte]map[credentials.StaticSizedPublicKey]struct{})
Expand Down Expand Up @@ -828,6 +830,14 @@ func integration_MercuryV3(t *testing.T) {
bootstrapNode := Node{App: appBootstrap, KeyBundle: bootstrapKb}
logObservers = append(logObservers, observedLogs)

// Commit blocks to finality depth to ensure LogPoller has finalized blocks to read from
ch, err := bootstrapNode.App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String())
require.NoError(t, err)
finalityDepth := ch.Config().EVM().FinalityDepth()
for i := 0; i < int(finalityDepth); i++ {
backend.Commit()
}

// Set up n oracles
var (
oracles []confighelper.OracleIdentityExtra
Expand Down Expand Up @@ -860,7 +870,8 @@ func integration_MercuryV3(t *testing.T) {

createBridge := func(name string, i int, p *big.Int, borm bridges.ORM) (bridgeName string) {
bridge := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
b, err := io.ReadAll(req.Body)
var b []byte
b, err = io.ReadAll(req.Body)
require.NoError(t, err)
require.Equal(t, `{"data":{"from":"ETH","to":"USD"}}`, string(b))

Expand All @@ -869,12 +880,12 @@ func integration_MercuryV3(t *testing.T) {
res.WriteHeader(http.StatusOK)
val := decimal.NewFromBigInt(p, 0).Div(decimal.NewFromInt(multiplier)).Add(decimal.NewFromInt(int64(i)).Div(decimal.NewFromInt(100))).String()
resp := fmt.Sprintf(`{"result": %s}`, val)
_, err := res.Write([]byte(resp))
_, err = res.Write([]byte(resp))
require.NoError(t, err)
} else {
res.WriteHeader(http.StatusInternalServerError)
resp := `{"error": "pError test error"}`
_, err := res.Write([]byte(resp))
_, err = res.Write([]byte(resp))
require.NoError(t, err)
}
}))
Expand Down Expand Up @@ -965,14 +976,6 @@ func integration_MercuryV3(t *testing.T) {
backend.Commit()
}

// Bury it with finality depth
ch, err := bootstrapNode.App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String())
require.NoError(t, err)
finalityDepth := ch.Config().EVM().FinalityDepth()
for i := 0; i < int(finalityDepth); i++ {
backend.Commit()
}

runTestSetup := func(reqs chan request) {
// Expect at least one report per feed from each oracle, per server
seen := make(map[[32]byte]map[credentials.StaticSizedPublicKey]struct{})
Expand Down
9 changes: 9 additions & 0 deletions core/services/ocr2/plugins/ocr2keeper/integration_21_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,15 @@ func setupNodes(t *testing.T, nodeKeys [5]ethkey.KeyV2, registry *iregistry21.IK
bootstrapNode := Node{
appBootstrap, bootstrapTransmitter, bootstrapKb,
}

// Commit blocks to finality depth to ensure LogPoller has finalized blocks to read from
ch, err := bootstrapNode.App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String())
require.NoError(t, err)
finalityDepth := ch.Config().EVM().FinalityDepth()
for i := 0; i < int(finalityDepth); i++ {
backend.Commit()
}

var (
oracles []confighelper.OracleIdentityExtra
nodes []Node
Expand Down
Loading

0 comments on commit 50870c3

Please sign in to comment.