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
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ describe('e2e_fees private_payment', () => {
});

// TODO(#7694): Remove this test once the lacking feature in TXE is implemented.
// TODO(#10775): Reenable, hit e.g. https://github.com/AztecProtocol/aztec-packages/actions/runs/12419409370/job/34675397831
it.skip('insufficient funded amount is correctly handled', async () => {
it('insufficient funded amount is correctly handled', async () => {
// We call arbitrary `private_get_name(...)` function just to check the correct error is triggered.
await expect(
bananaCoin.methods.private_get_name().prove({
Expand Down
22 changes: 14 additions & 8 deletions yarn-project/kv-store/src/lmdb/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,20 @@ export class LmdbAztecArray<T> implements AztecArray<T>, AztecAsyncArray<T> {
}

*entries(): IterableIterator<[number, T]> {
const values = this.#db.getRange({
start: this.#slot(0),
limit: this.length,
});

for (const { key, value } of values) {
const index = key[3];
yield [index, value];
const transaction = this.#db.useReadTransaction();
try {
const values = this.#db.getRange({
start: this.#slot(0),
limit: this.length,
transaction,
});

for (const { key, value } of values) {
const index = key[3];
yield [index, value];
}
} finally {
transaction.done();
}
}

Expand Down
80 changes: 47 additions & 33 deletions yarn-project/kv-store/src/lmdb/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ export class LmdbAztecMap<K extends Key, V> implements AztecMultiMap<K, V>, Azte
}

*getValues(key: K): IterableIterator<V> {
const values = this.db.getValues(this.slot(key));
for (const value of values) {
yield value?.[1];
const transaction = this.db.useReadTransaction();
try {
const values = this.db.getValues(this.slot(key), {
transaction,
});
for (const value of values) {
yield value?.[1];
}
} finally {
transaction.done();
}
}

Expand Down Expand Up @@ -88,38 +95,45 @@ export class LmdbAztecMap<K extends Key, V> implements AztecMultiMap<K, V>, Azte
}

*entries(range: Range<K> = {}): IterableIterator<[K, V]> {
const { reverse = false, limit } = range;
// LMDB has a quirk where it expects start > end when reverse=true
// in that case, we need to swap the start and end sentinels
const start = reverse
? range.end
? this.slot(range.end)
: this.endSentinel
: range.start
? this.slot(range.start)
: this.startSentinel;

const end = reverse
? range.start
const transaction = this.db.useReadTransaction();

try {
const { reverse = false, limit } = range;
// LMDB has a quirk where it expects start > end when reverse=true
// in that case, we need to swap the start and end sentinels
const start = reverse
? range.end
? this.slot(range.end)
: this.endSentinel
: range.start
? this.slot(range.start)
: this.startSentinel
: range.end
? this.slot(range.end)
: this.endSentinel;
: this.startSentinel;

const lmdbRange: RangeOptions = {
start,
end,
reverse,
limit,
};

const iterator = this.db.getRange(lmdbRange);

for (const {
value: [key, value],
} of iterator) {
yield [key, value];
const end = reverse
? range.start
? this.slot(range.start)
: this.startSentinel
: range.end
? this.slot(range.end)
: this.endSentinel;

const lmdbRange: RangeOptions = {
start,
end,
reverse,
limit,
transaction,
};

const iterator = this.db.getRange(lmdbRange);

for (const {
value: [key, value],
} of iterator) {
yield [key, value];
}
} finally {
transaction.done();
}
}

Expand Down