sane values for consensus_max_block_lag

This commit is contained in:
Felipe Andrade 2023-05-26 19:15:09 -07:00
parent 3cdac70a0d
commit 1b40d776a6
5 changed files with 21 additions and 10 deletions

@ -220,7 +220,7 @@ func NewConsensusPoller(bg *BackendGroup, opts ...ConsensusOpt) *ConsensusPoller
banPeriod: 5 * time.Minute,
maxUpdateThreshold: 30 * time.Second,
maxBlockLag: 50,
maxBlockLag: 8, // quarter of an epoch, 8*12 seconds = 96 seconds ~ 1.6 minutes
minPeerCount: 3,
}

@ -93,8 +93,8 @@ backends = ["infura"]
# consensus_ban_period = "1m"
# Maximum delay for update the backend, default 30s
# consensus_max_update_threshold = "20s"
# Maximum block lag, default 50
# consensus_max_block_lag = 10
# Maximum block lag, default 8
# consensus_max_block_lag = 16
# Minimum peer count, default 3
# consensus_min_peer_count = 4

@ -175,12 +175,12 @@ func TestConsensus(t *testing.T) {
t.Run("prevent using a backend lagging behind", func(t *testing.T) {
reset()
// node2 is 51 blocks ahead of node1 (0x101 + 51 = 0x134)
overrideBlock("node2", "latest", "0x134")
// node2 is 8+1 blocks ahead of node1 (0x101 + 8+1 = 0x10a)
overrideBlock("node2", "latest", "0x10a")
update()
// since we ignored node1, the consensus should be at 0x133
require.Equal(t, "0x134", bg.Consensus.GetLatestBlockNumber().String())
// since we ignored node1, the consensus should be at 0x10a
require.Equal(t, "0x10a", bg.Consensus.GetLatestBlockNumber().String())
require.Equal(t, "0xe1", bg.Consensus.GetSafeBlockNumber().String())
require.Equal(t, "0xc1", bg.Consensus.GetFinalizedBlockNumber().String())
@ -192,8 +192,8 @@ func TestConsensus(t *testing.T) {
t.Run("prevent using a backend lagging behind - one before limit", func(t *testing.T) {
reset()
// node2 is 50 blocks ahead of node1 (0x101 + 50 = 0x133)
overrideBlock("node2", "latest", "0x133")
// node2 is 8 blocks ahead of node1 (0x101 + 8 = 0x109)
overrideBlock("node2", "latest", "0x109")
update()
// both nodes are in consensus with the lowest block

@ -18,7 +18,7 @@ consensus_aware = true
consensus_handler = "noop" # allow more control over the consensus poller for tests
consensus_ban_period = "1m"
consensus_max_update_threshold = "2m"
consensus_max_block_lag = 50
consensus_max_block_lag = 8
consensus_min_peer_count = 4
[rpc_method_mappings]

@ -63,6 +63,17 @@
"number": "0x103"
}
}
- method: eth_getBlockByNumber
block: 0x10a
response: >
{
"jsonrpc": "2.0",
"id": 67,
"result": {
"hash": "hash_0x10a",
"number": "0x10a"
}
}
- method: eth_getBlockByNumber
block: 0x132
response: >