Skip to content
Merged
Show file tree
Hide file tree
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 Jul 6, 2023
958a426
Set Block Store in Block Manager
Manav-Aggarwal Jul 7, 2023
2a1e31e
Able to get block store height changes now
Manav-Aggarwal Jul 7, 2023
388e3f1
Add block store retrieve loop
Manav-Aggarwal Jul 7, 2023
ade9fc8
Get blocks from block store with a range and print
Manav-Aggarwal Jul 7, 2023
d35eb66
Run blockStoreRetrieveLoop in fullNode OnStart
Manav-Aggarwal Jul 7, 2023
7b0742d
Add defaults for block time
Manav-Aggarwal Jul 7, 2023
4c8303b
Change back blocktime in ful node integration tests
Manav-Aggarwal Jul 7, 2023
a6a6ecd
Add hash maps for block seen before and hard confirmed blocks
Manav-Aggarwal Jul 8, 2023
2645868
Address comments
Manav-Aggarwal Jul 8, 2023
96760cf
Remove isBlockWithHashSeen in processNextDABlock
Manav-Aggarwal Jul 8, 2023
cd6e8bf
wrap isBlockSeen with mutex locks
Manav-Aggarwal Jul 8, 2023
26d18ce
try removing BlockStoreRetrieveLoop for testing
Manav-Aggarwal Jul 8, 2023
75c118d
Extract BlockManagerConfig as a helper method
Manav-Aggarwal Jul 8, 2023
dc5d4cc
write blockSync speed test
Manav-Aggarwal Jul 9, 2023
8bda7b9
add time constraints on the blockSync speed test
Manav-Aggarwal Jul 9, 2023
22948fa
Make time constraints more customized
Manav-Aggarwal Jul 9, 2023
d2f5ab0
Make tests work, no blocksync enabled
Manav-Aggarwal Jul 9, 2023
743738e
use enum to clean up code for getNodeHeight
Manav-Aggarwal Jul 9, 2023
aa0c990
add unit tests for all sources in getNodeHeight helper
Manav-Aggarwal Jul 9, 2023
43f2a81
Remove previously added mutex lock from isBlockSeen
Manav-Aggarwal Jul 9, 2023
c285f9e
add back block sync speed test
Manav-Aggarwal Jul 9, 2023
c4b2fbb
set isBlockWithHashSeen to true only when no error in trySyncNextBlock
Manav-Aggarwal Jul 10, 2023
0d0ce6a
access daHeight atomically
Manav-Aggarwal Jul 10, 2023
79b122e
add mutex locks around isBlockHashSeen
Manav-Aggarwal Jul 11, 2023
887ac35
clean up getBlocksFromStore code
Manav-Aggarwal Jul 13, 2023
839994b
Replace waitForAtLeastNBlocks call with waitForFirstBlock
Manav-Aggarwal Jul 13, 2023
30e71c6
Use switch case instead of if else
Manav-Aggarwal Jul 14, 2023
cc6d883
Use correct ctx in test
Manav-Aggarwal Jul 17, 2023
d29aa6b
defer node stops and context cancels in the newly added test
Jul 17, 2023
7ddaf22
Merge branch 'main' into manav/use_block_sync_blocks_in_manager
Manav-Aggarwal Jul 20, 2023
b38c810
change Mutex to RWMutex for fixing build error
Jul 24, 2023
1c4a15e
increase test timeout and use go-header syncer fix
Jul 24, 2023
5dbbc60
Merge remote-tracking branch 'origin/main' into manav/use_block_sync_…
Jul 24, 2023
c069438
Merge remote-tracking branch 'origin/main' into manav/use_block_sync_…
Jul 24, 2023
29b521c
update go-header
Jul 24, 2023
0e347d3
Merge remote-tracking branch 'origin/main' into manav/use_block_sync_…
Jul 26, 2023
3cabbf2
fix tests and remove annoying debug log
Jul 26, 2023
bfc3d98
add fix to ignore the non-adjacency of headers
Jul 27, 2023
d21f452
revert delay change
Jul 27, 2023
0fcff95
adding the delay back
Jul 27, 2023
d500745
temporarily disabling test
Jul 28, 2023
1721cc9
waitForAtLeastNBlocks for all nodes
Jul 28, 2023
a2c6ce2
remove useless debug
Aug 1, 2023
c0183ce
Merge remote-tracking branch 'origin/main' into manav/use_block_sync_…
Aug 1, 2023
2fa80bc
fix lazy test
Aug 1, 2023
7f3c64f
fix deadlock
Aug 1, 2023
9759086
Add documentation for infinite for loops and remove inner infinite fo…
Manav-Aggarwal Aug 7, 2023
7b556fa
Update usage of client nodes in full node integration tests
Manav-Aggarwal Aug 8, 2023
0639119
refactor block cache contents into new struct
Manav-Aggarwal Aug 8, 2023
41984ae
verify timer inside block sync speed test
Manav-Aggarwal Aug 8, 2023
17b39cb
Merge branch 'main' into manav/use_block_sync_blocks_in_manager
Manav-Aggarwal Aug 8, 2023
6b2c1a0
Remove isHardConfirmed method to fix linter
Manav-Aggarwal Aug 8, 2023
d537af3
Extract constants from channel length
Manav-Aggarwal Aug 8, 2023
634cd5a
Initialize block store inside block manager
Manav-Aggarwal Aug 8, 2023
46bb920
Assign block store in NewManager
Manav-Aggarwal Aug 9, 2023
a7c302d
Update timer in block sync speed integration test
Manav-Aggarwal Aug 9, 2023
2d975a4
Merge branch 'main' into manav/use_block_sync_blocks_in_manager
Manav-Aggarwal Aug 9, 2023
a9552cb
DO NOT MERGE: Use pending blocks to submit blocks to DA (#1089)
Manav-Aggarwal Aug 9, 2023
7b0ec9e
Use continue instead of break since removal of inner for loop
Manav-Aggarwal Aug 10, 2023
808b2da
Address some comments
Manav-Aggarwal Aug 11, 2023
cbd3c8a
Refactor how block height is referenced
Manav-Aggarwal Aug 11, 2023
456fe24
add comment explaining channel length
Manav-Aggarwal Aug 11, 2023
45620f1
Initialize mutex in block cache correctly
Manav-Aggarwal Aug 11, 2023
a7f1d67
Refactor for select loop
Manav-Aggarwal Aug 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions block/block_cache.go
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
}
Comment thread
Manav-Aggarwal marked this conversation as resolved.
Resolved

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
}
Loading