Skip to content

Commit

Permalink
refac the cache length param to fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Oct 1, 2024
1 parent 4177fec commit 45d684a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 4 additions & 7 deletions packages/client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export interface ConfigOptions {
/**
* The cache for blobs and proofs to support CL import blocks
*/
blobsAndProofsCacheLength?: number
blobsAndProofsCacheBlocks?: number

/**
* Enables Prometheus Metrics that can be collected for monitoring client health
Expand Down Expand Up @@ -459,7 +459,7 @@ export class Config {
public readonly startExecution: boolean
public readonly ignoreStatelessInvalidExecs: boolean

public readonly blobsAndProofsCacheLength: number
public readonly blobsAndProofsCacheBlocks: number

public synchronized: boolean
public lastSynchronized?: boolean
Expand Down Expand Up @@ -563,11 +563,8 @@ export class Config {
this.chainCommon = common.copy()
this.execCommon = common.copy()

const blobGasLimit = common.param('maxblobGasPerBlock')
const blobGasPerBlob = common.param('blobGasPerBlob')
const allowedBlobs = Number(blobGasLimit / blobGasPerBlob)
this.blobsAndProofsCacheLength =
options.blobsAndProofsCacheLength ?? allowedBlobs * Config.BLOBS_AND_PROOFS_CACHE_BLOCKS
this.blobsAndProofsCacheBlocks =
options.blobsAndProofsCacheBlocks ?? Config.BLOBS_AND_PROOFS_CACHE_BLOCKS

this.discDns = this.getDnsDiscovery(options.discDns)
this.discV4 = options.discV4 ?? true
Expand Down
7 changes: 6 additions & 1 deletion packages/client/src/service/txpool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,12 @@ export class TxPool {
}

pruneBlobsAndProofsCache() {
const pruneLength = this.blobsAndProofsByHash.size - this.config.blobsAndProofsCacheLength
const blobGasLimit = this.config.chainCommon.param('maxblobGasPerBlock')
const blobGasPerBlob = this.config.chainCommon.param('blobGasPerBlob')
const allowedBlobs = Number(blobGasLimit / blobGasPerBlob)

const pruneLength =
this.blobsAndProofsByHash.size - allowedBlobs * this.config.blobsAndProofsCacheBlocks
let pruned = 0
// since keys() is sorted by insertion order this prunes the oldest data in cache
for (const versionedHash of this.blobsAndProofsByHash.keys()) {
Expand Down

0 comments on commit 45d684a

Please sign in to comment.