Skip to content

Commit

Permalink
apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Oct 1, 2024
1 parent fa12d79 commit 0ff225f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 16 additions & 0 deletions packages/client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ export interface ConfigOptions {
startExecution?: boolean
ignoreStatelessInvalidExecs?: boolean

/**
* The cache for blobs and proofs to support CL import blocks
*/
blobsAndProofsCacheLength?: number

/**
* Enables Prometheus Metrics that can be collected for monitoring client health
*/
Expand Down Expand Up @@ -393,6 +398,9 @@ export class Config {
// randomly kept it at 5 for fast testing purposes but ideally should be >=32 slots
public static readonly SNAP_TRANSITION_SAFE_DEPTH = BigInt(5)

// support blobs and proofs cache for CL getBlobs for upto 1 epoch of data
public static readonly BLOBS_AND_PROOFS_CACHE_BLOCKS = 32

public readonly logger: Logger
public readonly syncmode: SyncMode
public readonly vm?: VM
Expand Down Expand Up @@ -451,6 +459,8 @@ export class Config {
public readonly startExecution: boolean
public readonly ignoreStatelessInvalidExecs: boolean

public readonly blobsAndProofsCacheLength: number

public synchronized: boolean
public lastSynchronized?: boolean
/** lastSyncDate in ms */
Expand Down Expand Up @@ -553,6 +563,12 @@ 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.discDns = this.getDnsDiscovery(options.discDns)
this.discV4 = options.discV4 ?? true

Expand Down
5 changes: 2 additions & 3 deletions packages/client/src/service/txpool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ const MIN_GAS_PRICE = BigInt(100000000) // .1 GWei
const TX_MAX_DATA_SIZE = 128 * 1024 // 128KB
const MAX_POOL_SIZE = 5000
const MAX_TXS_PER_ACCOUNT = 100
// keep for 1 epoch deep to handle reorgs
const BLOBS_AND_PROOFS_CACHE_LENGTH = 6 * 32 * 1

export interface TxPoolOptions {
/* Config */
Expand Down Expand Up @@ -401,8 +399,9 @@ export class TxPool {
}

pruneBlobsAndProofsCache() {
const pruneLength = this.blobsAndProofsByHash.size - BLOBS_AND_PROOFS_CACHE_LENGTH
const pruneLength = this.blobsAndProofsByHash.size - this.config.blobsAndProofsCacheLength
let pruned = 0
// since keys() is sorted by insertion order this prunes the olddest data in cache
for (const versionedHash of this.blobsAndProofsByHash.keys()) {
if (pruned >= pruneLength) {
break
Expand Down

0 comments on commit 0ff225f

Please sign in to comment.