diff --git a/feeds/timeline/timeline_test.go b/feeds/timeline/timeline_test.go index a764080c..575263f2 100644 --- a/feeds/timeline/timeline_test.go +++ b/feeds/timeline/timeline_test.go @@ -169,7 +169,7 @@ func TestTimeline_CalculateLag(t *testing.T) { r.Equal(float64(1+5+9+13+15+2)/float64(6), lag) estimate, ok := blockTimeline.EstimateBlockScore() r.True(ok) - r.Equal(0.625, estimate) + r.Equal(0.0625, estimate) testDelay := time.Second blockTimeline.delay = &testDelay diff --git a/protocol/settings/chain.go b/protocol/settings/chain.go index aa454824..b56fda04 100644 --- a/protocol/settings/chain.go +++ b/protocol/settings/chain.go @@ -12,10 +12,7 @@ type ChainSettings struct { EnableTrace bool JsonRpcRateLimiting *RateLimit InspectionInterval int // in block number - - DefaultOffset int - SafeOffset int - BlockThreshold int + BlockThreshold int } // RateLimit is token bucket algorithm parameters. @@ -35,10 +32,7 @@ var allChainSettings = []ChainSettings{ EnableTrace: true, JsonRpcRateLimiting: defaultRateLimiting, InspectionInterval: 50, - - DefaultOffset: 0, - SafeOffset: 1, - BlockThreshold: 20, + BlockThreshold: 8, }, { ChainID: 10, @@ -46,10 +40,7 @@ var allChainSettings = []ChainSettings{ EnableTrace: false, JsonRpcRateLimiting: defaultRateLimiting, InspectionInterval: 100, - - DefaultOffset: 0, - SafeOffset: 5, - BlockThreshold: 100, + BlockThreshold: 8, }, { ChainID: 56, @@ -57,10 +48,7 @@ var allChainSettings = []ChainSettings{ EnableTrace: false, JsonRpcRateLimiting: defaultRateLimiting, InspectionInterval: 250, - - DefaultOffset: 0, - SafeOffset: 3, - BlockThreshold: 50, + BlockThreshold: 20, }, { ChainID: 137, @@ -68,10 +56,7 @@ var allChainSettings = []ChainSettings{ EnableTrace: false, JsonRpcRateLimiting: defaultRateLimiting, InspectionInterval: 70, - - DefaultOffset: 0, - SafeOffset: 4, - BlockThreshold: 70, + BlockThreshold: 30, }, { ChainID: 250, @@ -79,10 +64,7 @@ var allChainSettings = []ChainSettings{ EnableTrace: true, JsonRpcRateLimiting: defaultRateLimiting, InspectionInterval: 750, - - DefaultOffset: 0, - SafeOffset: 5, - BlockThreshold: 100, + BlockThreshold: 35, }, { ChainID: 42161, @@ -90,10 +72,7 @@ var allChainSettings = []ChainSettings{ EnableTrace: false, JsonRpcRateLimiting: defaultRateLimiting, InspectionInterval: 1500, - - DefaultOffset: 0, - SafeOffset: 60, - BlockThreshold: 1200, + BlockThreshold: 80, }, { ChainID: 43114, @@ -101,29 +80,10 @@ var allChainSettings = []ChainSettings{ EnableTrace: false, JsonRpcRateLimiting: defaultRateLimiting, InspectionInterval: 350, - - DefaultOffset: 0, - SafeOffset: 4, - BlockThreshold: 70, + BlockThreshold: 30, }, } -// ValidateChainSettings validates chain settings. -func ValidateChainSettings(chainID int) bool { - settings := GetChainSettings(chainID) - if settings.SafeOffset < 1 { - return false - } - if settings.BlockThreshold <= 0 { - return false - } - safeOffsetRate := float64(settings.SafeOffset) / float64(settings.BlockThreshold) - if safeOffsetRate < 0.05 || safeOffsetRate > 0.1 { - return false - } - return true -} - // GetChainSettings returns the settings for the chain. func GetChainSettings(chainID int) *ChainSettings { for _, settings := range allChainSettings { @@ -136,14 +96,6 @@ func GetChainSettings(chainID int) *ChainSettings { ChainID: chainID, JsonRpcRateLimiting: defaultRateLimiting, InspectionInterval: 50, // arbitrary value - not reliable - - DefaultOffset: 0, - SafeOffset: 2, - BlockThreshold: 10, + BlockThreshold: 10, } } - -// GetDefaultBlockOffset returns the block offset for a chain. -func GetBlockOffset(chainID int) int { - return GetChainSettings(chainID).DefaultOffset -} diff --git a/protocol/settings/chain_test.go b/protocol/settings/chain_test.go deleted file mode 100644 index 134d4983..00000000 --- a/protocol/settings/chain_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package settings - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestValidateChainSettings(t *testing.T) { - for _, chainSettings := range allChainSettings { - t.Run(chainSettings.Name, func(t *testing.T) { - r := require.New(t) - - r.True(ValidateChainSettings(chainSettings.ChainID)) - }) - } -}