Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(val): reex #9768

Merged
merged 170 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
b51e908
feat: cleanup publisher
LHerskind Aug 22, 2024
da2eb7a
refactor: get rid of timetraveler from l1-publisher
LHerskind Aug 28, 2024
3388966
feat: revert if timestamp in future
LHerskind Aug 28, 2024
13a60a3
feat: including txhashes explicitly in the rollup attestations
Maddiaa0 Aug 29, 2024
86026f2
temp
Maddiaa0 Aug 30, 2024
f3eac5b
Merge branch 'master' into md/check-tx-requests-before-signing
Maddiaa0 Aug 30, 2024
fc7a04a
temp
Maddiaa0 Aug 30, 2024
9eed298
temp
Maddiaa0 Sep 2, 2024
cc09455
temp
Maddiaa0 Sep 2, 2024
06f950f
Merge branch 'master' into md/check-tx-requests-before-signing
Maddiaa0 Sep 2, 2024
4727cd9
temp: get passing with txhash payloads
Maddiaa0 Sep 3, 2024
b4c2a46
fix: make sure transactions are available in the tx pool
Maddiaa0 Sep 5, 2024
4a8d178
chore: remove logs
Maddiaa0 Sep 5, 2024
b4324fc
fmt
Maddiaa0 Sep 5, 2024
052641a
Merge branch 'master' into md/check-tx-requests-before-signing
Maddiaa0 Sep 5, 2024
a803a94
🪿
Maddiaa0 Sep 5, 2024
164c117
chore: validator tests
Maddiaa0 Sep 6, 2024
27da59d
Add timeouts to individual reqresp connections
Maddiaa0 Sep 6, 2024
9e7d2d8
fix
Maddiaa0 Sep 6, 2024
3c8e1b9
chore: include tests for specific error messages
Maddiaa0 Sep 6, 2024
9a738e5
fmt
Maddiaa0 Sep 6, 2024
c10260c
Merge branch 'master' into md/check-tx-requests-before-signing
Maddiaa0 Sep 6, 2024
045af5a
clean
Maddiaa0 Sep 6, 2024
73d26ec
🧹
Maddiaa0 Sep 6, 2024
d358228
chore: fix sequencing tests
Maddiaa0 Sep 7, 2024
4b31953
Merge branch 'master' into md/check-tx-requests-before-signing
Maddiaa0 Sep 7, 2024
2f82a8f
Merge branch 'md/check-tx-requests-before-signing' into md/09-06-add_…
Maddiaa0 Sep 7, 2024
f673593
fmt
Maddiaa0 Sep 7, 2024
a15ab17
fmt
Maddiaa0 Sep 7, 2024
2e3f80b
fmt solidity
Maddiaa0 Sep 7, 2024
ae2a05e
Merge branch 'md/check-tx-requests-before-signing' into md/09-06-add_…
Maddiaa0 Sep 7, 2024
5734006
Merge branch 'master' into md/check-tx-requests-before-signing
Maddiaa0 Sep 7, 2024
1bde1fe
fix: test hash
Maddiaa0 Sep 8, 2024
c775b26
Merge branch 'md/check-tx-requests-before-signing' into md/09-06-add_…
Maddiaa0 Sep 8, 2024
7a50a2b
exp: adjust test nodes
Maddiaa0 Sep 8, 2024
72f98bd
Merge branch 'md/check-tx-requests-before-signing' into md/09-06-add_…
Maddiaa0 Sep 8, 2024
998f38c
chore: add reqresp configuration values to p2p config
Maddiaa0 Sep 8, 2024
1c2b151
fix: use abi.encode vs encodePacked
Maddiaa0 Sep 11, 2024
e6e7f6b
fix
Maddiaa0 Sep 11, 2024
6f417fc
Merge branch 'master' into md/check-tx-requests-before-signing
Maddiaa0 Sep 11, 2024
cde6283
fix: merge fix
Maddiaa0 Sep 11, 2024
8290c99
fmt
Maddiaa0 Sep 11, 2024
b13ca93
Merge branch 'md/check-tx-requests-before-signing' into md/09-06-add_…
Maddiaa0 Sep 11, 2024
1452017
Merge branch 'master' into md/check-tx-requests-before-signing
Maddiaa0 Sep 11, 2024
120c9a3
Merge branch 'md/check-tx-requests-before-signing' into md/09-06-add_…
Maddiaa0 Sep 11, 2024
b189270
feat: initial rate limiter impl
Maddiaa0 Sep 11, 2024
9b90fe1
Merge branch 'master' into md/09-06-add_timeouts_to_individual_reqres…
Maddiaa0 Sep 11, 2024
b7d815f
Merge branch 'md/09-06-add_timeouts_to_individual_reqresp_connections…
Maddiaa0 Sep 11, 2024
97a6a14
feat: tests + documentation
Maddiaa0 Sep 11, 2024
0e22558
test: add to reqresp.test.ts
Maddiaa0 Sep 11, 2024
b464dcf
Merge branch 'master' into md/add-rate-limits-to-reqresp-peers
Maddiaa0 Sep 11, 2024
d0da214
fix: add todo pr number
Maddiaa0 Sep 11, 2024
2b46268
feat: introduce new light signer
Maddiaa0 Sep 12, 2024
65d009a
chore: migrations
Maddiaa0 Sep 12, 2024
69aa4a0
chore: proliferate
Maddiaa0 Sep 12, 2024
d109853
chore: remove signature lib from leonidas
Maddiaa0 Sep 12, 2024
d3cf4b8
fmt
Maddiaa0 Sep 12, 2024
dc06395
Merge branch 'master' into md/replace-viem-in-validator
Maddiaa0 Sep 13, 2024
d762096
fmt + fix test
Maddiaa0 Sep 13, 2024
afb46ca
fmt
Maddiaa0 Sep 13, 2024
37929f5
document secp256 helpers
Maddiaa0 Sep 13, 2024
1cb6687
clean
Maddiaa0 Sep 13, 2024
62b7c72
clean
Maddiaa0 Sep 13, 2024
421470e
fix: validator pk validation
Maddiaa0 Sep 16, 2024
f0f87a4
fix: reinstante eip712
Maddiaa0 Sep 16, 2024
40303d0
Merge branch 'master' into md/replace-viem-in-validator
Maddiaa0 Sep 16, 2024
7a33bef
refactor: remove multiple public dbs
Maddiaa0 Sep 16, 2024
9ec4fb1
fix
Maddiaa0 Sep 16, 2024
6f35ee8
fix
Maddiaa0 Sep 16, 2024
2e80f83
chore: make phase manager less noisy
Maddiaa0 Sep 16, 2024
3927ab9
feat: add re-ex to validator config
Maddiaa0 Sep 13, 2024
c80af0e
chore: rename header in avm to historicalHeader
Maddiaa0 Sep 20, 2024
d204f9d
Merge branch 'master' into md/validator-re-ex
Maddiaa0 Sep 20, 2024
e5377b3
temp
Maddiaa0 Sep 20, 2024
6931bdc
Merge branch 'master' into md/validator-re-ex
Maddiaa0 Sep 24, 2024
4c6a2d3
feat: validator's sync then re-ex
Maddiaa0 Sep 24, 2024
a7124ae
add: reex test
Maddiaa0 Sep 25, 2024
7f927f9
use spam contract to test re-ex
Maddiaa0 Sep 25, 2024
31e53c8
Merge branch 'master' into md/validator-re-ex
Maddiaa0 Sep 30, 2024
4023746
temp
Maddiaa0 Sep 30, 2024
a7416ad
temp
Maddiaa0 Sep 30, 2024
c848c89
feat: snapshotting for e2e p2p tests
Maddiaa0 Sep 30, 2024
c55bb14
fmt
Maddiaa0 Sep 30, 2024
b678b89
Merge branch 'master' into md/e2e-p2p-snapshots
Maddiaa0 Oct 1, 2024
d72ee95
fix
Maddiaa0 Oct 1, 2024
3342623
fmt
Maddiaa0 Oct 1, 2024
08398c3
Merge branch 'md/e2e-p2p-snapshots' into md/validator-re-ex
Maddiaa0 Oct 1, 2024
871a319
fix
Maddiaa0 Oct 1, 2024
20730dc
fix
Maddiaa0 Oct 1, 2024
b12f81f
Merge branch 'master' into md/e2e-p2p-snapshots
Maddiaa0 Oct 1, 2024
481537e
fix: enable additional params in e2e tests
Maddiaa0 Oct 1, 2024
f4ab1bd
fix: e2e_test script
Maddiaa0 Oct 1, 2024
0c26bf3
Merge branch 'md/e2e-p2p-snapshots' into md/validator-re-ex
Maddiaa0 Oct 1, 2024
a6ca6c7
chore: use new snapshotting infra
Maddiaa0 Oct 1, 2024
af95b82
fix: wait on validator deploymnets
Maddiaa0 Oct 1, 2024
500ab6f
temp
Maddiaa0 Oct 2, 2024
638c9bb
Merge branch 'master' into md/validator-re-ex
Maddiaa0 Oct 2, 2024
50e3ba7
fix: reex with nested calls
Maddiaa0 Oct 2, 2024
bd2d765
fmt
Maddiaa0 Oct 2, 2024
049fb75
Merge branch 'master' into md/e2e-p2p-snapshots
Maddiaa0 Oct 2, 2024
c6056cf
Merge branch 'md/e2e-p2p-snapshots' into md/validator-re-ex
Maddiaa0 Oct 2, 2024
6f0aaea
clean
Maddiaa0 Oct 2, 2024
5c50f07
fix: anvil failures issue
Maddiaa0 Oct 2, 2024
01e8eca
fmt
Maddiaa0 Oct 2, 2024
295ef75
Merge branch 'master' into md/e2e-p2p-snapshots
Maddiaa0 Oct 2, 2024
863457c
bump number of nodes in reqresp test
Maddiaa0 Oct 2, 2024
294ed73
Merge branch 'md/e2e-p2p-snapshots' into md/validator-re-ex
Maddiaa0 Oct 2, 2024
e416dd4
fix
Maddiaa0 Oct 2, 2024
9726085
Merge branch 'md/e2e-p2p-snapshots' into md/validator-re-ex
Maddiaa0 Oct 2, 2024
e653028
chore: further testing
Maddiaa0 Oct 3, 2024
bebea79
fmt
Maddiaa0 Oct 3, 2024
58861dc
chore: restore tx validator
Maddiaa0 Oct 3, 2024
367ae2e
fix: dependency cycle in circuits.js
Maddiaa0 Oct 3, 2024
8da85d4
fix: yarn prepare
Maddiaa0 Oct 3, 2024
7fd3b4f
nargo fmt
Maddiaa0 Oct 3, 2024
2f54025
chore: revert header changes
Maddiaa0 Oct 3, 2024
cde3d51
fmt
Maddiaa0 Oct 3, 2024
e1b8f88
remove processor
Maddiaa0 Nov 5, 2024
65260e7
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 5, 2024
0a591c3
feat: re-ex with shared block building logic
Maddiaa0 Nov 5, 2024
29c80ab
fmt test
Maddiaa0 Nov 6, 2024
6c1ef2e
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 6, 2024
f74945c
fmt
Maddiaa0 Nov 6, 2024
1202cd4
fix: remove duplicate
Maddiaa0 Nov 6, 2024
9ad8bac
fix: remove simulator from validator deps
Maddiaa0 Nov 6, 2024
0fd38f5
fix: clean
Maddiaa0 Nov 6, 2024
682539d
fix: reenable "flakey" p2p tests
Maddiaa0 Nov 6, 2024
8151e7b
fix: add e2e p2p to test config
Maddiaa0 Nov 6, 2024
b3f7f2c
chore: run cluster with reex
Maddiaa0 Nov 6, 2024
d7dec72
fix: validator script
Maddiaa0 Nov 7, 2024
22eab85
fix
Maddiaa0 Nov 7, 2024
d77b1f4
run seperately
Maddiaa0 Nov 7, 2024
1748069
fix: extend allowlist to matching prefixes
Maddiaa0 Nov 7, 2024
dbe9432
fix: shorten reqresp test name
Maddiaa0 Nov 7, 2024
4e76f7e
reex by default
Maddiaa0 Nov 7, 2024
f3fd818
fix fmt
Maddiaa0 Nov 7, 2024
fccfb7a
Merge branch 'md/re-enable-p2p' into md/dumb-re-ex
Maddiaa0 Nov 7, 2024
730803a
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 7, 2024
fe62a9f
fix: simplify matching script
Maddiaa0 Nov 7, 2024
028c637
fix: simplify labels
Maddiaa0 Nov 7, 2024
80db367
fix: sync to immediate block
Maddiaa0 Nov 7, 2024
1fac13d
Merge branch 'master' into md/re-enable-p2p
Maddiaa0 Nov 7, 2024
391899a
fmt
Maddiaa0 Nov 7, 2024
c31ea1d
Merge branch 'md/re-enable-p2p' into md/dumb-re-ex
Maddiaa0 Nov 7, 2024
dc82880
fix: add reex test
Maddiaa0 Nov 7, 2024
a912ecd
fix: pr comments, re-ex rejection test
Maddiaa0 Nov 8, 2024
037a79d
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 8, 2024
622fde4
fix: do not abbreviate reex
Maddiaa0 Nov 8, 2024
5eee7ea
fix
Maddiaa0 Nov 8, 2024
82f3946
fmt
Maddiaa0 Nov 8, 2024
108298b
fix
Maddiaa0 Nov 8, 2024
dd81a42
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 8, 2024
91c5f4d
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 8, 2024
2c997ed
merge fix
Maddiaa0 Nov 8, 2024
3779488
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 13, 2024
4649808
fmt
Maddiaa0 Nov 13, 2024
56237ed
fix: logging change
Maddiaa0 Nov 13, 2024
15a20d8
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 13, 2024
78f879c
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 21, 2024
f97ce86
fix: merge fix
Maddiaa0 Nov 21, 2024
19e17cc
fix: boxes
Maddiaa0 Nov 21, 2024
a040102
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 22, 2024
205e03b
fix: prover-agent.yaml syntax
ludamad Nov 22, 2024
66328f0
try to fix kind test runner
ludamad Nov 22, 2024
ca52e6d
Update ci.yml
ludamad Nov 22, 2024
b147e86
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 22, 2024
87dae4b
fix
Maddiaa0 Nov 22, 2024
36dd9d5
Revert "Update ci.yml"
Maddiaa0 Nov 22, 2024
2620c83
Revert "try to fix kind test runner"
Maddiaa0 Nov 22, 2024
dab2406
Merge branch 'master' into md/dumb-re-ex
Maddiaa0 Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion scripts/ci/get_e2e_jobs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ done
# Add the input labels and expanded matches to allow_list
allow_list+=("${input_labels[@]}" "${expanded_allow_list[@]}")


# Generate full list of targets, excluding specific entries, on one line
test_list=$(echo "${full_list[@]}" | grep -v 'base' | grep -v 'bench' | grep -v "network" | grep -v 'devnet' | xargs echo)

Expand Down
2 changes: 2 additions & 0 deletions spartan/aztec-network/templates/validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ spec:
value: "{{ .Values.validator.p2p.enabled }}"
- name: VALIDATOR_DISABLED
value: "{{ .Values.validator.validator.disabled }}"
- name: VALIDATOR_REEXECUTE
value: "{{ .Values.validator.validator.reexecute }}"
- name: SEQ_MAX_SECONDS_BETWEEN_BLOCKS
value: "{{ .Values.validator.sequencer.maxSecondsBetweenBlocks }}"
- name: SEQ_MIN_TX_PER_BLOCK
Expand Down
1 change: 1 addition & 0 deletions spartan/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ validator:
enforceTimeTable: true
validator:
disabled: false
reexecute: true
p2p:
enabled: "true"
startupProbe:
Expand Down
10 changes: 10 additions & 0 deletions yarn-project/circuits.js/src/structs/public_data_update_request.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { type AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr } from '@aztec/foundation/fields';
import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';

import { inspect } from 'util';

import { computePublicDataTreeLeafSlot } from '../hash/hash.js';
import { type ContractStorageUpdateRequest } from './contract_storage_update_request.js';

// TO BE REMOVED.
/**
* Write operations on the public data tree including the previous value.
Expand Down Expand Up @@ -75,6 +79,12 @@ export class PublicDataUpdateRequest {
return new PublicDataUpdateRequest(Fr.fromBuffer(reader), Fr.fromBuffer(reader), reader.readNumber());
}

static fromContractStorageUpdateRequest(contractAddress: AztecAddress, updateRequest: ContractStorageUpdateRequest) {
const leafSlot = computePublicDataTreeLeafSlot(contractAddress, updateRequest.storageSlot);

return new PublicDataUpdateRequest(leafSlot, updateRequest.newValue, updateRequest.counter);
}

static empty() {
return new PublicDataUpdateRequest(Fr.ZERO, Fr.ZERO, 0);
}
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/end-to-end/scripts/e2e_test_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ tests:
test_path: 'e2e_p2p/rediscovery.test.ts'
e2e_p2p_reqresp:
test_path: 'e2e_p2p/reqresp.test.ts'
e2e_p2p_reex:
test_path: 'e2e_p2p/reex.test.ts'
flakey_e2e_tests:
test_path: './src/flakey'
ignore_failures: true
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/end-to-end/src/e2e_p2p/gossip_network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ describe('e2e_p2p_network', () => {
throw new Error('Bootstrap node ENR is not available');
}

t.ctx.aztecNodeConfig.validatorReexecute = true;

// create our network of nodes and submit txs into each of them
// the number of txs per node and the number of txs per rollup
// should be set so that the only way for rollups to be built
Expand Down
52 changes: 50 additions & 2 deletions yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
import { type AztecNodeConfig, type AztecNodeService } from '@aztec/aztec-node';
import { EthCheatCodes } from '@aztec/aztec.js';
import { type AccountWalletWithSecretKey, EthCheatCodes } from '@aztec/aztec.js';
import { EthAddress } from '@aztec/circuits.js';
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum';
import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
import { RollupAbi } from '@aztec/l1-artifacts';
import { SpamContract } from '@aztec/noir-contracts.js';
import { type BootstrapNode } from '@aztec/p2p';
import { createBootstrapNodeFromPrivateKey } from '@aztec/p2p/mocks';

Expand All @@ -17,7 +19,12 @@ import {
generateNodePrivateKeys,
generatePeerIdPrivateKeys,
} from '../fixtures/setup_p2p_test.js';
import { type ISnapshotManager, type SubsystemsContext, createSnapshotManager } from '../fixtures/snapshot_manager.js';
import {
type ISnapshotManager,
type SubsystemsContext,
addAccounts,
createSnapshotManager,
} from '../fixtures/snapshot_manager.js';
import { getPrivateKeyFromIndex } from '../fixtures/utils.js';
import { getEndToEndTestTelemetryClient } from '../fixtures/with_telemetry_utils.js';

Expand All @@ -39,6 +46,10 @@ export class P2PNetworkTest {

public bootstrapNodeEnr: string = '';

// The re-execution test needs a wallet and a spam contract
public wallet?: AccountWalletWithSecretKey;
public spamContract?: SpamContract;

constructor(
testName: string,
public bootstrapNode: BootstrapNode,
Expand Down Expand Up @@ -108,12 +119,16 @@ export class P2PNetworkTest {
client: deployL1ContractsValues.walletClient,
});

this.logger.verbose(`Adding ${this.numberOfNodes} validators`);

const txHashes: `0x${string}`[] = [];
for (let i = 0; i < this.numberOfNodes; i++) {
const account = privateKeyToAccount(this.nodePrivateKeys[i]!);
this.logger.debug(`Adding ${account.address} as validator`);
const txHash = await rollup.write.addValidator([account.address]);
txHashes.push(txHash);

this.logger.debug(`Adding ${account.address} as validator`);
}

// Wait for all the transactions adding validators to be mined
Expand Down Expand Up @@ -148,6 +163,39 @@ export class P2PNetworkTest {
});
}

async setupAccount() {
await this.snapshotManager.snapshot(
'setup-account',
addAccounts(1, this.logger, false),
async ({ accountKeys }, ctx) => {
const accountManagers = accountKeys.map(ak => getSchnorrAccount(ctx.pxe, ak[0], ak[1], 1));
await Promise.all(accountManagers.map(a => a.register()));
const wallets = await Promise.all(accountManagers.map(a => a.getWallet()));
this.wallet = wallets[0];
},
);
}

async deploySpamContract() {
await this.snapshotManager.snapshot(
'add-spam-contract',
async () => {
if (!this.wallet) {
throw new Error('Call snapshot t.setupAccount before deploying account contract');
}

const spamContract = await SpamContract.deploy(this.wallet).send().deployed();
return { contractAddress: spamContract.address };
},
async ({ contractAddress }) => {
if (!this.wallet) {
throw new Error('Call snapshot t.setupAccount before deploying account contract');
}
this.spamContract = await SpamContract.at(contractAddress, this.wallet);
},
);
}

async removeInitialNode() {
await this.snapshotManager.snapshot(
'remove-inital-validator',
Expand Down
130 changes: 130 additions & 0 deletions yarn-project/end-to-end/src/e2e_p2p/reex.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import { type AztecNodeService } from '@aztec/aztec-node';
import { type SentTx, sleep } from '@aztec/aztec.js';

/* eslint-disable-next-line no-restricted-imports */
import { BlockProposal, SignatureDomainSeperator, getHashedSignaturePayload } from '@aztec/circuit-types';

import { beforeAll, describe, it, jest } from '@jest/globals';
import fs from 'fs';

import { createNodes } from '../fixtures/setup_p2p_test.js';
import { P2PNetworkTest } from './p2p_network.js';
import { submitComplexTxsTo } from './shared.js';

const NUM_NODES = 4;
const NUM_TXS_PER_NODE = 1;
const BOOT_NODE_UDP_PORT = 41000;

const DATA_DIR = './data/re-ex';

describe('e2e_p2p_reex', () => {
let t: P2PNetworkTest;
let nodes: AztecNodeService[];

beforeAll(async () => {
nodes = [];

t = await P2PNetworkTest.create({
testName: 'e2e_p2p_reex',
numberOfNodes: NUM_NODES,
basePort: BOOT_NODE_UDP_PORT,
});

t.logger.verbose('Setup account');
await t.setupAccount();

t.logger.verbose('Deploy spam contract');
await t.deploySpamContract();

t.logger.verbose('Apply base snapshots');
await t.applyBaseSnapshots();

t.logger.verbose('Setup nodes');
await t.setup();
});

afterAll(async () => {
// shutdown all nodes.
await t.stopNodes(nodes);
await t.teardown();
for (let i = 0; i < NUM_NODES; i++) {
fs.rmSync(`${DATA_DIR}-${i}`, { recursive: true, force: true });
}
});

it('validators should re-execute transactions before attesting', async () => {
// create the bootstrap node for the network
if (!t.bootstrapNodeEnr) {
throw new Error('Bootstrap node ENR is not available');
}

t.ctx.aztecNodeConfig.validatorReexecute = true;

LHerskind marked this conversation as resolved.
Show resolved Hide resolved
nodes = await createNodes(
t.ctx.aztecNodeConfig,
t.peerIdPrivateKeys,
t.bootstrapNodeEnr,
NUM_NODES,
BOOT_NODE_UDP_PORT,
);

// Hook into the node and intercept re-execution logic, ensuring that it was infact called
const reExecutionSpies = [];
for (const node of nodes) {
// Make sure the nodes submit faulty proposals, in this case a faulty proposal is one where we remove one of the transactions
// Such that the calculated archive will be different!
jest.spyOn((node as any).p2pClient, 'broadcastProposal').mockImplementation(async (...args: unknown[]) => {
// We remove one of the transactions, therefore the block root will be different!
const proposal = args[0] as BlockProposal;
const { txHashes } = proposal.payload;

// We need to mutate the proposal, so we cast to any
(proposal.payload as any).txHashes = txHashes.slice(0, txHashes.length - 1);

// We sign over the proposal using the node's signing key
// Abusing javascript to access the nodes signing key
const signer = (node as any).sequencer.sequencer.validatorClient.validationService.keyStore;
const newProposal = new BlockProposal(
proposal.payload,
await signer.signMessage(getHashedSignaturePayload(proposal.payload, SignatureDomainSeperator.blockProposal)),
);

return (node as any).p2pClient.p2pService.propagate(newProposal);
});

// Store re-execution spys node -> sequencer Client -> seqeuncer -> validator
const spy = jest.spyOn((node as any).sequencer.sequencer.validatorClient, 'reExecuteTransactions');
reExecutionSpies.push(spy);
}

// wait a bit for peers to discover each other
await sleep(4000);

nodes.forEach(node => {
node.getSequencer()?.updateSequencerConfig({
minTxsPerBlock: NUM_TXS_PER_NODE,
maxTxsPerBlock: NUM_TXS_PER_NODE,
});
});
const txs = await submitComplexTxsTo(t.logger, t.spamContract!, NUM_TXS_PER_NODE);

// We ensure that the transactions are NOT mined
try {
await Promise.all(
txs.map(async (tx: SentTx, i: number) => {
t.logger.info(`Waiting for tx ${i}: ${await tx.getTxHash()} to be mined`);
return tx.wait();
}),
);
} catch (e) {
t.logger.info('Failed to mine all txs, as planned');
}

// Expect that all of the re-execution attempts failed with an invalid root
for (const spy of reExecutionSpies) {
for (const result of spy.mock.results) {
await expect(result.value).rejects.toThrow('Validator Error: Re-execution state mismatch');
}
}
});
});
27 changes: 26 additions & 1 deletion yarn-project/end-to-end/src/e2e_p2p/shared.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
import { type AztecNodeService } from '@aztec/aztec-node';
import { type DebugLogger } from '@aztec/aztec.js';
import { type DebugLogger, type SentTx } from '@aztec/aztec.js';
import { CompleteAddress, TxStatus } from '@aztec/aztec.js';
import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
import { type SpamContract } from '@aztec/noir-contracts.js';
import { type PXEService, createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe';

import { type NodeContext } from '../fixtures/setup_p2p_test.js';

// submits a set of transactions to the provided Private eXecution Environment (PXE)
export const submitComplexTxsTo = async (logger: DebugLogger, spamContract: SpamContract, numTxs: number) => {
const txs: SentTx[] = [];

const seed = 1234n;
const spamCount = 15;
for (let i = 0; i < numTxs; i++) {
const tx = spamContract.methods.spam(seed + BigInt(i * spamCount), spamCount, false).send();
const txHash = await tx.getTxHash();

logger.info(`Tx sent with hash ${txHash}`);
const receipt = await tx.getReceipt();
expect(receipt).toEqual(
expect.objectContaining({
status: TxStatus.PENDING,
error: '',
}),
);
logger.info(`Receipt received for ${txHash}`);
txs.push(tx);
}
return txs;
};

// creates an instance of the PXE and submit a given number of transactions to it.
export const createPXEServiceAndSubmitTransactions = async (
logger: DebugLogger,
Expand Down
1 change: 0 additions & 1 deletion yarn-project/end-to-end/src/e2e_synching.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*
* To run the Setup run with the `AZTEC_GENERATE_TEST_DATA=1` flag. Without
* this flag, we will run in execution.
*
* There is functionality to store the `stats` of a sync, but currently we
* will simply be writing it to the log instead.
*
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/fixtures/snapshot_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ async function setupFromFresh(
opts: SetupOptions = {},
deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {
assumeProvenThrough: Number.MAX_SAFE_INTEGER,
initialValidators: [],
},
): Promise<SubsystemsContext> {
logger.verbose(`Initializing state...`);
Expand Down Expand Up @@ -390,7 +391,6 @@ async function setupFromFresh(
async function setupFromState(statePath: string, logger: Logger): Promise<SubsystemsContext> {
logger.verbose(`Initializing with saved state at ${statePath}...`);

// Load config.
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
const aztecNodeConfig: AztecNodeConfig & SetupOptions = JSON.parse(
readFileSync(`${statePath}/aztec_node_config.json`, 'utf-8'),
Expand Down
1 change: 1 addition & 0 deletions yarn-project/foundation/src/config/env_var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export type EnvVar =
| 'VALIDATOR_ATTESTATIONS_WAIT_TIMEOUT_MS'
| 'VALIDATOR_DISABLED'
| 'VALIDATOR_PRIVATE_KEY'
| 'VALIDATOR_REEXECUTE'
| 'VERSION'
| 'WS_BLOCK_CHECK_INTERVAL_MS'
| 'WS_PROVEN_BLOCKS_ONLY'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export async function buildBaseRollupHints(
padArrayEnd(tx.txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map(n => n.toBuffer()),
NULLIFIER_SUBTREE_HEIGHT,
);

if (nullifierWitnessLeaves === undefined) {
throw new Error(`Could not craft nullifier batch insertion proofs`);
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/sequencer-client/src/block_builder/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class LightweightBlockBuilder implements BlockBuilder {
constructor(private db: MerkleTreeWriteOperations, private telemetry: TelemetryClient) {}

async startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void> {
this.logger.verbose('Starting new block', { numTxs, globalVariables, l1ToL2Messages });
this.logger.verbose('Starting new block', { numTxs, globalVariables: globalVariables.toJSON(), l1ToL2Messages });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

this.numTxs = numTxs;
this.globalVariables = globalVariables;
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
Expand Down
1 change: 1 addition & 0 deletions yarn-project/sequencer-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export * from './publisher/index.js';
export * from './sequencer/index.js';

// Used by the node to simulate public parts of transactions. Should these be moved to a shared library?
// ISSUE(#9832)
export * from './global_variable_builder/index.js';
Loading