Repository navigation
Use Blocks from Block Sync in Block Manager #1056
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
Merged
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
241841e
add getBlockStore method
Manav-Aggarwal 958a426
Set Block Store in Block Manager
Manav-Aggarwal 2a1e31e
Able to get block store height changes now
Manav-Aggarwal 388e3f1
Add block store retrieve loop
Manav-Aggarwal ade9fc8
Get blocks from block store with a range and print
Manav-Aggarwal d35eb66
Run blockStoreRetrieveLoop in fullNode OnStart
Manav-Aggarwal 7b0742d
Add defaults for block time
Manav-Aggarwal 4c8303b
Change back blocktime in ful node integration tests
Manav-Aggarwal a6a6ecd
Add hash maps for block seen before and hard confirmed blocks
Manav-Aggarwal 2645868
Address comments
Manav-Aggarwal 96760cf
Remove isBlockWithHashSeen in processNextDABlock
Manav-Aggarwal cd6e8bf
wrap isBlockSeen with mutex locks
Manav-Aggarwal 26d18ce
try removing BlockStoreRetrieveLoop for testing
Manav-Aggarwal 75c118d
Extract BlockManagerConfig as a helper method
Manav-Aggarwal dc5d4cc
write blockSync speed test
Manav-Aggarwal 8bda7b9
add time constraints on the blockSync speed test
Manav-Aggarwal 22948fa
Make time constraints more customized
Manav-Aggarwal d2f5ab0
Make tests work, no blocksync enabled
Manav-Aggarwal 743738e
use enum to clean up code for getNodeHeight
Manav-Aggarwal aa0c990
add unit tests for all sources in getNodeHeight helper
Manav-Aggarwal 43f2a81
Remove previously added mutex lock from isBlockSeen
Manav-Aggarwal c285f9e
add back block sync speed test
Manav-Aggarwal c4b2fbb
set isBlockWithHashSeen to true only when no error in trySyncNextBlock
Manav-Aggarwal 0d0ce6a
access daHeight atomically
Manav-Aggarwal 79b122e
add mutex locks around isBlockHashSeen
Manav-Aggarwal 887ac35
clean up getBlocksFromStore code
Manav-Aggarwal 839994b
Replace waitForAtLeastNBlocks call with waitForFirstBlock
Manav-Aggarwal 30e71c6
Use switch case instead of if else
Manav-Aggarwal cc6d883
Use correct ctx in test
Manav-Aggarwal d29aa6b
defer node stops and context cancels in the newly added test
7ddaf22
Merge branch 'main' into manav/use_block_sync_blocks_in_manager
Manav-Aggarwal b38c810
change Mutex to RWMutex for fixing build error
1c4a15e
increase test timeout and use go-header syncer fix
5dbbc60
Merge remote-tracking branch 'origin/main' into manav/use_block_sync_…
c069438
Merge remote-tracking branch 'origin/main' into manav/use_block_sync_…
29b521c
update go-header
0e347d3
Merge remote-tracking branch 'origin/main' into manav/use_block_sync_…
3cabbf2
fix tests and remove annoying debug log
bfc3d98
add fix to ignore the non-adjacency of headers
d21f452
revert delay change
0fcff95
adding the delay back
d500745
temporarily disabling test
1721cc9
waitForAtLeastNBlocks for all nodes
a2c6ce2
remove useless debug
c0183ce
Merge remote-tracking branch 'origin/main' into manav/use_block_sync_…
2fa80bc
fix lazy test
7f3c64f
fix deadlock
9759086
Add documentation for infinite for loops and remove inner infinite fo…
Manav-Aggarwal 7b556fa
Update usage of client nodes in full node integration tests
Manav-Aggarwal 0639119
refactor block cache contents into new struct
Manav-Aggarwal 41984ae
verify timer inside block sync speed test
Manav-Aggarwal 17b39cb
Merge branch 'main' into manav/use_block_sync_blocks_in_manager
Manav-Aggarwal 6b2c1a0
Remove isHardConfirmed method to fix linter
Manav-Aggarwal d537af3
Extract constants from channel length
Manav-Aggarwal 634cd5a
Initialize block store inside block manager
Manav-Aggarwal 46bb920
Assign block store in NewManager
Manav-Aggarwal a7c302d
Update timer in block sync speed integration test
Manav-Aggarwal 2d975a4
Merge branch 'main' into manav/use_block_sync_blocks_in_manager
Manav-Aggarwal a9552cb
DO NOT MERGE: Use pending blocks to submit blocks to DA (#1089)
Manav-Aggarwal 7b0ec9e
Use continue instead of break since removal of inner for loop
Manav-Aggarwal 808b2da
Address some comments
Manav-Aggarwal cbd3c8a
Refactor how block height is referenced
Manav-Aggarwal 456fe24
add comment explaining channel length
Manav-Aggarwal 45620f1
Initialize mutex in block cache correctly
Manav-Aggarwal a7f1d67
Refactor for select loop
Manav-Aggarwal 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package block | ||
|
|
||
| import ( | ||
| "sync" | ||
|
|
||
| "github.com/rollkit/rollkit/types" | ||
| ) | ||
|
|
||
| type BlockCache struct { | ||
| blocks map[uint64]*types.Block | ||
| hashes map[string]bool | ||
| hardConfirmations map[string]bool | ||
| mtx *sync.RWMutex | ||
| } | ||
|
|
||
| func NewBlockCache() *BlockCache { | ||
| return &BlockCache{ | ||
| blocks: make(map[uint64]*types.Block), | ||
| hashes: make(map[string]bool), | ||
| hardConfirmations: make(map[string]bool), | ||
| mtx: new(sync.RWMutex), | ||
| } | ||
| } | ||
|
|
||
| func (bc *BlockCache) getBlock(height uint64) (*types.Block, bool) { | ||
| bc.mtx.Lock() | ||
| defer bc.mtx.Unlock() | ||
| block, ok := bc.blocks[height] | ||
| return block, ok | ||
| } | ||
|
|
||
| func (bc *BlockCache) setBlock(height uint64, block *types.Block) { | ||
| bc.mtx.Lock() | ||
| defer bc.mtx.Unlock() | ||
| bc.blocks[height] = block | ||
| } | ||
|
|
||
| func (bc *BlockCache) deleteBlock(height uint64) { | ||
| bc.mtx.Lock() | ||
| defer bc.mtx.Unlock() | ||
| delete(bc.blocks, height) | ||
| } | ||
|
|
||
| func (bc *BlockCache) isSeen(hash string) bool { | ||
| bc.mtx.Lock() | ||
| defer bc.mtx.Unlock() | ||
| return bc.hashes[hash] | ||
| } | ||
|
|
||
| func (bc *BlockCache) setSeen(hash string) { | ||
| bc.mtx.Lock() | ||
| defer bc.mtx.Unlock() | ||
| bc.hashes[hash] = true | ||
| } | ||
|
|
||
| func (bc *BlockCache) setHardConfirmed(hash string) { | ||
| bc.mtx.Lock() | ||
| defer bc.mtx.Unlock() | ||
| bc.hardConfirmations[hash] = true | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.