@aztec/stdlib 0.77.0-testnet-ignition.30 → 0.77.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/contract/interfaces/contract_instance_update.js +1 -1
- package/dest/contract/interfaces/node-info.js +2 -2
- package/dest/database-version/index.d.ts +2 -0
- package/dest/database-version/index.d.ts.map +1 -0
- package/dest/database-version/index.js +1 -0
- package/dest/database-version/version_manager.d.ts +99 -0
- package/dest/database-version/version_manager.d.ts.map +1 -0
- package/dest/database-version/version_manager.js +188 -0
- package/dest/errors/simulation_error.js +2 -2
- package/dest/hash/hash.d.ts +0 -2
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +0 -11
- package/dest/interfaces/world_state.js +3 -3
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -1
- package/dest/logs/contract_class_log.d.ts +4 -0
- package/dest/logs/contract_class_log.d.ts.map +1 -1
- package/dest/logs/contract_class_log.js +30 -9
- package/dest/logs/private_log.d.ts +2 -0
- package/dest/logs/private_log.d.ts.map +1 -1
- package/dest/logs/private_log.js +9 -0
- package/dest/logs/public_log.d.ts +2 -0
- package/dest/logs/public_log.d.ts.map +1 -1
- package/dest/logs/public_log.js +10 -0
- package/dest/messaging/l2_to_l1_message.js +1 -1
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +4 -6
- package/dest/tx/tx_effect.d.ts.map +1 -1
- package/dest/tx/tx_effect.js +26 -10
- package/dest/tx/tx_receipt.js +1 -1
- package/package.json +8 -7
- package/src/contract/interfaces/contract_instance_update.ts +1 -1
- package/src/contract/interfaces/node-info.ts +2 -2
- package/src/database-version/README.md +63 -0
- package/src/database-version/index.ts +1 -0
- package/src/database-version/version_manager.ts +207 -0
- package/src/errors/simulation_error.ts +2 -2
- package/src/hash/hash.ts +0 -10
- package/src/interfaces/world_state.ts +3 -3
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +5 -1
- package/src/logs/contract_class_log.ts +28 -9
- package/src/logs/private_log.ts +11 -0
- package/src/logs/public_log.ts +12 -0
- package/src/messaging/l2_to_l1_message.ts +1 -1
- package/src/tx/tx.ts +7 -7
- package/src/tx/tx_effect.ts +29 -9
- package/src/tx/tx_receipt.ts +1 -1
|
@@ -3,7 +3,7 @@ import { schemas } from '../../schemas/index.js';
|
|
|
3
3
|
export const ContractInstanceUpdateSchema = z.object({
|
|
4
4
|
prevContractClassId: schemas.Fr,
|
|
5
5
|
newContractClassId: schemas.Fr,
|
|
6
|
-
blockOfChange: z.number()
|
|
6
|
+
blockOfChange: z.number().int().nonnegative()
|
|
7
7
|
});
|
|
8
8
|
export const ContractInstanceUpdateWithAddressSchema = ContractInstanceUpdateSchema.and(z.object({
|
|
9
9
|
address: schemas.AztecAddress
|
|
@@ -3,8 +3,8 @@ import { z } from 'zod';
|
|
|
3
3
|
import { ProtocolContractAddressesSchema } from './protocol_contract_addresses.js';
|
|
4
4
|
export const NodeInfoSchema = z.object({
|
|
5
5
|
nodeVersion: z.string(),
|
|
6
|
-
l1ChainId: z.number(),
|
|
7
|
-
protocolVersion: z.number(),
|
|
6
|
+
l1ChainId: z.number().int().nonnegative(),
|
|
7
|
+
protocolVersion: z.number().int().nonnegative(),
|
|
8
8
|
enr: z.string().optional(),
|
|
9
9
|
l1ContractAddresses: L1ContractAddressesSchema,
|
|
10
10
|
protocolContractAddresses: ProtocolContractAddressesSchema
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database-version/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './version_manager.js';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
|
+
import fs from 'fs/promises';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a version record for storing in a version file.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DatabaseVersion {
|
|
11
|
+
readonly schemaVersion: number;
|
|
12
|
+
readonly rollupAddress: EthAddress;
|
|
13
|
+
constructor(schemaVersion: number, rollupAddress: EthAddress);
|
|
14
|
+
toBuffer(): Buffer;
|
|
15
|
+
static fromBuffer(buf: Buffer): DatabaseVersion;
|
|
16
|
+
/**
|
|
17
|
+
* Compares two versions. If the rollups addresses are different then it returns undefined
|
|
18
|
+
*/
|
|
19
|
+
cmp(other: DatabaseVersion): undefined | -1 | 0 | 1;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if two versions exactly match
|
|
22
|
+
*/
|
|
23
|
+
equals(other: DatabaseVersion): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the schema for this class
|
|
26
|
+
*/
|
|
27
|
+
static get schema(): z.ZodEffects<z.ZodObject<{
|
|
28
|
+
schemaVersion: z.ZodNumber;
|
|
29
|
+
rollupAddress: z.ZodType<EthAddress, any, string>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
rollupAddress: EthAddress;
|
|
32
|
+
schemaVersion: number;
|
|
33
|
+
}, {
|
|
34
|
+
rollupAddress: string;
|
|
35
|
+
schemaVersion: number;
|
|
36
|
+
}>, DatabaseVersion, {
|
|
37
|
+
rollupAddress: string;
|
|
38
|
+
schemaVersion: number;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Returns an empty instance
|
|
42
|
+
*/
|
|
43
|
+
static empty(): DatabaseVersion;
|
|
44
|
+
}
|
|
45
|
+
export type DatabaseVersionManagerFs = Pick<typeof fs, 'readFile' | 'writeFile' | 'rm' | 'mkdir'>;
|
|
46
|
+
/**
|
|
47
|
+
* A manager for handling database versioning and migrations.
|
|
48
|
+
* This class will check the version of data in a directory and either
|
|
49
|
+
* reset or upgrade based on version compatibility.
|
|
50
|
+
*/
|
|
51
|
+
export declare class DatabaseVersionManager<T> {
|
|
52
|
+
private dataDirectory;
|
|
53
|
+
private onOpen;
|
|
54
|
+
private onUpgrade?;
|
|
55
|
+
private fileSystem;
|
|
56
|
+
private log;
|
|
57
|
+
static readonly VERSION_FILE = "db_version";
|
|
58
|
+
private readonly versionFile;
|
|
59
|
+
private readonly currentVersion;
|
|
60
|
+
/**
|
|
61
|
+
* Create a new version manager
|
|
62
|
+
*
|
|
63
|
+
* @param schemaVersion - The current version of the application
|
|
64
|
+
* @param rollupAddress - The rollup contract address
|
|
65
|
+
* @param dataDirectory - The directory where version information will be stored
|
|
66
|
+
* @param onOpen - A callback to the open the database at the given location
|
|
67
|
+
* @param onUpgrade - An optional callback to upgrade the database before opening. If not provided it will reset the database
|
|
68
|
+
* @param fileSystem - An interface to access the filesystem
|
|
69
|
+
* @param log - Optional custom logger
|
|
70
|
+
* @param options - Configuration options
|
|
71
|
+
*/
|
|
72
|
+
constructor(schemaVersion: number, rollupAddress: EthAddress, dataDirectory: string, onOpen: (dataDir: string) => Promise<T>, onUpgrade?: ((dataDir: string, currentVersion: number, latestVersion: number) => Promise<void>) | undefined, fileSystem?: DatabaseVersionManagerFs, log?: import("@aztec/foundation/log").Logger);
|
|
73
|
+
/**
|
|
74
|
+
* Checks the stored version against the current version and handles the outcome
|
|
75
|
+
* by either resetting the data directory or calling an upgrade function
|
|
76
|
+
*
|
|
77
|
+
* @param onReset - Function to call when a full reset is needed
|
|
78
|
+
* @param onUpgrade - Function to call when an upgrade is needed
|
|
79
|
+
* @returns True if data was reset, false if upgraded or no change needed
|
|
80
|
+
*/
|
|
81
|
+
open(): Promise<[T, boolean]>;
|
|
82
|
+
/**
|
|
83
|
+
* Writes the current version to the version file
|
|
84
|
+
*/
|
|
85
|
+
private writeVersion;
|
|
86
|
+
/**
|
|
87
|
+
* Resets the data directory by deleting it and recreating it
|
|
88
|
+
*/
|
|
89
|
+
private resetDataDirectory;
|
|
90
|
+
/**
|
|
91
|
+
* Get the data directory path
|
|
92
|
+
*/
|
|
93
|
+
getDataDirectory(): string;
|
|
94
|
+
/**
|
|
95
|
+
* Get the current version number
|
|
96
|
+
*/
|
|
97
|
+
getSchemaVersion(): number;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=version_manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version_manager.d.ts","sourceRoot":"","sources":["../../src/database-version/version_manager.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,qBAAa,eAAe;aACE,aAAa,EAAE,MAAM;aAAkB,aAAa,EAAE,UAAU;gBAAhE,aAAa,EAAE,MAAM,EAAkB,aAAa,EAAE,UAAU;IAErF,QAAQ,IAAI,MAAM;WAIX,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe;IAQtD;;OAEG;IACI,GAAG,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAa1D;;OAEG;IACI,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO;IAI9C;;OAEG;IACH,MAAM,KAAK,MAAM;;;;;;;;;;;;OAOhB;IAED;;OAEG;IACH,MAAM,CAAC,KAAK;CAGb;AAED,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC;AAElG;;;;GAIG;AACH,qBAAa,sBAAsB,CAAC,CAAC;IAqBjC,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,SAAS,CAAC;IAClB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,GAAG;IAxBb,gBAAuB,YAAY,gBAAgB;IAEnD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkB;IAEjD;;;;;;;;;;;OAWG;gBAED,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,UAAU,EACjB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACvC,SAAS,CAAC,aAAY,MAAM,kBAAkB,MAAM,iBAAiB,MAAM,KAAK,QAAQ,IAAI,CAAC,aAAA,EAC7F,UAAU,GAAE,wBAA6B,EACzC,GAAG,yCAA6C;IAU1D;;;;;;;OAOG;IACU,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAmD1C;;OAEG;YACW,YAAY;IAO1B;;OAEG;YACW,kBAAkB;IAUhC;;OAEG;IACI,gBAAgB,IAAI,MAAM;IAIjC;;OAEG;IACI,gBAAgB,IAAI,MAAM;CAGlC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { jsonParseWithSchemaSync, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import fs from 'fs/promises';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a version record for storing in a version file.
|
|
9
|
+
*/ export class DatabaseVersion {
|
|
10
|
+
schemaVersion;
|
|
11
|
+
rollupAddress;
|
|
12
|
+
constructor(schemaVersion, rollupAddress){
|
|
13
|
+
this.schemaVersion = schemaVersion;
|
|
14
|
+
this.rollupAddress = rollupAddress;
|
|
15
|
+
}
|
|
16
|
+
toBuffer() {
|
|
17
|
+
return Buffer.from(jsonStringify(this));
|
|
18
|
+
}
|
|
19
|
+
static fromBuffer(buf) {
|
|
20
|
+
try {
|
|
21
|
+
return jsonParseWithSchemaSync(buf.toString('utf-8'), DatabaseVersion.schema);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
throw new Error(`Failed to deserialize version information: ${err}`, {
|
|
24
|
+
cause: err
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Compares two versions. If the rollups addresses are different then it returns undefined
|
|
30
|
+
*/ cmp(other) {
|
|
31
|
+
if (this.rollupAddress.equals(other.rollupAddress)) {
|
|
32
|
+
if (this.schemaVersion < other.schemaVersion) {
|
|
33
|
+
return -1;
|
|
34
|
+
} else if (this.schemaVersion > other.schemaVersion) {
|
|
35
|
+
return 1;
|
|
36
|
+
} else {
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Checks if two versions exactly match
|
|
44
|
+
*/ equals(other) {
|
|
45
|
+
return this.cmp(other) === 0;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns the schema for this class
|
|
49
|
+
*/ static get schema() {
|
|
50
|
+
return z.object({
|
|
51
|
+
schemaVersion: z.number(),
|
|
52
|
+
rollupAddress: EthAddress.schema
|
|
53
|
+
}).transform(({ schemaVersion, rollupAddress })=>new DatabaseVersion(schemaVersion, rollupAddress));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns an empty instance
|
|
57
|
+
*/ static empty() {
|
|
58
|
+
return new DatabaseVersion(0, EthAddress.ZERO);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A manager for handling database versioning and migrations.
|
|
63
|
+
* This class will check the version of data in a directory and either
|
|
64
|
+
* reset or upgrade based on version compatibility.
|
|
65
|
+
*/ export class DatabaseVersionManager {
|
|
66
|
+
dataDirectory;
|
|
67
|
+
onOpen;
|
|
68
|
+
onUpgrade;
|
|
69
|
+
fileSystem;
|
|
70
|
+
log;
|
|
71
|
+
static VERSION_FILE = 'db_version';
|
|
72
|
+
versionFile;
|
|
73
|
+
currentVersion;
|
|
74
|
+
/**
|
|
75
|
+
* Create a new version manager
|
|
76
|
+
*
|
|
77
|
+
* @param schemaVersion - The current version of the application
|
|
78
|
+
* @param rollupAddress - The rollup contract address
|
|
79
|
+
* @param dataDirectory - The directory where version information will be stored
|
|
80
|
+
* @param onOpen - A callback to the open the database at the given location
|
|
81
|
+
* @param onUpgrade - An optional callback to upgrade the database before opening. If not provided it will reset the database
|
|
82
|
+
* @param fileSystem - An interface to access the filesystem
|
|
83
|
+
* @param log - Optional custom logger
|
|
84
|
+
* @param options - Configuration options
|
|
85
|
+
*/ constructor(schemaVersion, rollupAddress, dataDirectory, onOpen, onUpgrade, fileSystem = fs, log = createLogger(`foundation:version-manager`)){
|
|
86
|
+
this.dataDirectory = dataDirectory;
|
|
87
|
+
this.onOpen = onOpen;
|
|
88
|
+
this.onUpgrade = onUpgrade;
|
|
89
|
+
this.fileSystem = fileSystem;
|
|
90
|
+
this.log = log;
|
|
91
|
+
if (schemaVersion < 1) {
|
|
92
|
+
throw new TypeError(`Invalid schema version received: ${schemaVersion}`);
|
|
93
|
+
}
|
|
94
|
+
this.versionFile = join(this.dataDirectory, DatabaseVersionManager.VERSION_FILE);
|
|
95
|
+
this.currentVersion = new DatabaseVersion(schemaVersion, rollupAddress);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Checks the stored version against the current version and handles the outcome
|
|
99
|
+
* by either resetting the data directory or calling an upgrade function
|
|
100
|
+
*
|
|
101
|
+
* @param onReset - Function to call when a full reset is needed
|
|
102
|
+
* @param onUpgrade - Function to call when an upgrade is needed
|
|
103
|
+
* @returns True if data was reset, false if upgraded or no change needed
|
|
104
|
+
*/ async open() {
|
|
105
|
+
// const storedVersion = await DatabaseVersion.readVersion(this.versionFile);
|
|
106
|
+
let storedVersion;
|
|
107
|
+
try {
|
|
108
|
+
const versionBuf = await this.fileSystem.readFile(this.versionFile);
|
|
109
|
+
storedVersion = DatabaseVersion.fromBuffer(versionBuf);
|
|
110
|
+
} catch (err) {
|
|
111
|
+
if (err && err.code === 'ENOENT') {
|
|
112
|
+
storedVersion = DatabaseVersion.empty();
|
|
113
|
+
} else {
|
|
114
|
+
this.log.warn(`Failed to read stored version information: ${err}. Defaulting to empty version`);
|
|
115
|
+
storedVersion = DatabaseVersion.empty();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const cmp = storedVersion.cmp(this.currentVersion);
|
|
119
|
+
let needsReset = false;
|
|
120
|
+
if (typeof cmp === 'number') {
|
|
121
|
+
// only allow forward upgrades
|
|
122
|
+
if (cmp === -1 && this.onUpgrade) {
|
|
123
|
+
this.log.info(`Upgrading from version ${storedVersion.schemaVersion} to ${this.currentVersion.schemaVersion}`);
|
|
124
|
+
try {
|
|
125
|
+
await this.onUpgrade(this.dataDirectory, storedVersion.schemaVersion, this.currentVersion.schemaVersion);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
this.log.error(`Failed to upgrade: ${error}. Falling back to reset.`);
|
|
128
|
+
needsReset = true;
|
|
129
|
+
}
|
|
130
|
+
} else if (cmp !== 0) {
|
|
131
|
+
this.log.info(`Can't upgrade from version ${storedVersion.schemaVersion} to ${this.currentVersion}. Resetting database at ${this.dataDirectory}`);
|
|
132
|
+
needsReset = true;
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
this.log.warn('Rollup address changed, resetting data directory');
|
|
136
|
+
needsReset = true;
|
|
137
|
+
}
|
|
138
|
+
// Handle reset if needed
|
|
139
|
+
if (needsReset) {
|
|
140
|
+
await this.resetDataDirectory();
|
|
141
|
+
}
|
|
142
|
+
// Write the current version to disk
|
|
143
|
+
await this.writeVersion();
|
|
144
|
+
return [
|
|
145
|
+
await this.onOpen(this.dataDirectory),
|
|
146
|
+
needsReset
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Writes the current version to the version file
|
|
151
|
+
*/ async writeVersion() {
|
|
152
|
+
// Ensure the directory exists
|
|
153
|
+
await this.fileSystem.mkdir(this.dataDirectory, {
|
|
154
|
+
recursive: true
|
|
155
|
+
});
|
|
156
|
+
// Write the version file
|
|
157
|
+
await this.fileSystem.writeFile(this.versionFile, this.currentVersion.toBuffer());
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Resets the data directory by deleting it and recreating it
|
|
161
|
+
*/ async resetDataDirectory() {
|
|
162
|
+
try {
|
|
163
|
+
await this.fileSystem.rm(this.dataDirectory, {
|
|
164
|
+
recursive: true,
|
|
165
|
+
force: true,
|
|
166
|
+
maxRetries: 3
|
|
167
|
+
});
|
|
168
|
+
await this.fileSystem.mkdir(this.dataDirectory, {
|
|
169
|
+
recursive: true
|
|
170
|
+
});
|
|
171
|
+
} catch (err) {
|
|
172
|
+
this.log.error(`Failed to reset data directory: ${err}`);
|
|
173
|
+
throw new Error(`Failed to reset data directory: ${err}`, {
|
|
174
|
+
cause: err
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Get the data directory path
|
|
180
|
+
*/ getDataDirectory() {
|
|
181
|
+
return this.dataDirectory;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get the current version number
|
|
185
|
+
*/ getSchemaVersion() {
|
|
186
|
+
return this.currentVersion.schemaVersion;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -4,8 +4,8 @@ import { AztecAddress } from '../aztec-address/index.js';
|
|
|
4
4
|
import { schemas } from '../schemas/index.js';
|
|
5
5
|
const SourceCodeLocationSchema = z.object({
|
|
6
6
|
filePath: z.string(),
|
|
7
|
-
line: z.number(),
|
|
8
|
-
column: z.number(),
|
|
7
|
+
line: z.number().int().nonnegative(),
|
|
8
|
+
column: z.number().int().nonnegative(),
|
|
9
9
|
fileSource: z.string(),
|
|
10
10
|
locationText: z.string()
|
|
11
11
|
});
|
package/dest/hash/hash.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
3
|
-
import type { ContractClassLog } from '../logs/index.js';
|
|
4
3
|
import type { ScopedL2ToL1Message } from '../messaging/l2_to_l1_message.js';
|
|
5
4
|
/**
|
|
6
5
|
* Computes a hash of a given verification key.
|
|
@@ -73,5 +72,4 @@ export declare function computeL1ToL2MessageNullifier(contract: AztecAddress, me
|
|
|
73
72
|
* @returns Fr containing 248 bits of information of sha256 hash.
|
|
74
73
|
*/
|
|
75
74
|
export declare function siloL2ToL1Message(l2ToL1Message: ScopedL2ToL1Message, version: Fr, chainId: Fr): Fr;
|
|
76
|
-
export declare function siloContractClassLog(log: ContractClassLog, contract: AztecAddress): Promise<ContractClassLog>;
|
|
77
75
|
//# sourceMappingURL=hash.d.ts.map
|
package/dest/hash/hash.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/hash/hash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/hash/hash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E;;;;GAIG;AACH,w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ANGED
|
@@ -122,14 +122,3 @@ export async function computeL1ToL2MessageNullifier(contract, messageHash, secre
|
|
|
122
122
|
]);
|
|
123
123
|
return Fr.fromBuffer(sha256Trunc(preimage));
|
|
124
124
|
}
|
|
125
|
-
export async function siloContractClassLog(log, contract) {
|
|
126
|
-
const innerLog = log.clone();
|
|
127
|
-
if (contract.isZero()) {
|
|
128
|
-
return innerLog;
|
|
129
|
-
}
|
|
130
|
-
innerLog.fields[0] = await poseidon2Hash([
|
|
131
|
-
contract,
|
|
132
|
-
innerLog.fields[0]
|
|
133
|
-
]);
|
|
134
|
-
return innerLog;
|
|
135
|
-
}
|
|
@@ -9,9 +9,9 @@ import { z } from 'zod';
|
|
|
9
9
|
return WorldStateRunningState;
|
|
10
10
|
}({});
|
|
11
11
|
export const WorldStateSyncStatusSchema = z.object({
|
|
12
|
-
finalisedBlockNumber: z.number(),
|
|
13
|
-
latestBlockNumber: z.number(),
|
|
12
|
+
finalisedBlockNumber: z.number().int().nonnegative(),
|
|
13
|
+
latestBlockNumber: z.number().int().nonnegative(),
|
|
14
14
|
latestBlockHash: z.string(),
|
|
15
|
-
oldestHistoricBlockNumber: z.number(),
|
|
15
|
+
oldestHistoricBlockNumber: z.number().int().nonnegative(),
|
|
16
16
|
treesAreSynched: z.boolean()
|
|
17
17
|
});
|
|
@@ -100,7 +100,8 @@ export declare class PrivateKernelTailCircuitPublicInputs {
|
|
|
100
100
|
getNonEmptyNullifiers(): Fr[];
|
|
101
101
|
getNonEmptyPrivateLogs(): import("../logs/private_log.js").PrivateLog[];
|
|
102
102
|
getNonEmptyContractClassLogsHashes(): import("./log_hash.js").ScopedLogHash[];
|
|
103
|
-
|
|
103
|
+
getEmittedContractClassLogsLength(): number;
|
|
104
|
+
getEmittedPrivateLogsLength(): number;
|
|
104
105
|
static fromBuffer(buffer: Buffer | BufferReader): PrivateKernelTailCircuitPublicInputs;
|
|
105
106
|
toBuffer(): Buffer;
|
|
106
107
|
static empty(): PrivateKernelTailCircuitPublicInputs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_kernel_tail_circuit_public_inputs.d.ts","sourceRoot":"","sources":["../../src/kernel/private_kernel_tail_circuit_public_inputs.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,wCAAwC,EAAE,MAAM,qDAAqD,CAAC;AAC/G,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,wCAAwC,EAAE,MAAM,qDAAqD,CAAC;AAC/G,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,qBAAa,uCAAuC;IAEhD;;OAEG;IACI,4BAA4B,EAAE,8BAA8B;IACnE;;OAEG;IACI,yBAAyB,EAAE,8BAA8B;IAChE;;OAEG;IACI,yBAAyB,EAAE,iBAAiB;;IAXnD;;OAEG;IACI,4BAA4B,EAAE,8BAA8B;IACnE;;OAEG;IACI,yBAAyB,EAAE,8BAA8B;IAChE;;OAEG;IACI,yBAAyB,EAAE,iBAAiB;IAGrD,OAAO;IAQP,IAAI,UAAU,YAEb;IAED,IAAI,aAAa,YAEhB;IAED,IAAI,aAAa,YAEhB;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,uCAAuC;IASzF,QAAQ;IAQR,MAAM,CAAC,KAAK;CAOb;AAED,qBAAa,uCAAuC;IAC/B,GAAG,EAAE,8BAA8B;gBAAnC,GAAG,EAAE,8BAA8B;IAEtD,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,uCAAuC;IAKzF,OAAO;IAIP,QAAQ;IAIR,MAAM,CAAC,KAAK;CAGb;AAED,qBAAa,oCAAoC;IAE7C;;OAEG;IACI,SAAS,EAAE,cAAc;IACzB,wBAAwB,EAAE,wBAAwB;IACzD;;;OAGG;IACI,OAAO,EAAE,GAAG;IACnB;;OAEG;IACI,QAAQ,EAAE,YAAY;IAEtB,SAAS,CAAC;IACV,SAAS,CAAC;;IAhBjB;;OAEG;IACI,SAAS,EAAE,cAAc,EACzB,wBAAwB,EAAE,wBAAwB;IACzD;;;OAGG;IACI,OAAO,EAAE,GAAG;IACnB;;OAEG;IACI,QAAQ,EAAE,YAAY,EAEtB,SAAS,CAAC,qDAAyC,EACnD,SAAS,CAAC,qDAAyC;IAY5D,MAAM,KAAK,MAAM,6EAEhB;IAED,MAAM;IAIN,OAAO;IAUP,0CAA0C;IAe1C,0CAA0C;IAmB1C,0BAA0B;IAQ1B,uCAAuC;IAIvC,oCAAoC;IAIpC,4BAA4B;IAI5B,kCAAkC;IAMlC,+BAA+B;IAI/B,4BAA4B;IAK5B,qBAAqB;IAUrB,qBAAqB;IAUrB,sBAAsB;IAUtB,kCAAkC;IAUlC,
|
|
1
|
+
{"version":3,"file":"private_kernel_tail_circuit_public_inputs.d.ts","sourceRoot":"","sources":["../../src/kernel/private_kernel_tail_circuit_public_inputs.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE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AAwB,EAAE,wBAAwB;IACzD;;;OAGG;IACI,OAAO,EAAE,GAAG;IACnB;;OAEG;IACI,QAAQ,EAAE,YAAY,EAEtB,SAAS,CAAC,qDAAyC,EACnD,SAAS,CAAC,qDAAyC;IAY5D,MAAM,KAAK,MAAM,6EAEhB;IAED,MAAM;IAIN,OAAO;IAUP,0CAA0C;IAe1C,0CAA0C;IAmB1C,0BAA0B;IAQ1B,uCAAuC;IAIvC,oCAAoC;IAIpC,4BAA4B;IAI5B,kCAAkC;IAMlC,+BAA+B;IAI/B,4BAA4B;IAK5B,qBAAqB;IAUrB,qBAAqB;IAUrB,sBAAsB;IAUtB,kCAAkC;IAUlC,iCAAiC;IAIjC,2BAA2B;IAI3B,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,oCAAoC;IAatF,QAAQ;IAYR,MAAM,CAAC,KAAK;IAWZ;;;;OAIG;IACH,MAAM,CAAC,kBAAkB;CAY1B"}
|
|
@@ -156,9 +156,12 @@ export class PrivateKernelTailCircuitPublicInputs {
|
|
|
156
156
|
const contractClassLogsHashes = this.forPublic ? mergeAccumulatedData(this.forPublic.nonRevertibleAccumulatedData.contractClassLogsHashes, this.forPublic.revertibleAccumulatedData.contractClassLogsHashes) : this.forRollup.end.contractClassLogsHashes;
|
|
157
157
|
return contractClassLogsHashes.filter((h)=>!h.isEmpty());
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
getEmittedContractClassLogsLength() {
|
|
160
160
|
return this.getNonEmptyContractClassLogsHashes().reduce((total, log)=>total + log.logHash.length, 0);
|
|
161
161
|
}
|
|
162
|
+
getEmittedPrivateLogsLength() {
|
|
163
|
+
return this.getNonEmptyPrivateLogs().reduce((total, log)=>total + log.getEmittedLength(), 0);
|
|
164
|
+
}
|
|
162
165
|
static fromBuffer(buffer) {
|
|
163
166
|
const reader = BufferReader.asReader(buffer);
|
|
164
167
|
const isForPublic = reader.readBoolean();
|
|
@@ -10,6 +10,7 @@ export declare class ContractClassLog {
|
|
|
10
10
|
contractAddress: AztecAddress;
|
|
11
11
|
fields: Fr[];
|
|
12
12
|
static SIZE_IN_BYTES: number;
|
|
13
|
+
unsiloedFirstField?: Fr | undefined;
|
|
13
14
|
constructor(contractAddress: AztecAddress, fields: Fr[]);
|
|
14
15
|
toFields(): Fr[];
|
|
15
16
|
static fromFields(fields: Fr[] | FieldReader): ContractClassLog;
|
|
@@ -21,6 +22,9 @@ export declare class ContractClassLog {
|
|
|
21
22
|
static random(): Promise<ContractClassLog>;
|
|
22
23
|
getEmittedLength(): number;
|
|
23
24
|
getEmittedFields(): Fr[];
|
|
25
|
+
setUnsiloedFirstField(field: Fr): void;
|
|
26
|
+
toUnsiloed(): ContractClassLog;
|
|
27
|
+
silo(): Promise<ContractClassLog>;
|
|
24
28
|
hash(): Promise<Fr>;
|
|
25
29
|
static get schema(): z.ZodEffects<z.ZodObject<{
|
|
26
30
|
contractAddress: import("@aztec/foundation/schemas").ZodFor<AztecAddress>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_class_log.d.ts","sourceRoot":"","sources":["../../src/logs/contract_class_log.ts"],"names":[],"mappings":";;;AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAE3F,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,qBAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"contract_class_log.d.ts","sourceRoot":"","sources":["../../src/logs/contract_class_log.ts"],"names":[],"mappings":";;;AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAE3F,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,qBAAa,gBAAgB;IAOR,eAAe,EAAE,YAAY;IAAS,MAAM,EAAE,EAAE,EAAE;IANrE,MAAM,CAAC,aAAa,SAAwD;IAErE,kBAAkB,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;gBAIxB,eAAe,EAAE,YAAY,EAAS,MAAM,EAAE,EAAE,EAAE;IAQrE,QAAQ,IAAI,EAAE,EAAE;IAIhB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;IAU5C,OAAO;IAIP,MAAM,CAAC,KAAK;IAIZ,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAW/C,KAAK;WAIQ,MAAM;IAWnB,gBAAgB;IAOhB,gBAAgB;IAKhB,qBAAqB,CAAC,KAAK,EAAE,EAAE;IAI/B,UAAU;IAQJ,IAAI;IAUJ,IAAI;IAIV,MAAM,KAAK,MAAM;;;;;;;;;;;;OAOhB;IAED,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM;CAK3B"}
|
|
@@ -10,6 +10,8 @@ export class ContractClassLog {
|
|
|
10
10
|
contractAddress;
|
|
11
11
|
fields;
|
|
12
12
|
static SIZE_IN_BYTES = Fr.SIZE_IN_BYTES * CONTRACT_CLASS_LOG_SIZE_IN_FIELDS;
|
|
13
|
+
// Keeps original first field pre-siloing. Only set by silo().
|
|
14
|
+
unsiloedFirstField;
|
|
13
15
|
// Below line gives error 'Type instantiation is excessively deep and possibly infinite. ts(2589)'
|
|
14
16
|
// public fields: Tuple<Fr, typeof CONTRACT_CLASS_LOG_DATA_SIZE_IN_FIELDS>
|
|
15
17
|
constructor(contractAddress, fields){
|
|
@@ -71,21 +73,40 @@ export class ContractClassLog {
|
|
|
71
73
|
}
|
|
72
74
|
getEmittedLength() {
|
|
73
75
|
// This assumes that we cut trailing zeroes from the end of the log. In ts, these will always be added back.
|
|
74
|
-
// Does not include address
|
|
76
|
+
// Does not include address or length prefix.
|
|
77
|
+
// Note: Unlike public logs, address is not included here because it is not included in the log itself.
|
|
75
78
|
return this.getEmittedFields().length;
|
|
76
79
|
}
|
|
77
80
|
getEmittedFields() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const lastNonZeroIndex = this.fields.findLastIndex((f)=>!f.isZero());
|
|
82
|
+
return this.fields.slice(0, lastNonZeroIndex + 1);
|
|
83
|
+
}
|
|
84
|
+
setUnsiloedFirstField(field) {
|
|
85
|
+
this.unsiloedFirstField = field;
|
|
86
|
+
}
|
|
87
|
+
toUnsiloed() {
|
|
88
|
+
if (this.unsiloedFirstField) {
|
|
89
|
+
return new ContractClassLog(this.contractAddress, [
|
|
90
|
+
this.unsiloedFirstField
|
|
91
|
+
].concat(this.fields.slice(1)));
|
|
92
|
+
} else {
|
|
93
|
+
return this;
|
|
84
94
|
}
|
|
85
|
-
|
|
95
|
+
}
|
|
96
|
+
async silo() {
|
|
97
|
+
const innerLog = this.clone();
|
|
98
|
+
if (innerLog.contractAddress.isZero()) {
|
|
99
|
+
return innerLog;
|
|
100
|
+
}
|
|
101
|
+
innerLog.setUnsiloedFirstField(innerLog.fields[0]);
|
|
102
|
+
innerLog.fields[0] = await poseidon2Hash([
|
|
103
|
+
innerLog.contractAddress,
|
|
104
|
+
innerLog.fields[0]
|
|
105
|
+
]);
|
|
106
|
+
return innerLog;
|
|
86
107
|
}
|
|
87
108
|
async hash() {
|
|
88
|
-
return await poseidon2Hash(this.
|
|
109
|
+
return await poseidon2Hash(this.fields);
|
|
89
110
|
}
|
|
90
111
|
static get schema() {
|
|
91
112
|
return z.object({
|
|
@@ -17,6 +17,8 @@ export declare class PrivateLog {
|
|
|
17
17
|
toBuffer(): Buffer;
|
|
18
18
|
static fromBuffer(buffer: Buffer | BufferReader): PrivateLog;
|
|
19
19
|
static random(): PrivateLog;
|
|
20
|
+
getEmittedLength(): number;
|
|
21
|
+
getEmittedFields(): Fr[];
|
|
20
22
|
static get schema(): z.ZodEffects<z.ZodObject<{
|
|
21
23
|
fields: z.ZodArray<z.ZodType<Fr, any, string>, "many">;
|
|
22
24
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_log.d.ts","sourceRoot":"","sources":["../../src/logs/private_log.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,KAAK,EAAqB,MAAM,6BAA6B,CAAC;AAEvG,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qBAAa,UAAU;IAGF,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,0BAA0B,CAAC;IAFvE,MAAM,CAAC,aAAa,SAAiD;gBAElD,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,0BAA0B,CAAC;IAEvE,QAAQ,IAAI,EAAE,EAAE;IAIhB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;IAK5C,OAAO;IAIP,MAAM,CAAC,KAAK;IAIZ,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAK/C,MAAM,CAAC,MAAM;IAIb,MAAM,KAAK,MAAM;;;;;;;;OAMhB;IAED,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM;CAK3B"}
|
|
1
|
+
{"version":3,"file":"private_log.d.ts","sourceRoot":"","sources":["../../src/logs/private_log.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,KAAK,EAAqB,MAAM,6BAA6B,CAAC;AAEvG,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qBAAa,UAAU;IAGF,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,0BAA0B,CAAC;IAFvE,MAAM,CAAC,aAAa,SAAiD;gBAElD,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,0BAA0B,CAAC;IAEvE,QAAQ,IAAI,EAAE,EAAE;IAIhB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;IAK5C,OAAO;IAIP,MAAM,CAAC,KAAK;IAIZ,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAK/C,MAAM,CAAC,MAAM;IAIb,gBAAgB;IAMhB,gBAAgB;IAKhB,MAAM,KAAK,MAAM;;;;;;;;OAMhB;IAED,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM;CAK3B"}
|
package/dest/logs/private_log.js
CHANGED
|
@@ -34,6 +34,15 @@ export class PrivateLog {
|
|
|
34
34
|
static random() {
|
|
35
35
|
return new PrivateLog(makeTuple(PRIVATE_LOG_SIZE_IN_FIELDS, Fr.random));
|
|
36
36
|
}
|
|
37
|
+
getEmittedLength() {
|
|
38
|
+
// This assumes that we cut trailing zeroes from the end of the log. In ts, these will always be added back.
|
|
39
|
+
// Does not include length prefix.
|
|
40
|
+
return this.getEmittedFields().length;
|
|
41
|
+
}
|
|
42
|
+
getEmittedFields() {
|
|
43
|
+
const lastNonZeroIndex = this.fields.findLastIndex((f)=>!f.isZero());
|
|
44
|
+
return this.fields.slice(0, lastNonZeroIndex + 1);
|
|
45
|
+
}
|
|
37
46
|
static get schema() {
|
|
38
47
|
return z.object({
|
|
39
48
|
fields: z.array(schemas.Fr)
|
|
@@ -21,6 +21,8 @@ export declare class PublicLog {
|
|
|
21
21
|
toBuffer(): Buffer;
|
|
22
22
|
static fromBuffer(buffer: Buffer | BufferReader): PublicLog;
|
|
23
23
|
static random(): Promise<PublicLog>;
|
|
24
|
+
getEmittedLength(): number;
|
|
25
|
+
getEmittedFields(): Fr[];
|
|
24
26
|
equals(other: this): boolean;
|
|
25
27
|
toHumanReadable(): string;
|
|
26
28
|
static get schema(): ZodFor<PublicLog>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_log.d.ts","sourceRoot":"","sources":["../../src/logs/public_log.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,8BAA8B,EAA6B,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,KAAK,QAAQ,EAAa,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,KAAK,KAAK,EAGX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,qBAAa,SAAS;IAGD,eAAe,EAAE,YAAY;IAAS,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,8BAA8B,CAAC;IAF9G,MAAM,CAAC,aAAa,SAAgD;gBAEjD,eAAe,EAAE,YAAY,EAAS,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,8BAA8B,CAAC;IAE9G,QAAQ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,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC;IAI5C,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;IAK5C,OAAO;IAIP,MAAM,CAAC,KAAK;IAIZ,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;WAKlC,MAAM;IAInB,gBAAgB;IAMhB,gBAAgB;IAMhB,MAAM,CAAC,KAAK,EAAE,IAAI;IAOlB,eAAe,IAAI,MAAM;IAIzB,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAOrC;IAED,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM;CAM3B"}
|
package/dest/logs/public_log.js
CHANGED
|
@@ -43,6 +43,16 @@ export class PublicLog {
|
|
|
43
43
|
static async random() {
|
|
44
44
|
return new PublicLog(await AztecAddress.random(), makeTuple(PUBLIC_LOG_DATA_SIZE_IN_FIELDS, Fr.random));
|
|
45
45
|
}
|
|
46
|
+
getEmittedLength() {
|
|
47
|
+
// This assumes that we cut trailing zeroes from the end of the log. In ts, these will always be added back.
|
|
48
|
+
// Does not include length prefix.
|
|
49
|
+
return this.getEmittedFields().length;
|
|
50
|
+
}
|
|
51
|
+
getEmittedFields() {
|
|
52
|
+
const fields = this.toFields();
|
|
53
|
+
const lastNonZeroIndex = fields.findLastIndex((f)=>!f.isZero());
|
|
54
|
+
return fields.slice(0, lastNonZeroIndex + 1);
|
|
55
|
+
}
|
|
46
56
|
equals(other) {
|
|
47
57
|
return this.contractAddress.equals(other.contractAddress) && this.log.reduce((acc, field, i)=>acc && field.equals(other.log[i]), true);
|
|
48
58
|
}
|
|
@@ -18,7 +18,7 @@ export class L2ToL1Message {
|
|
|
18
18
|
return z.object({
|
|
19
19
|
recipient: schemas.EthAddress,
|
|
20
20
|
content: schemas.Fr,
|
|
21
|
-
counter: z.number()
|
|
21
|
+
counter: z.number().int().nonnegative()
|
|
22
22
|
}).transform(({ recipient, content, counter })=>new L2ToL1Message(recipient, content, counter));
|
|
23
23
|
}
|
|
24
24
|
/**
|
package/dest/tx/tx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../src/tx/tx.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAyD,MAAM,6BAA6B,CAAC;AAClH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../src/tx/tx.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAyD,MAAM,6BAA6B,CAAC;AAClH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,oCAAoC,EAAE,MAAM,wDAAwD,CAAC;AAC9G,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,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