Skip to content

Commit

Permalink
Working on adding new data field into the work object header
Browse files Browse the repository at this point in the history
  • Loading branch information
gameofpointers authored and jdowning100 committed Dec 16, 2024
1 parent 1124fdc commit d10b69b
Show file tree
Hide file tree
Showing 8 changed files with 353 additions and 300 deletions.
18 changes: 9 additions & 9 deletions core/rawdb/accessors_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestHeaderStorage(t *testing.T) {
woBody := types.EmptyWorkObjectBody()
woBody.SetHeader(header)

woHeader := types.NewWorkObjectHeader(header.Hash(), common.Hash{1}, big.NewInt(1), big.NewInt(30000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 1, common.LocationFromAddressBytes([]byte{0x01, 0x01}), common.BytesToAddress([]byte{1}, common.Location{0, 0}))
woHeader := types.NewWorkObjectHeader(header.Hash(), common.Hash{1}, big.NewInt(1), big.NewInt(30000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 1, common.LocationFromAddressBytes([]byte{0x01, 0x01}), common.BytesToAddress([]byte{1}, common.Location{0, 0}), []byte{0, 1, 2, 3})

wo := types.NewWorkObject(woHeader, woBody, nil)

Expand Down Expand Up @@ -190,7 +190,7 @@ func TestPbCacheStorage(t *testing.T) {
woBody := types.EmptyWorkObjectBody()
woBody.SetHeader(types.EmptyHeader())

woHeader := types.NewWorkObjectHeader(types.EmptyRootHash, types.EmptyRootHash, big.NewInt(11), big.NewInt(30000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 1, common.LocationFromAddressBytes([]byte{0x01, 0x01}), common.BytesToAddress([]byte{1}, common.Location{0, 0}))
woHeader := types.NewWorkObjectHeader(types.EmptyRootHash, types.EmptyRootHash, big.NewInt(11), big.NewInt(30000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 1, common.LocationFromAddressBytes([]byte{0x01, 0x01}), common.BytesToAddress([]byte{1}, common.Location{0, 0}), []byte{0, 1, 2, 3})
wo := types.NewWorkObject(woHeader, woBody, nil)
WritePbCacheBody(db, common.Hash{1}, wo)

Expand Down Expand Up @@ -320,7 +320,7 @@ func TestBlockHashesIterator(t *testing.T) {
blockHeader := types.EmptyHeader()
blockBody := types.EmptyWorkObjectBody()
blockBody.SetHeader(blockHeader)
blockWoHeader := types.NewWorkObjectHeader(blockHeader.Hash(), types.EmptyHash, big.NewInt(int64(i+1)), big.NewInt(3000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 2, common.Location{0, byte(j)}, common.BytesToAddress([]byte{1}, common.Location{0, byte(j)}))
blockWoHeader := types.NewWorkObjectHeader(blockHeader.Hash(), types.EmptyHash, big.NewInt(int64(i+1)), big.NewInt(3000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 2, common.Location{0, byte(j)}, common.BytesToAddress([]byte{1}, common.Location{0, byte(j)}), []byte{0, 1, 2, 3})
block := types.NewWorkObject(blockWoHeader, blockBody, nil)
WriteWorkObject(db, block.Hash(), block, types.BlockObject, common.ZONE_CTX)
hashes[i][block.Hash()] = true
Expand All @@ -345,30 +345,30 @@ func TestCommonAncestor(t *testing.T) {
regionHeader.SetNumber(big.NewInt(1), common.REGION_CTX)
regionBody := types.EmptyWorkObjectBody()
regionBody.SetHeader(regionHeader)
regionWoHeader := types.NewWorkObjectHeader(regionHeader.Hash(), types.EmptyRootHash, big.NewInt(1), big.NewInt(3000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 1, common.Location{0}, common.BytesToAddress([]byte{0}, common.Location{0, 0}))
regionWoHeader := types.NewWorkObjectHeader(regionHeader.Hash(), types.EmptyRootHash, big.NewInt(1), big.NewInt(3000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 1, common.Location{0}, common.BytesToAddress([]byte{0}, common.Location{0, 0}), []byte{0, 1, 2, 3})
regionBlock := types.NewWorkObject(regionWoHeader, regionBody, nil)
WriteWorkObject(db, regionBlock.Hash(), regionBlock, types.BlockObject, common.REGION_CTX)

//Write one block on zone 0 context
zone0Header := types.EmptyHeader()
zone0Body := types.EmptyWorkObjectBody()
zone0Body.SetHeader(zone0Header)
zone0WoHeader := types.NewWorkObjectHeader(zone0Header.Hash(), regionBlock.Hash(), big.NewInt(2), big.NewInt(3000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 2, common.Location{0, 0}, common.BytesToAddress([]byte{0}, common.Location{0, 0}))
zone0WoHeader := types.NewWorkObjectHeader(zone0Header.Hash(), regionBlock.Hash(), big.NewInt(2), big.NewInt(3000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 2, common.Location{0, 0}, common.BytesToAddress([]byte{0}, common.Location{0, 0}), []byte{0, 1, 2, 3})
zone0Block := types.NewWorkObject(zone0WoHeader, zone0Body, nil)
WriteWorkObject(db, zone0Block.Hash(), zone0Block, types.BlockObject, common.ZONE_CTX)

//Write two blocks on zone 1 context
zone1Header1 := types.EmptyHeader()
zone1Body1 := types.EmptyWorkObjectBody()
zone1Body1.SetHeader(zone1Header1)
zone1WoHeader1 := types.NewWorkObjectHeader(zone1Header1.Hash(), regionBlock.Hash(), big.NewInt(2), big.NewInt(3000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 2, common.Location{0, 1}, common.BytesToAddress([]byte{0}, common.Location{0, 1}))
zone1WoHeader1 := types.NewWorkObjectHeader(zone1Header1.Hash(), regionBlock.Hash(), big.NewInt(2), big.NewInt(3000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 2, common.Location{0, 1}, common.BytesToAddress([]byte{0}, common.Location{0, 1}), []byte{0, 1, 2, 3})
zone1Block1 := types.NewWorkObject(zone1WoHeader1, zone1Body1, nil)
WriteWorkObject(db, zone1Block1.Hash(), zone1Block1, types.BlockObject, common.ZONE_CTX)

zone1Header2 := types.EmptyHeader()
zone1Body2 := types.EmptyWorkObjectBody()
zone1Body2.SetHeader(zone1Header2)
zone1WoHeader2 := types.NewWorkObjectHeader(zone1Header2.Hash(), zone1Block1.Hash(), big.NewInt(3), big.NewInt(3000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 3, common.Location{0, 1}, common.BytesToAddress([]byte{0}, common.Location{0, 1}))
zone1WoHeader2 := types.NewWorkObjectHeader(zone1Header2.Hash(), zone1Block1.Hash(), big.NewInt(3), big.NewInt(3000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 3, common.Location{0, 1}, common.BytesToAddress([]byte{0}, common.Location{0, 1}), []byte{0, 1, 2, 3})
zone1Block2 := types.NewWorkObject(zone1WoHeader2, zone1Body2, nil)
WriteWorkObject(db, zone1Block2.Hash(), zone1Block2, types.BlockObject, common.ZONE_CTX)

Expand Down Expand Up @@ -588,7 +588,7 @@ func createTestWorkObject() *types.WorkObject {
woBody := types.EmptyWorkObjectBody()
woBody.SetHeader(types.EmptyHeader())

woHeader := types.NewWorkObjectHeader(types.EmptyRootHash, types.EmptyRootHash, big.NewInt(11), big.NewInt(30000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 1, common.LocationFromAddressBytes([]byte{0x01, 0x01}), common.BytesToAddress([]byte{0}, common.Location{0, 0}))
woHeader := types.NewWorkObjectHeader(types.EmptyRootHash, types.EmptyRootHash, big.NewInt(11), big.NewInt(30000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 1, common.LocationFromAddressBytes([]byte{0x01, 0x01}), common.BytesToAddress([]byte{0}, common.Location{0, 0}), []byte{0, 1, 2, 3})
return types.NewWorkObject(woHeader, woBody, nil)
}

Expand Down Expand Up @@ -742,7 +742,7 @@ func createBlockWithTransactions(txs types.Transactions) *types.WorkObject {
woBody := types.EmptyWorkObjectBody()
woBody.SetHeader(types.EmptyHeader())
woBody.SetTransactions(txs)
return types.NewWorkObject(types.NewWorkObjectHeader(types.EmptyRootHash, types.EmptyRootHash, big.NewInt(0), big.NewInt(30000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 1, common.LocationFromAddressBytes([]byte{0x01, 0x01}), common.BytesToAddress([]byte{0}, common.Location{0, 0})), woBody, nil)
return types.NewWorkObject(types.NewWorkObjectHeader(types.EmptyRootHash, types.EmptyRootHash, big.NewInt(0), big.NewInt(30000), big.NewInt(42), types.EmptyRootHash, types.BlockNonce{23}, 1, 1, common.LocationFromAddressBytes([]byte{0x01, 0x01}), common.BytesToAddress([]byte{0}, common.Location{0, 0}), []byte{0, 1, 2, 3}), woBody, nil)
}

func writeBlockForReceipts(db ethdb.Database, hash common.Hash, txs types.Transactions) {
Expand Down
1 change: 1 addition & 0 deletions core/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ func (sl *Slice) combinePendingHeader(header *types.WorkObject, slPendingHeader
combinedPendingHeader.WorkObjectHeader().SetPrimeTerminusNumber(header.PrimeTerminusNumber())
combinedPendingHeader.WorkObjectHeader().SetLock(header.Lock())
combinedPendingHeader.WorkObjectHeader().SetPrimaryCoinbase(header.PrimaryCoinbase())
combinedPendingHeader.WorkObjectHeader().SetData(header.Data())

combinedPendingHeader.Header().SetEtxRollupHash(header.EtxRollupHash())
combinedPendingHeader.Header().SetUncledEntropy(header.Header().UncledEntropy())
Expand Down
6 changes: 5 additions & 1 deletion core/types/gen_header_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d10b69b

Please sign in to comment.