Skip to content

Commit 8e28dcf

Browse files
spypsyaztec-bot
authored andcommitted
fix(stdlib): correct NoteDao size (#22068)
1 parent 03a9107 commit 8e28dcf

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

yarn-project/stdlib/src/note/note_dao.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ describe('NoteDao', () => {
77
expect(NoteDao.fromBuffer(buf)).toEqual(note);
88
});
99

10+
it('reports the serialized size', async () => {
11+
const note = await NoteDao.random();
12+
13+
expect(note.getSize()).toBe(note.toBuffer().length);
14+
});
15+
1016
describe('equals', () => {
1117
it('returns true for identical NoteDao instances', async () => {
1218
const note1 = await NoteDao.random();

yarn-project/stdlib/src/note/note_dao.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { BlockNumber } from '@aztec/foundation/branded-types';
22
import { Fr } from '@aztec/foundation/curves/bn254';
3-
import { Point } from '@aztec/foundation/curves/grumpkin';
43
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
54
import { AztecAddress } from '@aztec/stdlib/aztec-address';
65
import { Note } from '@aztec/stdlib/note';
@@ -148,9 +147,7 @@ export class NoteDao {
148147
* @returns - Its size in bytes.
149148
*/
150149
public getSize() {
151-
const noteSize = 4 + this.note.items.length * Fr.SIZE_IN_BYTES;
152-
// 2 numbers for txIndexInBlock and noteIndexInTx (4 bytes each)
153-
return noteSize + AztecAddress.SIZE_IN_BYTES * 2 + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + 8;
150+
return this.toBuffer().length;
154151
}
155152

156153
static async random({

0 commit comments

Comments
 (0)