Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions yarn-project/archiver/src/archiver/data_retrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ export async function processL2BlockProposedLogs(
};

retrievedBlocks.push({ ...block, l1 });
logger.trace(`Retrieved L2 block ${l2BlockNumber} from L1 tx ${log.transactionHash}`, {
l1BlockNumber: log.blockNumber,
l2BlockNumber,
archive: archive.toString(),
signatures: block.signatures.map(signature => signature.toString()),
});
} else {
logger.warn(`Ignoring L2 block ${l2BlockNumber} due to archive root mismatch`, {
actual: archive,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/e2e_p2p/gossip_network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('e2e_p2p_network', () => {
const dataStore = ((nodes[0] as AztecNodeService).getBlockSource() as Archiver).dataStore;
const [block] = await dataStore.getBlocks(blockNumber, blockNumber);
const payload = ConsensusPayload.fromBlock(block.block);
const attestations = block.signatures.map(sig => new BlockAttestation(payload, sig));
const attestations = block.signatures.filter(s => !s.isEmpty).map(sig => new BlockAttestation(payload, sig));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix for the issue

const signers = await Promise.all(attestations.map(att => att.getSender().then(s => s.toString())));
t.logger.info(`Attestation signers`, { signers });

Expand Down
10 changes: 8 additions & 2 deletions yarn-project/foundation/src/crypto/secp256k1-signer/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ export function addressFromPrivateKey(privateKey: Buffer): EthAddress {
* @returns The address.
*/
export function recoverAddress(hash: Buffer32, signature: Signature): EthAddress {
const publicKey = recoverPublicKey(hash, signature);
return publicKeyToAddress(publicKey);
try {
const publicKey = recoverPublicKey(hash, signature);
return publicKeyToAddress(publicKey);
} catch (err) {
throw new Error(
`Error recovering Ethereum address from hash ${hash.toString()} and signature ${signature.toString()}: ${err}`,
);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export class KvAttestationPool implements AttestationPool {
this.getAttestationKey(slotNumber, proposalId, address),
);

this.log.verbose(`Added attestation for slot ${slotNumber} from ${address}`);
this.log.verbose(`Added attestation for slot ${slotNumber.toBigInt()} from ${address}`, {
signature: attestation.signature.toString(),
});
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export class InMemoryAttestationPool implements AttestationPool {
const proposalAttestationMap = getProposalOrDefault(slotAttestationMap, proposalId);
proposalAttestationMap.set(address.toString(), attestation);

this.log.verbose(`Added attestation for slot ${slotNumber} from ${address}`);
this.log.verbose(`Added attestation for slot ${slotNumber.toBigInt()} from ${address}`, {
signature: attestation.signature.toString(),
});
}

// TODO: set these to pending or something ????
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Buffer32 } from '@aztec/foundation/buffer';
import { makeBlockProposal } from '@aztec/stdlib/testing';

import { generatePrivateKey } from 'viem/accounts';

import { LocalKeyStore } from '../key_store/local_key_store.js';
import { ValidationService } from './validation_service.js';

describe('ValidationService', () => {
let service: ValidationService;
let store: LocalKeyStore;
let key: `0x${string}`;

beforeEach(() => {
key = generatePrivateKey();
store = new LocalKeyStore(Buffer32.fromString(key));
service = new ValidationService(store);
});

it('creates a proposal', async () => {
const {
payload: { header, archive, txHashes },
} = await makeBlockProposal();
const proposal = await service.createBlockProposal(header, archive, txHashes);
await expect(proposal.getSender()).resolves.toEqual(store.getAddress());
});

it('attests to proposal', async () => {
const proposal = await makeBlockProposal();
const attestation = await service.attestToProposal(proposal);
await expect(attestation.getSender()).resolves.toEqual(store.getAddress());
});
});