Skip to content

Commit

Permalink
format info and optimize channel buffers
Browse files Browse the repository at this point in the history
Signed-off-by: Pranay Valson <[email protected]>
  • Loading branch information
noslav committed Mar 28, 2024
1 parent 3297649 commit 4eaf414
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
18 changes: 8 additions & 10 deletions core/block_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,23 @@ type BlockReplicationEvent struct {

func (bc *BlockChain) createBlockReplica(block *types.Block, replicaConfig *ReplicaConfig, chainConfig *params.ChainConfig, stateSpecimen *types.StateSpecimen) error {

// blobs
var blobTxSidecars []*types.BlobTxSidecar
for sidecarData := range types.BlobTxSidecarChan {
if sidecarData.BlockNumber.Uint64() == block.NumberU64() {
log.Info("Consuming Sidecar From Miner Side Channel: ", sidecarData.BlockNumber)
log.Info("Consuming BlobTxSidecar Match From Chain Sync Channel", "Block Number:", sidecarData.BlockNumber.Uint64())
blobTxSidecars = append(blobTxSidecars, sidecarData.Blobs)
} else {
log.Info("Blob Sidecar did not match block number from Miner Side Channel: ", sidecarData.BlockNumber.Uint64())
log.Info("Failing BlobTxSidecar Match from Chain Sync Channel", "Block Number:", sidecarData.BlockNumber.Uint64())
}
fmt.Println("side car header block number:", sidecarData.BlockNumber)
fmt.Println("length of sidecar channel:", len(types.BlobTxSidecarChan))

// blobTxSidecars = append(blobTxSidecars, sidecarData.Blobs)
}
log.Info("BlobTxSidecar Header", "Block Number:", sidecarData.BlockNumber.Uint64())

log.Info("Chain Sync Sidecar Channel", "Length:", len(types.BlobTxSidecarChan))

// for _, sidecarData := range blobTxSidecars {
// fmt.Println(*sidecarData, "full side car")
// }
}

//block replica
//block replica with blobs
exportBlockReplica, err := bc.createReplica(block, replicaConfig, chainConfig, stateSpecimen, blobTxSidecars)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion core/types/block_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type BlobTxSidecarData struct {
BlockNumber *big.Int
}

var BlobTxSidecarChan = make(chan *BlobTxSidecarData, 1000)
var BlobTxSidecarChan = make(chan *BlobTxSidecarData, 100)

func (r *ReceiptForExport) ExportReceipt() *ReceiptExportRLP {
enc := &ReceiptExportRLP{
Expand Down
4 changes: 2 additions & 2 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (env *environment) copy() *environment {
cpy.sidecars = make([]*types.BlobTxSidecar, len(env.sidecars))
copy(cpy.sidecars, env.sidecars)

types.BlobTxSidecarChan = make(chan *types.BlobTxSidecarData, 1000)
types.BlobTxSidecarChan = make(chan *types.BlobTxSidecarData, 100)

go func() {
for sidecar := range env.sidecars {
Expand All @@ -127,7 +127,7 @@ func (env *environment) copy() *environment {
BlockNumber: env.header.Number,
}
}
fmt.Println("closed sidecar channel in miner")
log.Info("Closing Chain Sync BlobTxSidecar Channel For", "Block Number:", env.header.Number.Uint64(), "Length:", len(types.BlobTxSidecarChan))
close(types.BlobTxSidecarChan)
}()

Expand Down

0 comments on commit 4eaf414

Please sign in to comment.