-
-
Notifications
You must be signed in to change notification settings - Fork 410
feat: allow block import after NUMBER_OF_COLUMNS / 2 #8408
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
Open
wemeetagain
wants to merge
188
commits into
unstable
Choose a base branch
from
cayman/delay-reconstruction
base: unstable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 183 commits
Commits
Show all changes
188 commits
Select commit
Hold shift + click to select a range
ec4635c
feat: add blocksAndData testing utils
matthewkeil 337d348
feat: add SeenBlockInputCache.getByColumn
matthewkeil 004860a
feat: add downloadByRange.ts
matthewkeil b74691b
test: add tests for getByColumn and downloadByRange. need to get them…
matthewkeil 8ef928b
wip: add roughed out downloadByRoot
matthewkeil 6d374c9
Merge branch 'unstable' into mkeil/refactor-block-input-on-unstable
wemeetagain 1b6046d
chore: get src building
wemeetagain 0be6543
chore: fix some test build issues
wemeetagain d7b5b66
chore: update chain processing
wemeetagain ec8727f
Revert "chore: fix some test build issues"
matthewkeil 3b04598
chore: fix some build issues (reverts some of the details from previo…
matthewkeil a96efbf
Merge branch 'unstable' into mkeil/refactor-block-input-on-unstable
wemeetagain c1bf66b
chore: fix up src/api
wemeetagain 17846cb
chore: halfway thru gossip handlers
wemeetagain 5bde098
fix: add fulu case to SeenBlockInput.getByBlock
matthewkeil 4d97aaf
chore: finish updating gossip handlers
wemeetagain 3fe3851
chore: remove stray function
wemeetagain 60c66fe
feat: update how range sync Batch works
matthewkeil d664ce2
Merge branch 'mkeil/refactor-block-input-on-unstable' of github.com:C…
matthewkeil c6999c5
fix: logic errors in batch.getRequests
matthewkeil 1448520
feat: update chain and range to use downloadByRoot and updated batch
matthewkeil 6470907
feat: add throwOnDuplicateAdd to IBlockInput.addBlock
matthewkeil 32adcd2
feat: add throwOnDuplicate option for blobs and columns
matthewkeil 2a7b681
feat: rough out byRange caching
matthewkeil dfc11d4
refactor: remove beaconBlockMaybeBlobsByRange
matthewkeil aed92ef
refactor: remove beaconBlockMaybeBlobsByRoot
matthewkeil e3a093b
feat: switch "unknown*" event types from Network to Chain events
matthewkeil 3358916
fix: type issue in SeenBlockInput
matthewkeil b116bfb
refactor: change name from UnknownBlock and options to BlockInputSync
matthewkeil f387cac
feat: add source to events data
matthewkeil 021523c
fix: convert to new IBlockInput
matthewkeil 5a450aa
fix: convert some BlockInput to IBlockInput for type safety in sync
matthewkeil 97a5e6a
fix: remove old types that were used by UnknownBlock and move to new …
matthewkeil 66672ef
fix: bug in Batch (add blocks back to state)
matthewkeil 6b53b8e
fix: by range types to allow for batches that do not need blocks pulled
matthewkeil 738e1fc
wip: start to update BlockInputSync and pendingBlocksTree
matthewkeil 983cff0
refactor: rename unknownBlock.ts -> blockInputSync.ts
matthewkeil 9380308
wip: more fixing up block input sync
wemeetagain ded5c6a
Merge branch 'unstable' into mkeil/refactor-block-input-on-unstable
matthewkeil e48d21b
wip: get BlockInputSync class cleaned up after merging tuyen PR
matthewkeil e675be7
fix: types for UnknownBlockPeerBalancer
matthewkeil 86aba63
chore: fix last build errors
wemeetagain 821dd39
chore: move blockInput.ts to unknownBlock.ts
wemeetagain 0f1b2a3
chore: clean up getUnknownAndAncestorBlocks
wemeetagain 1c49e12
chore: fix getUnknownAndAncestorBlocks
wemeetagain edd7dc2
chore: another fix to getUnknownAndAncestorBlocks
wemeetagain bf70001
chore: fix up downloadBlock and processBlock
wemeetagain ed42752
chore: remove unused code in unknownBlock.ts
wemeetagain be7e3a1
chore: use sampledColumns vs sampledGroups
wemeetagain 41b6193
Merge branch 'unstable' into mkeil/refactor-block-input-on-unstable
wemeetagain b25ab64
feat: build out downloadByRoot
matthewkeil 461f372
Merge branch 'mkeil/refactor-block-input-on-unstable' of github.com:C…
matthewkeil ab5b4d6
refactor: rename download to fetch
matthewkeil 612af54
feat: update BlockInputCache to pass in blockRootHex instead of calcu…
matthewkeil 43ec65f
fix: add caching to downloadByRoot and pass in executionEngine
matthewkeil dd819bc
chore: fix some of check-types
wemeetagain 8a48222
chore: delete test
wemeetagain a1e3351
chore: remove old test files
wemeetagain 511d9f6
feat: modify ColumnMeta to support getBlobsV2
matthewkeil 57a7699
feat: make logger public on network
matthewkeil a7c69e5
feat: make getCellsAndProofs async
matthewkeil 7265027
feat: add getBlobsV1 and V2 to downloadByRoot
matthewkeil 4c248a3
test: rough out unit tests for downloadByRoot
matthewkeil cbda219
fix: debug blocksAndData test utils
matthewkeil 93222b5
chore: fix some check-type errors
wemeetagain 6603a16
test: partial testing of downloadByRoot with code changes from bugs f…
matthewkeil bff41ab
fix: rename dataAvailabilityStatus
matthewkeil 68d5e83
Merge branch 'mkeil/refactor-block-input-on-unstable' of github.com:C…
matthewkeil 0da2fc1
fix: type errors
matthewkeil d45f3e4
chore: lint
matthewkeil fa83ae1
test: rough out MockBlockInput for testing
matthewkeil c3adcf8
chore: fix check-types
matthewkeil efcdaa2
fix: update pendingBlocksTree.test for new BlockInput
matthewkeil 1087c82
fix: check-types in blocksAndData test util
matthewkeil 35883ba
chore: lint
matthewkeil 8576a2b
test: unit testing downloadByRoot
matthewkeil 9cf380b
test: testing fetchAndValidateBlobs
matthewkeil 4b7a244
test: fetchAndValidateBlobs
matthewkeil 2fa46f1
test: fetchAndValidateBlobs
matthewkeil 29bc78b
test: fetchAndValidateColumns
matthewkeil 46cfe6f
fix: clean up unused comments
matthewkeil 7247a42
chore: fix up download by range
wemeetagain 56742b1
chore: touch up batch states
wemeetagain 4ba34a7
chore: more work on by range
wemeetagain d440a6a
chore: temporarily disable extra blobs check
wemeetagain 8ac7c80
chore: update validate blobs input
wemeetagain 92e97c8
chore: update vlaidate blobs input
wemeetagain 836186e
fix: address spacing for @nflaig
matthewkeil 11582b3
chore: fix some bugs
wemeetagain cd68138
chore: dedupe blobsRequestBlocks
wemeetagain 6073afc
chore: improve log
wemeetagain fbe6919
chore: fix typo
wemeetagain d501655
chore: fix batch update when there are skip slots
wemeetagain 218d997
chore: wip fix blob/column reqresp validation
wemeetagain 97b9426
fix: wait for data before writing to db (#8291)
twoeths e66e36a
docs: add checklist docstring to downloadByRange
matthewkeil 0cfc9e4
chore: refactor sidecar validation in by-range
wemeetagain 01e6174
chore: fix column proof verification
wemeetagain 1b7e37a
chore: fix up columns block input
wemeetagain 6d225a2
chore: remove unnecessary sidecar validation step
wemeetagain adbcde8
Merge branch 'unstable' into mkeil/refactor-block-input-on-unstable
matthewkeil f5b2f68
chore: remove unused validation fn, consolidate validation fn usage
wemeetagain 43590a7
feat: downscore peers for sending range batches on wrong chain and us…
matthewkeil 136e076
fix: put sorting of block in batch.downloadingSuccess
matthewkeil 805a201
chore: simplify validation (use same validation functions everywhere)
wemeetagain 8a9c8df
chore: fix an e2e test
wemeetagain d3000a8
chore: fix unit test
wemeetagain 1097736
chore: fix another unit test
wemeetagain e191662
chore: fix more tests
wemeetagain 1a43035
test: partial update of batch.test.ts
matthewkeil 1b1134a
Merge branch 'mkeil/refactor-block-input-on-unstable' of github.com:C…
matthewkeil fbc7fcb
chore: fix more test
wemeetagain b9e4a62
feat: refactor downloadByRange.ts
matthewkeil 604f0ca
feat: add AI analysis and unit test cases for downloadByRange
matthewkeil de11b44
fix: sort ascending
matthewkeil 4d2ad9b
chore: downscore peers appropriately
wemeetagain 89b9c7c
fix: debug test/utils/blocksAndData.ts
matthewkeil 5ce5bb7
test: unit test getBlocksForDataValidation
matthewkeil ff687e3
chore: fix check-types
matthewkeil 1fe1fce
chore: fix more tests
wemeetagain eb6379f
Merge branch 'unstable' into mkeil/refactor-block-input-on-unstable
wemeetagain e2cf218
chore: lint
wemeetagain 31407b0
chore: more cleanup
wemeetagain f30d9a2
chore: fix lint
wemeetagain 3943b36
chore: add getBlobsV2 call to gossip block handler
wemeetagain be99499
chore: cleanup getDataColumnSidecarsFromExecution
wemeetagain 45baecd
chore: apply #8282-ish solution
wemeetagain 09f0044
chore: fetch data columns from execution upon data column sidecar
wemeetagain cc933e5
fix: throw on duplicate add (#8326)
twoeths 9548fd5
fix: correct validateBlockDataColumnSidecars result mapping (#8328)
twoeths 20292ec
fix: correct leveldb metrics (#8335)
twoeths 49a3624
fix: handle full data BlockInput in downloadByRoot (#8339)
twoeths e338b69
fix: request columns by peer custodied columns (#8330)
twoeths 4caea70
fix: remove getBlobs use during by root syncing (#8341)
wemeetagain 03dc499
fix: allow for sparse blobs in blob validation (#8342)
wemeetagain 92e477d
fix: new error code NOT_ENOUGH_SIDECARS_RECEIVED (#8351)
twoeths aabe8be
fix: resolve data promise for BlockInputPreData (#8299)
twoeths 6351259
Merge branch 'unstable' into mkeil/refactor-block-input-on-unstable
matthewkeil 10dbede
docs: add TODO
matthewkeil 423c77a
feat: only cache gossip block after validation
matthewkeil 588c237
docs: update comments and add TODOs
matthewkeil 1192618
refactor: dont create separate variable, use object prop
matthewkeil e257931
docs: add TODO
matthewkeil 633d137
refactor: imports
matthewkeil 5c3d888
fix: remove duplicate BlockInputCache
matthewkeil 234c26f
feat: track DownloadByRoot errors on new metrics (#8352)
twoeths e9ab7a9
Merge branch 'unstable' into mkeil/refactor-block-input-on-unstable
wemeetagain c1bea58
Merge branch 'mkeil/refactor-block-input-on-unstable' of github.com:C…
matthewkeil 1737333
fix: build error
matthewkeil c884573
fix: build error
matthewkeil 855bdbf
fix: prevent faulty by range EXTRA_COLUMNS error
wemeetagain 143d184
feat: reimplement PR#7940 for column reconstruction
matthewkeil d482016
chore: lint and check-types
matthewkeil d119773
Merge branch 'mkeil/refactor-block-input-on-unstable' of github.com:C…
matthewkeil 3b97226
feat: dont check for listener twice
matthewkeil cfe8ba2
feat: getLogMeta to print slot first
matthewkeil 4804855
fix: dont destructure logMeta in debug call
matthewkeil 02696de
fix: update log comment
matthewkeil 92a992d
docs: add comment
matthewkeil 7827f14
fix: replace extra validation check error with log statement
matthewkeil 4f7d53c
feat: prune BlockInputs for ByRange
matthewkeil 84c5895
feat: prune BlockInputs for ByRoot
matthewkeil 2735565
Merge branch 'mkeil/refactor-block-input-on-unstable' of github.com:C…
matthewkeil 07a214c
fix: build error. I love you TS!!!.... and i hate you but I love you!!!
matthewkeil d46bf59
feat: log number of pruned BlockInputs
matthewkeil 1a7b1e4
chore: fix check-types
matthewkeil ee00704
fix: add blocks to all BatchState (#8369)
twoeths 1d1fbe1
feat: track downloadByRange errors in metrics (#8372)
twoeths 71269d3
fix: track getBlobsV2 calls via GetBlobsTracker (#8381)
wemeetagain 369a160
feat: add imported columns by source metric (#8380)
wemeetagain 83fcfec
fix: add valid request window check for each fork (#8379)
nazarhussain 70d969e
feat: add gossip data column sidecar verification skip (#8382)
wemeetagain 0dc23bf
feat: add ColumnReconstructionTracker (#8383)
wemeetagain dbe9b74
fix: wait until next event loop for getBlobsV2 (#8384)
wemeetagain f8e36f5
feat: relaxed data column response handler (#8387)
twoeths 4e198eb
chore: fix unit tests (#8392)
wemeetagain b041e32
fix: pass testCaseName to spec testFunction to allow for case specifi…
matthewkeil d2b90db
fix: add default custody to test for unavailable peerDas data
matthewkeil d090d54
docs: add not to spec test about test case for future us to know what…
matthewkeil 14a8ae3
docs: add note to spec test about test case for future us to know wha…
matthewkeil b829484
fix: e2e tests for blockinput refactor branch (#8394)
twoeths a6dd9e7
chore: review block input refactor (#8398)
nflaig b982584
feat: allow block import after NUMBER_OF_COLUMNS / 2
wemeetagain 42042c1
Update packages/beacon-node/src/chain/blocks/blockInput/blockInput.ts
wemeetagain a1af740
chore: use params to configure delay
wemeetagain 7ffe6b0
Update packages/beacon-node/src/network/processor/gossipHandlers.ts
wemeetagain 22ee657
chore: add additional promise to BlockInputColumns
wemeetagain f7f36e6
chore: no eager block import
wemeetagain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/beacon-node/src/chain/ColumnReconstructionTracker.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import {Logger, sleep} from "@lodestar/utils"; | ||
| import {ChainEventEmitter} from "./emitter.js"; | ||
| import {Metrics} from "../metrics/metrics.js"; | ||
| import {ChainForkConfig} from "@lodestar/config"; | ||
| import {BlockInputColumns} from "./blocks/blockInput/index.js"; | ||
| import {recoverDataColumnSidecars} from "../util/dataColumns.js"; | ||
|
|
||
| /** | ||
| * Maximum added delay before attempting reconstruction | ||
| * | ||
| * From the spec: | ||
| * If delaying reconstruction, nodes may use a random delay in order to desynchronize reconstruction among nodes, thus reducing overall CPU load. | ||
| */ | ||
| const RECONSTRUCTION_RANDOM_DELAY_MAX_MS = 200; | ||
|
|
||
| export type ColumnReconstructionTrackerInit = { | ||
| logger: Logger; | ||
| emitter: ChainEventEmitter; | ||
| metrics: Metrics | null; | ||
| config: ChainForkConfig; | ||
| }; | ||
|
|
||
| /** | ||
| * Tracks column reconstruction attempts to avoid duplicate and multiple in-flight calls | ||
| */ | ||
| export class ColumnReconstructionTracker { | ||
| logger: Logger; | ||
| emitter: ChainEventEmitter; | ||
| metrics: Metrics | null; | ||
| config: ChainForkConfig; | ||
|
|
||
| /** | ||
| * Track last attempted block root | ||
| * | ||
| * This is sufficient to avoid duplicate calls since we only call this | ||
| * function when we see a new data column sidecar from gossip. | ||
| */ | ||
| lastBlockRootHex: string | null = null; | ||
| /** Track if a reconstruction attempt is in-flight */ | ||
| running = false; | ||
|
|
||
| constructor(init: ColumnReconstructionTrackerInit) { | ||
| this.logger = init.logger; | ||
| this.emitter = init.emitter; | ||
| this.metrics = init.metrics; | ||
| this.config = init.config; | ||
| } | ||
|
|
||
| triggerColumnReconstruction(delay: number, blockInput: BlockInputColumns): void { | ||
| if (this.running) { | ||
| return; | ||
| } | ||
|
|
||
| if (this.lastBlockRootHex === blockInput.blockRootHex) { | ||
| return; | ||
| } | ||
|
|
||
| // We don't care about the outcome of this call, | ||
| // just that it has been triggered for this block root. | ||
| this.running = true; | ||
| this.lastBlockRootHex = blockInput.blockRootHex; | ||
| sleep(delay + Math.random() * RECONSTRUCTION_RANDOM_DELAY_MAX_MS).then(() => { | ||
| recoverDataColumnSidecars(blockInput, this.emitter, this.metrics).finally(() => { | ||
| this.running = false; | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import {Logger} from "@lodestar/utils"; | ||
| import {IExecutionEngine} from "../execution/index.js"; | ||
| import {ChainEventEmitter} from "./emitter.js"; | ||
| import {Metrics} from "../metrics/metrics.js"; | ||
| import {ChainForkConfig} from "@lodestar/config"; | ||
| import {IBlockInput} from "./blocks/blockInput/index.js"; | ||
| import {getDataColumnSidecarsFromExecution} from "../util/execution.js"; | ||
| import {callInNextEventLoop} from "../util/eventLoop.js"; | ||
|
|
||
| export type GetBlobsTrackerInit = { | ||
| logger: Logger; | ||
| executionEngine: IExecutionEngine; | ||
| emitter: ChainEventEmitter; | ||
| metrics: Metrics | null; | ||
| config: ChainForkConfig; | ||
| }; | ||
|
|
||
| /** | ||
| * Tracks getBlobsV2 calls to the execution engine to avoid duplicate and multiple in-flight calls | ||
| */ | ||
| export class GetBlobsTracker { | ||
| logger: Logger; | ||
| executionEngine: IExecutionEngine; | ||
| emitter: ChainEventEmitter; | ||
| metrics: Metrics | null; | ||
| config: ChainForkConfig; | ||
|
|
||
| /** | ||
| * Track last attempted block root | ||
| * | ||
| * This is sufficient to avoid duplicate calls since we only call this | ||
| * function when we see a new block or data column sidecar from gossip. | ||
| */ | ||
| lastBlockRootHex: string | null = null; | ||
| /** Track if a getBlobsV2 call is in-flight */ | ||
| running = false; | ||
| // Preallocate buffers for getBlobsV2 RPC calls | ||
| // See https://github.com/ChainSafe/lodestar/pull/8282 for context | ||
| blobAndProofBuffers: Uint8Array[] = []; | ||
|
|
||
| constructor(init: GetBlobsTrackerInit) { | ||
| this.logger = init.logger; | ||
| this.executionEngine = init.executionEngine; | ||
| this.emitter = init.emitter; | ||
| this.metrics = init.metrics; | ||
| this.config = init.config; | ||
| } | ||
|
|
||
| triggerGetBlobs(blockInput: IBlockInput): void { | ||
| if (this.running) { | ||
| return; | ||
| } | ||
|
|
||
| if (this.lastBlockRootHex === blockInput.blockRootHex) { | ||
| return; | ||
| } | ||
|
|
||
| // We don't care about the outcome of this call, | ||
| // just that it has been triggered for this block root. | ||
| this.running = true; | ||
| this.lastBlockRootHex = blockInput.blockRootHex; | ||
| callInNextEventLoop(() => { | ||
| getDataColumnSidecarsFromExecution( | ||
| this.config, | ||
| this.executionEngine, | ||
| this.emitter, | ||
| blockInput, | ||
| this.metrics, | ||
| this.blobAndProofBuffers | ||
| ).finally(() => { | ||
| this.running = false; | ||
| }); | ||
| }); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of having a mechanism to delay more based on number of columns arrived instead of a random()
similar to lighthouse
may want to revisit this later