New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →

@aztec/archiver

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aztec/archiver - npm Package Compare versions

Comparing version

to
0.79.0

@@ -47,4 +47,4 @@ /// <reference types="node" resolution-mode="require"/>

private store;
l1BlockNumber: bigint | undefined;
l1Timestamp: bigint | undefined;
private l1BlockNumber;
private l1Timestamp;
readonly tracer: Tracer;

@@ -51,0 +51,0 @@ /**

@@ -170,9 +170,6 @@ function _ts_decorate(decorators, target, key, desc) {

await this.handleL1ToL2Messages(messagesSynchedTo, currentL1BlockNumber);
// Store latest l1 block number and timestamp seen. Used for epoch and slots calculations.
if (!this.l1BlockNumber || this.l1BlockNumber < currentL1BlockNumber) {
this.l1Timestamp = (await this.publicClient.getBlock({
blockNumber: currentL1BlockNumber
})).timestamp;
this.l1BlockNumber = currentL1BlockNumber;
}
// Get L1 timestamp for the current block
const currentL1Timestamp = !this.l1Timestamp || !this.l1BlockNumber || this.l1BlockNumber !== currentL1BlockNumber ? (await this.publicClient.getBlock({
blockNumber: currentL1BlockNumber
})).timestamp : this.l1Timestamp;
// ********** Events that are processed per L2 block **********

@@ -187,5 +184,10 @@ if (currentL1BlockNumber > blocksSynchedTo) {

// up to which point we're pruning, and then requesting L2 blocks up to that point only.
await this.handleEpochPrune(provenBlockNumber, currentL1BlockNumber);
await this.handleEpochPrune(provenBlockNumber, currentL1BlockNumber, currentL1Timestamp);
this.instrumentation.updateL1BlockHeight(currentL1BlockNumber);
}
// After syncing has completed, update the current l1 block number and timestamp,
// otherwise we risk announcing to the world that we've synced to a given point,
// but the corresponding blocks have not been processed (see #12631).
this.l1Timestamp = currentL1Timestamp;
this.l1BlockNumber = currentL1BlockNumber;
if (initialRun) {

@@ -199,4 +201,4 @@ this.log.info(`Initial archiver sync to L1 block ${currentL1BlockNumber} complete.`, {

}
/** Queries the rollup contract on whether a prune can be executed on the immediatenext L1 block. */ async canPrune(currentL1BlockNumber) {
const time = (this.l1Timestamp ?? 0n) + BigInt(this.l1constants.ethereumSlotDuration);
/** Queries the rollup contract on whether a prune can be executed on the immediatenext L1 block. */ async canPrune(currentL1BlockNumber, currentL1Timestamp) {
const time = (currentL1Timestamp ?? 0n) + BigInt(this.l1constants.ethereumSlotDuration);
return await this.rollup.read.canPruneAtTime([

@@ -208,7 +210,7 @@ time

}
/** Checks if there'd be a reorg for the next block submission and start pruning now. */ async handleEpochPrune(provenBlockNumber, currentL1BlockNumber) {
/** Checks if there'd be a reorg for the next block submission and start pruning now. */ async handleEpochPrune(provenBlockNumber, currentL1BlockNumber, currentL1Timestamp) {
const localPendingBlockNumber = BigInt(await this.getBlockNumber());
const canPrune = localPendingBlockNumber > provenBlockNumber && await this.canPrune(currentL1BlockNumber);
const canPrune = localPendingBlockNumber > provenBlockNumber && await this.canPrune(currentL1BlockNumber, currentL1Timestamp);
if (canPrune) {
const localPendingSlotNumber = await this.getL2SlotNumber();
const localPendingSlotNumber = getSlotAtTimestamp(currentL1Timestamp, this.l1constants);
const localPendingEpochNumber = getEpochAtSlot(localPendingSlotNumber, this.l1constants);

@@ -215,0 +217,0 @@ // Emit an event for listening services to react to the chain prune

{
"name": "@aztec/archiver",
"version": "0.78.1",
"version": "0.79.0",
"type": "module",

@@ -67,14 +67,14 @@ "exports": {

"dependencies": {
"@aztec/blob-lib": "0.78.1",
"@aztec/blob-sink": "0.78.1",
"@aztec/constants": "0.78.1",
"@aztec/ethereum": "0.78.1",
"@aztec/foundation": "0.78.1",
"@aztec/kv-store": "0.78.1",
"@aztec/l1-artifacts": "0.78.1",
"@aztec/noir-contracts.js": "0.78.1",
"@aztec/noir-protocol-circuits-types": "0.78.1",
"@aztec/protocol-contracts": "0.78.1",
"@aztec/stdlib": "0.78.1",
"@aztec/telemetry-client": "0.78.1",
"@aztec/blob-lib": "0.79.0",
"@aztec/blob-sink": "0.79.0",
"@aztec/constants": "0.79.0",
"@aztec/ethereum": "0.79.0",
"@aztec/foundation": "0.79.0",
"@aztec/kv-store": "0.79.0",
"@aztec/l1-artifacts": "0.79.0",
"@aztec/noir-contracts.js": "0.79.0",
"@aztec/noir-protocol-circuits-types": "0.79.0",
"@aztec/protocol-contracts": "0.79.0",
"@aztec/stdlib": "0.79.0",
"@aztec/telemetry-client": "0.79.0",
"debug": "^4.3.4",

@@ -85,3 +85,3 @@ "lodash.groupby": "^4.6.0",

"tslib": "^2.5.0",
"viem": "2.22.8",
"viem": "2.23.7",
"ws": "^8.13.0"

@@ -88,0 +88,0 @@ },

@@ -93,4 +93,4 @@ import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';

public l1BlockNumber: bigint | undefined;
public l1Timestamp: bigint | undefined;
private l1BlockNumber: bigint | undefined;
private l1Timestamp: bigint | undefined;

@@ -274,7 +274,7 @@ public readonly tracer: Tracer;

// Store latest l1 block number and timestamp seen. Used for epoch and slots calculations.
if (!this.l1BlockNumber || this.l1BlockNumber < currentL1BlockNumber) {
this.l1Timestamp = (await this.publicClient.getBlock({ blockNumber: currentL1BlockNumber })).timestamp;
this.l1BlockNumber = currentL1BlockNumber;
}
// Get L1 timestamp for the current block
const currentL1Timestamp =
!this.l1Timestamp || !this.l1BlockNumber || this.l1BlockNumber !== currentL1BlockNumber
? (await this.publicClient.getBlock({ blockNumber: currentL1BlockNumber })).timestamp
: this.l1Timestamp;

@@ -290,7 +290,12 @@ // ********** Events that are processed per L2 block **********

// up to which point we're pruning, and then requesting L2 blocks up to that point only.
await this.handleEpochPrune(provenBlockNumber, currentL1BlockNumber);
await this.handleEpochPrune(provenBlockNumber, currentL1BlockNumber, currentL1Timestamp);
this.instrumentation.updateL1BlockHeight(currentL1BlockNumber);
}
// After syncing has completed, update the current l1 block number and timestamp,
// otherwise we risk announcing to the world that we've synced to a given point,
// but the corresponding blocks have not been processed (see #12631).
this.l1Timestamp = currentL1Timestamp;
this.l1BlockNumber = currentL1BlockNumber;
if (initialRun) {

@@ -306,4 +311,4 @@ this.log.info(`Initial archiver sync to L1 block ${currentL1BlockNumber} complete.`, {

/** Queries the rollup contract on whether a prune can be executed on the immediatenext L1 block. */
private async canPrune(currentL1BlockNumber: bigint) {
const time = (this.l1Timestamp ?? 0n) + BigInt(this.l1constants.ethereumSlotDuration);
private async canPrune(currentL1BlockNumber: bigint, currentL1Timestamp: bigint) {
const time = (currentL1Timestamp ?? 0n) + BigInt(this.l1constants.ethereumSlotDuration);
return await this.rollup.read.canPruneAtTime([time], { blockNumber: currentL1BlockNumber });

@@ -313,8 +318,9 @@ }

/** Checks if there'd be a reorg for the next block submission and start pruning now. */
private async handleEpochPrune(provenBlockNumber: bigint, currentL1BlockNumber: bigint) {
private async handleEpochPrune(provenBlockNumber: bigint, currentL1BlockNumber: bigint, currentL1Timestamp: bigint) {
const localPendingBlockNumber = BigInt(await this.getBlockNumber());
const canPrune = localPendingBlockNumber > provenBlockNumber && (await this.canPrune(currentL1BlockNumber));
const canPrune =
localPendingBlockNumber > provenBlockNumber && (await this.canPrune(currentL1BlockNumber, currentL1Timestamp));
if (canPrune) {
const localPendingSlotNumber = await this.getL2SlotNumber();
const localPendingSlotNumber = getSlotAtTimestamp(currentL1Timestamp, this.l1constants);
const localPendingEpochNumber = getEpochAtSlot(localPendingSlotNumber, this.l1constants);

@@ -321,0 +327,0 @@

Sorry, the diff of this file is not supported yet