@xyo-network/chain-sdk 5.4.0 → 5.5.0
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/dist/browser/modules/services/simple/block/runner/SimpleBlockRunner.d.ts +19 -0
- package/dist/browser/modules/services/simple/block/runner/SimpleBlockRunner.d.ts.map +1 -1
- package/dist/browser/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.d.ts +1 -1
- package/dist/browser/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.d.ts.map +1 -1
- package/dist/browser/modules/slashing/index/foldSlashIndex.d.ts +24 -8
- package/dist/browser/modules/slashing/index/foldSlashIndex.d.ts.map +1 -1
- package/dist/browser/modules/slashing/verify/verifyInvalidBlock.d.ts.map +1 -1
- package/dist/browser/modules/validation/hydratedBlockState/validators/RequiredBalance.d.ts.map +1 -1
- package/dist/neutral/modules/services/simple/block/runner/SimpleBlockRunner.d.ts +19 -0
- package/dist/neutral/modules/services/simple/block/runner/SimpleBlockRunner.d.ts.map +1 -1
- package/dist/neutral/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.d.ts +1 -1
- package/dist/neutral/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.d.ts.map +1 -1
- package/dist/neutral/modules/slashing/index/foldSlashIndex.d.ts +24 -8
- package/dist/neutral/modules/slashing/index/foldSlashIndex.d.ts.map +1 -1
- package/dist/neutral/modules/slashing/verify/verifyInvalidBlock.d.ts.map +1 -1
- package/dist/neutral/modules/validation/hydratedBlockState/validators/RequiredBalance.d.ts.map +1 -1
- package/dist/neutral/services.mjs +38 -12
- package/dist/neutral/services.mjs.map +2 -2
- package/dist/neutral/slashing.mjs +52 -20
- package/dist/neutral/slashing.mjs.map +3 -3
- package/dist/neutral/validation.mjs +6 -4
- package/dist/neutral/validation.mjs.map +2 -2
- package/dist/node/modules/services/simple/block/runner/SimpleBlockRunner.d.ts +19 -0
- package/dist/node/modules/services/simple/block/runner/SimpleBlockRunner.d.ts.map +1 -1
- package/dist/node/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.d.ts +1 -1
- package/dist/node/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.d.ts.map +1 -1
- package/dist/node/modules/slashing/index/foldSlashIndex.d.ts +24 -8
- package/dist/node/modules/slashing/index/foldSlashIndex.d.ts.map +1 -1
- package/dist/node/modules/slashing/verify/verifyInvalidBlock.d.ts.map +1 -1
- package/dist/node/modules/validation/hydratedBlockState/validators/RequiredBalance.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -225,6 +225,25 @@ export declare class SimpleBlockRunner extends AbstractCreatableProvider<SimpleB
|
|
|
225
225
|
* @returns The prior candidate's signed data hash, or undefined when there is none
|
|
226
226
|
*/
|
|
227
227
|
private previousOwnCandidateHash;
|
|
228
|
+
/**
|
|
229
|
+
* Balances for every distinct sender that has a paired transfer, read at `head` in one request.
|
|
230
|
+
*
|
|
231
|
+
* Senders are all known before any balance is needed and the lookups are independent, so they go
|
|
232
|
+
* out together. The previous shape awaited one `accountBalances([from])` per distinct sender
|
|
233
|
+
* inside the filter loop — a full round trip each wherever the viewer is bound over RPC, so the
|
|
234
|
+
* filter slowed in proportion to how busy the chain was, worst when candidates are contested.
|
|
235
|
+
*
|
|
236
|
+
* Reads are qualified to the parent `head`, matching the post-submit block validator
|
|
237
|
+
* (`RequiredBalanceBlockStateValidator` reads at `block[0].previous`). Unqualified reads resolved
|
|
238
|
+
* the viewer's *current* head per call, so the producer could admit a tx against a balance the
|
|
239
|
+
* validator would then reject — the wedge this filter exists to prevent — and successive senders
|
|
240
|
+
* could be read at different heads if the head moved mid-loop.
|
|
241
|
+
* @param head Hash of the parent block the candidate builds on
|
|
242
|
+
* @param txs The candidate transactions, in inclusion order
|
|
243
|
+
* @param transferByFrom Fee transfers keyed by sender, first transfer per sender
|
|
244
|
+
* @returns Balance at `head` per distinct sender, zero when the viewer omits one
|
|
245
|
+
*/
|
|
246
|
+
private readSenderBalances;
|
|
228
247
|
private rejectExhaustedBlock;
|
|
229
248
|
private rejectWrongChainTransactions;
|
|
230
249
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleBlockRunner.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/services/simple/block/runner/SimpleBlockRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAQ,UAAU,EAC1B,MAAM,iBAAiB,CAAA;AAKxB,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAAE,YAAY,EAChC,MAAM,kBAAkB,CAAA;AAKzB,OAAO,KAAK,EACV,oBAAoB,EAAuB,iBAAiB,EACxC,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EACzE,gBAAgB,EAAE,uBAAuB,EACzC,qBAAqB,EACrB,kBAAkB,EAClB,oCAAoC,EAAgC,aAAa,EACjF,mCAAmC,EACnC,+BAA+B,EAClB,cAAc,EAAE,QAAQ,EACtC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,yBAAyB,EAQ1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAKlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAI3E,OAAO,KAAK,EAAE,gCAAgC,EAA+B,MAAM,uCAAuC,CAAA;AAG1H,uFAAuF;AACvF,UAAU,wBAAwB;IAChC,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,SAAU,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,mCAAmC,MAAM,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,iCAAiC,MAAM,CAAA;AAEpD,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACtE,4FAA4F;IAC5F,O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+B,GAAG,SAAS,CAAC;cAOtH,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"SimpleBlockRunner.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/services/simple/block/runner/SimpleBlockRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAQ,UAAU,EAC1B,MAAM,iBAAiB,CAAA;AAKxB,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAAE,YAAY,EAChC,MAAM,kBAAkB,CAAA;AAKzB,OAAO,KAAK,EACV,oBAAoB,EAAuB,iBAAiB,EACxC,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EACzE,gBAAgB,EAAE,uBAAuB,EACzC,qBAAqB,EACrB,kBAAkB,EAClB,oCAAoC,EAAgC,aAAa,EACjF,mCAAmC,EACnC,+BAA+B,EAClB,cAAc,EAAE,QAAQ,EACtC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,yBAAyB,EAQ1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAKlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAI3E,OAAO,KAAK,EAAE,gCAAgC,EAA+B,MAAM,uCAAuC,CAAA;AAG1H,uFAAuF;AACvF,UAAU,wBAAwB;IAChC,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,SAAU,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,mCAAmC,MAAM,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,iCAAiC,MAAM,CAAA;AAEpD,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACtE,4FAA4F;I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C,+BAA+B,GAAG,SAAS,CAAC;cAOtH,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAkB3E;;;;OAIG;IACH,SAAS,CAAC,wBAAwB,CAAC,IAAI,EAAE,YAAY,CAAC,iBAAiB,CAAC,GAAG,UAAU,CAAC,gBAAgB,GAAG,SAAS,CAAC;cAsBnG,qBAAqB,CAAC,IAAI,EAAE,YAAY,CAAC,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,EAAE,OAAO,EAAE,KAAK,UAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA8DtH,OAAO,CAAC,kBAAkB;YASZ,mBAAmB;IAyBjC;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;IAgBjC;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;YASd,cAAc;YAqDd,mBAAmB;IAUjC;;;;;;;;;;;OAWG;YACW,SAAS;IAevB;;;;;;;;;OASG;YACW,iBAAiB;YAMjB,UAAU;IAexB,OAAO,CAAC,4BAA4B;IAMpC;;;;;;;;;;;;;OAaG;YACW,wBAAwB;IAUtC;;;;;;;;;;;;;;;;;OAiBG;YACW,kBAAkB;YAWlB,oBAAoB;YAkBpB,4BAA4B;IAiC1C;;;;;;;;;;;;OAYG;YACW,iBAAiB;YASjB,yBAAyB;CAoExC"}
|
package/dist/browser/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const SIMPLE_BLOCK_RUNNER_INSTRUMENTATION_SINGLETON = "simpleBlockRunnerInstrumentation";
|
|
2
|
-
export declare const SimpleBlockRunnerTimingNames: readonly ["mempoolPendingBlocksFetch", "mempoolPendingTransactionsFetch"];
|
|
2
|
+
export declare const SimpleBlockRunnerTimingNames: readonly ["blockRewardTransfers", "mempoolPendingBlocksFetch", "mempoolPendingTransactionsFetch", "timePayloadGeneration"];
|
|
3
3
|
export type SimpleBlockRunnerTimingName = typeof SimpleBlockRunnerTimingNames[number];
|
|
4
4
|
/** Optional process-local observer for timings owned by SimpleBlockRunner. */
|
|
5
5
|
export interface SimpleBlockRunnerInstrumentation {
|
package/dist/browser/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleBlockRunnerInstrumentation.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6CAA6C,qCAAqC,CAAA;AAE/F,eAAO,MAAM,4BAA4B,
|
|
1
|
+
{"version":3,"file":"SimpleBlockRunnerInstrumentation.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6CAA6C,qCAAqC,CAAA;AAE/F,eAAO,MAAM,4BAA4B,4HAK/B,CAAA;AAEV,MAAM,MAAM,2BAA2B,GAAG,OAAO,4BAA4B,CAAC,MAAM,CAAC,CAAA;AAErF,8EAA8E;AAC9E,MAAM,WAAW,gCAAgC;IAC/C,YAAY,CAAC,IAAI,EAAE,2BAA2B,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1E;AAED,MAAM,WAAW,uCAAuC;IACtD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7C;AAED,wBAAgB,wCAAwC,CACtD,OAAO,EAAE,uCAAuC,EAChD,eAAe,EAAE,gCAAgC,GAChD,IAAI,CAEN;AAED,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,uCAAuC,GAC/C,gCAAgC,GAAG,SAAS,CAI9C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Hash, JsonObject } from '@ariestools/sdk';
|
|
2
|
-
import type { SignedHydratedBlockWithHashMeta, SlashIndexKeyRecord } from '@xyo-network/xl1-sdk';
|
|
2
|
+
import type { SignedHydratedBlockWithHashMeta, SlashIndexKeyRecord, SlashOutcome } from '@xyo-network/xl1-sdk';
|
|
3
3
|
/** One object to write, and whether it may ever be rewritten. */
|
|
4
4
|
export interface SlashIndexWrite {
|
|
5
5
|
/** True when the object is content-addressed and must never change once written. */
|
|
@@ -9,6 +9,23 @@ export interface SlashIndexWrite {
|
|
|
9
9
|
/** What goes there. */
|
|
10
10
|
value: JsonObject;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* A challenge or adjudication, and the report it answers.
|
|
14
|
+
*
|
|
15
|
+
* An adjudication carries its outcome. When the report is in an earlier batch, the writing pass
|
|
16
|
+
* files the verdict and its outcome together, and no later pass reads that verdict again, so an
|
|
17
|
+
* outcome left behind here could never be recovered.
|
|
18
|
+
*/
|
|
19
|
+
export type SlashIndexPendingLink = {
|
|
20
|
+
hash: Hash;
|
|
21
|
+
kind: 'adjudication';
|
|
22
|
+
outcome: SlashOutcome;
|
|
23
|
+
request: Hash;
|
|
24
|
+
} | {
|
|
25
|
+
hash: Hash;
|
|
26
|
+
kind: 'challenge';
|
|
27
|
+
request: Hash;
|
|
28
|
+
};
|
|
12
29
|
/** Everything one batch of finalized blocks contributes to the index. */
|
|
13
30
|
export interface SlashIndexDelta {
|
|
14
31
|
/** Producer aggregates: path to the offense keys seen for that producer. */
|
|
@@ -16,16 +33,15 @@ export interface SlashIndexDelta {
|
|
|
16
33
|
/** Per-offense aggregates, keyed by their path. */
|
|
17
34
|
keys: Map<string, SlashIndexKeyRecord>;
|
|
18
35
|
/**
|
|
19
|
-
*
|
|
36
|
+
* What the writing pass has to attach, in the order it was finalized: adjudications and
|
|
37
|
+
* challenges whose report was not in this batch, and every adjudication after the first such
|
|
38
|
+
* adjudication.
|
|
20
39
|
*
|
|
21
40
|
* Their offense cannot be resolved from the blocks alone — the report that names it is further
|
|
22
|
-
* back — so the writing pass resolves them against the published request records.
|
|
41
|
+
* back — so the writing pass resolves them against the published request records. Later
|
|
42
|
+
* adjudications wait behind the first so that every verdict is settled in finalized order.
|
|
23
43
|
*/
|
|
24
|
-
pending:
|
|
25
|
-
hash: Hash;
|
|
26
|
-
kind: 'adjudication' | 'challenge';
|
|
27
|
-
request: Hash;
|
|
28
|
-
}[];
|
|
44
|
+
pending: SlashIndexPendingLink[];
|
|
29
45
|
/** Content-addressed records, safe to skip when already present. */
|
|
30
46
|
records: SlashIndexWrite[];
|
|
31
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"foldSlashIndex.d.ts","sourceRoot":"","sources":["../../../../../src/modules/slashing/index/foldSlashIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEvD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"foldSlashIndex.d.ts","sourceRoot":"","sources":["../../../../../src/modules/slashing/index/foldSlashIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEvD,OAAO,KAAK,EACV,+BAA+B,EAAE,mBAAmB,EAAE,YAAY,EACnE,MAAM,sBAAsB,CAAA;AAS7B,iEAAiE;AACjE,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,SAAS,EAAE,OAAO,CAAA;IAClB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,uBAAuB;IACvB,KAAK,EAAE,UAAU,CAAA;CAClB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAC3B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,GAC1E;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,CAAA;AAEtD,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9B,mDAAmD;IACnD,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;IACtC;;;;;;;;OAQG;IACH,OAAO,EAAE,qBAAqB,EAAE,CAAA;IAChC,oEAAoE;IACpE,OAAO,EAAE,eAAe,EAAE,CAAA;CAC3B;AAWD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,+BAA+B,EAAE,GAAG,eAAe,CAOzF;AAyFD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,mBAAmB,GAAG,SAAS,EACzC,IAAI,EAAE,mBAAmB,GACxB,mBAAmB,CAcrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyInvalidBlock.d.ts","sourceRoot":"","sources":["../../../../../src/modules/slashing/verify/verifyInvalidBlock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verifyInvalidBlock.d.ts","sourceRoot":"","sources":["../../../../../src/modules/slashing/verify/verifyInvalidBlock.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,8BAA8B,CAAA;AAyFtF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBA+ChC,CAAA"}
|
package/dist/browser/modules/validation/hydratedBlockState/validators/RequiredBalance.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequiredBalance.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/validation/hydratedBlockState/validators/RequiredBalance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,oCAAoC,EAAE,MAAM,sBAAsB,CAAA;AAiBzF,eAAO,MAAM,kCAAkC,EAAE,
|
|
1
|
+
{"version":3,"file":"RequiredBalance.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/validation/hydratedBlockState/validators/RequiredBalance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,oCAAoC,EAAE,MAAM,sBAAsB,CAAA;AAiBzF,eAAO,MAAM,kCAAkC,EAAE,oCAgEhD,CAAA"}
|
|
@@ -225,6 +225,25 @@ export declare class SimpleBlockRunner extends AbstractCreatableProvider<SimpleB
|
|
|
225
225
|
* @returns The prior candidate's signed data hash, or undefined when there is none
|
|
226
226
|
*/
|
|
227
227
|
private previousOwnCandidateHash;
|
|
228
|
+
/**
|
|
229
|
+
* Balances for every distinct sender that has a paired transfer, read at `head` in one request.
|
|
230
|
+
*
|
|
231
|
+
* Senders are all known before any balance is needed and the lookups are independent, so they go
|
|
232
|
+
* out together. The previous shape awaited one `accountBalances([from])` per distinct sender
|
|
233
|
+
* inside the filter loop — a full round trip each wherever the viewer is bound over RPC, so the
|
|
234
|
+
* filter slowed in proportion to how busy the chain was, worst when candidates are contested.
|
|
235
|
+
*
|
|
236
|
+
* Reads are qualified to the parent `head`, matching the post-submit block validator
|
|
237
|
+
* (`RequiredBalanceBlockStateValidator` reads at `block[0].previous`). Unqualified reads resolved
|
|
238
|
+
* the viewer's *current* head per call, so the producer could admit a tx against a balance the
|
|
239
|
+
* validator would then reject — the wedge this filter exists to prevent — and successive senders
|
|
240
|
+
* could be read at different heads if the head moved mid-loop.
|
|
241
|
+
* @param head Hash of the parent block the candidate builds on
|
|
242
|
+
* @param txs The candidate transactions, in inclusion order
|
|
243
|
+
* @param transferByFrom Fee transfers keyed by sender, first transfer per sender
|
|
244
|
+
* @returns Balance at `head` per distinct sender, zero when the viewer omits one
|
|
245
|
+
*/
|
|
246
|
+
private readSenderBalances;
|
|
228
247
|
private rejectExhaustedBlock;
|
|
229
248
|
private rejectWrongChainTransactions;
|
|
230
249
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleBlockRunner.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/services/simple/block/runner/SimpleBlockRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAQ,UAAU,EAC1B,MAAM,iBAAiB,CAAA;AAKxB,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAAE,YAAY,EAChC,MAAM,kBAAkB,CAAA;AAKzB,OAAO,KAAK,EACV,oBAAoB,EAAuB,iBAAiB,EACxC,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EACzE,gBAAgB,EAAE,uBAAuB,EACzC,qBAAqB,EACrB,kBAAkB,EAClB,oCAAoC,EAAgC,aAAa,EACjF,mCAAmC,EACnC,+BAA+B,EAClB,cAAc,EAAE,QAAQ,EACtC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,yBAAyB,EAQ1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAKlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAI3E,OAAO,KAAK,EAAE,gCAAgC,EAA+B,MAAM,uCAAuC,CAAA;AAG1H,uFAAuF;AACvF,UAAU,wBAAwB;IAChC,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,SAAU,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,mCAAmC,MAAM,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,iCAAiC,MAAM,CAAA;AAEpD,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACtE,4FAA4F;IAC5F,OAAO,CAAC,EAAE,eAAe,CAAA;IACzB,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,8F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":3,"file":"SimpleBlockRunner.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/services/simple/block/runner/SimpleBlockRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAQ,UAAU,EAC1B,MAAM,iBAAiB,CAAA;AAKxB,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAAE,YAAY,EAChC,MAAM,kBAAkB,CAAA;AAKzB,OAAO,KAAK,EACV,oBAAoB,EAAuB,iBAAiB,EACxC,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EACzE,gBAAgB,EAAE,uBAAuB,EACzC,qBAAqB,EACrB,kBAAkB,EAClB,oCAAoC,EAAgC,aAAa,EACjF,mCAAmC,EACnC,+BAA+B,EAClB,cAAc,EAAE,QAAQ,EACtC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,yBAAyB,EAQ1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAKlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAI3E,OAAO,KAAK,EAAE,gCAAgC,EAA+B,MAAM,uCAAuC,CAAA;AAG1H,uFAAuF;AACvF,UAAU,wBAAwB;IAChC,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,SAAU,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,mCAAmC,MAAM,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,iCAAiC,MAAM,CAAA;AAEpD,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACtE,4FAA4F;IAC5F,OAAO,CAAC,EAAE,eAAe,CAAA;IACzB,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IA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;;OAIG;IACH,SAAS,CAAC,wBAAwB,CAAC,IAAI,EAAE,YAAY,CAAC,iBAAiB,CAAC,GAAG,UAAU,CAAC,gBAAgB,GAAG,SAAS,CAAC;cAsBnG,qBAAqB,CAAC,IAAI,EAAE,YAAY,CAAC,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,EAAE,OAAO,EAAE,KAAK,UAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA8DtH,OAAO,CAAC,kBAAkB;YASZ,mBAAmB;IAyBjC;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;IAgBjC;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;YASd,cAAc;YAqDd,mBAAmB;IAUjC;;;;;;;;;;;OAWG;YACW,SAAS;IAevB;;;;;;;;;OASG;YACW,iBAAiB;YAMjB,UAAU;IAexB,OAAO,CAAC,4BAA4B;IAMpC;;;;;;;;;;;;;OAaG;YACW,wBAAwB;IAUtC;;;;;;;;;;;;;;;;;OAiBG;YACW,kBAAkB;YAWlB,oBAAoB;YAkBpB,4BAA4B;IAiC1C;;;;;;;;;;;;OAYG;YACW,iBAAiB;YASjB,yBAAyB;CAoExC"}
|
package/dist/neutral/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const SIMPLE_BLOCK_RUNNER_INSTRUMENTATION_SINGLETON = "simpleBlockRunnerInstrumentation";
|
|
2
|
-
export declare const SimpleBlockRunnerTimingNames: readonly ["mempoolPendingBlocksFetch", "mempoolPendingTransactionsFetch"];
|
|
2
|
+
export declare const SimpleBlockRunnerTimingNames: readonly ["blockRewardTransfers", "mempoolPendingBlocksFetch", "mempoolPendingTransactionsFetch", "timePayloadGeneration"];
|
|
3
3
|
export type SimpleBlockRunnerTimingName = typeof SimpleBlockRunnerTimingNames[number];
|
|
4
4
|
/** Optional process-local observer for timings owned by SimpleBlockRunner. */
|
|
5
5
|
export interface SimpleBlockRunnerInstrumentation {
|
package/dist/neutral/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleBlockRunnerInstrumentation.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6CAA6C,qCAAqC,CAAA;AAE/F,eAAO,MAAM,4BAA4B,
|
|
1
|
+
{"version":3,"file":"SimpleBlockRunnerInstrumentation.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6CAA6C,qCAAqC,CAAA;AAE/F,eAAO,MAAM,4BAA4B,4HAK/B,CAAA;AAEV,MAAM,MAAM,2BAA2B,GAAG,OAAO,4BAA4B,CAAC,MAAM,CAAC,CAAA;AAErF,8EAA8E;AAC9E,MAAM,WAAW,gCAAgC;IAC/C,YAAY,CAAC,IAAI,EAAE,2BAA2B,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1E;AAED,MAAM,WAAW,uCAAuC;IACtD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7C;AAED,wBAAgB,wCAAwC,CACtD,OAAO,EAAE,uCAAuC,EAChD,eAAe,EAAE,gCAAgC,GAChD,IAAI,CAEN;AAED,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,uCAAuC,GAC/C,gCAAgC,GAAG,SAAS,CAI9C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Hash, JsonObject } from '@ariestools/sdk';
|
|
2
|
-
import type { SignedHydratedBlockWithHashMeta, SlashIndexKeyRecord } from '@xyo-network/xl1-sdk';
|
|
2
|
+
import type { SignedHydratedBlockWithHashMeta, SlashIndexKeyRecord, SlashOutcome } from '@xyo-network/xl1-sdk';
|
|
3
3
|
/** One object to write, and whether it may ever be rewritten. */
|
|
4
4
|
export interface SlashIndexWrite {
|
|
5
5
|
/** True when the object is content-addressed and must never change once written. */
|
|
@@ -9,6 +9,23 @@ export interface SlashIndexWrite {
|
|
|
9
9
|
/** What goes there. */
|
|
10
10
|
value: JsonObject;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* A challenge or adjudication, and the report it answers.
|
|
14
|
+
*
|
|
15
|
+
* An adjudication carries its outcome. When the report is in an earlier batch, the writing pass
|
|
16
|
+
* files the verdict and its outcome together, and no later pass reads that verdict again, so an
|
|
17
|
+
* outcome left behind here could never be recovered.
|
|
18
|
+
*/
|
|
19
|
+
export type SlashIndexPendingLink = {
|
|
20
|
+
hash: Hash;
|
|
21
|
+
kind: 'adjudication';
|
|
22
|
+
outcome: SlashOutcome;
|
|
23
|
+
request: Hash;
|
|
24
|
+
} | {
|
|
25
|
+
hash: Hash;
|
|
26
|
+
kind: 'challenge';
|
|
27
|
+
request: Hash;
|
|
28
|
+
};
|
|
12
29
|
/** Everything one batch of finalized blocks contributes to the index. */
|
|
13
30
|
export interface SlashIndexDelta {
|
|
14
31
|
/** Producer aggregates: path to the offense keys seen for that producer. */
|
|
@@ -16,16 +33,15 @@ export interface SlashIndexDelta {
|
|
|
16
33
|
/** Per-offense aggregates, keyed by their path. */
|
|
17
34
|
keys: Map<string, SlashIndexKeyRecord>;
|
|
18
35
|
/**
|
|
19
|
-
*
|
|
36
|
+
* What the writing pass has to attach, in the order it was finalized: adjudications and
|
|
37
|
+
* challenges whose report was not in this batch, and every adjudication after the first such
|
|
38
|
+
* adjudication.
|
|
20
39
|
*
|
|
21
40
|
* Their offense cannot be resolved from the blocks alone — the report that names it is further
|
|
22
|
-
* back — so the writing pass resolves them against the published request records.
|
|
41
|
+
* back — so the writing pass resolves them against the published request records. Later
|
|
42
|
+
* adjudications wait behind the first so that every verdict is settled in finalized order.
|
|
23
43
|
*/
|
|
24
|
-
pending:
|
|
25
|
-
hash: Hash;
|
|
26
|
-
kind: 'adjudication' | 'challenge';
|
|
27
|
-
request: Hash;
|
|
28
|
-
}[];
|
|
44
|
+
pending: SlashIndexPendingLink[];
|
|
29
45
|
/** Content-addressed records, safe to skip when already present. */
|
|
30
46
|
records: SlashIndexWrite[];
|
|
31
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"foldSlashIndex.d.ts","sourceRoot":"","sources":["../../../../../src/modules/slashing/index/foldSlashIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEvD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"foldSlashIndex.d.ts","sourceRoot":"","sources":["../../../../../src/modules/slashing/index/foldSlashIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEvD,OAAO,KAAK,EACV,+BAA+B,EAAE,mBAAmB,EAAE,YAAY,EACnE,MAAM,sBAAsB,CAAA;AAS7B,iEAAiE;AACjE,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,SAAS,EAAE,OAAO,CAAA;IAClB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,uBAAuB;IACvB,KAAK,EAAE,UAAU,CAAA;CAClB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAC3B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,GAC1E;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,CAAA;AAEtD,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9B,mDAAmD;IACnD,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;IACtC;;;;;;;;OAQG;IACH,OAAO,EAAE,qBAAqB,EAAE,CAAA;IAChC,oEAAoE;IACpE,OAAO,EAAE,eAAe,EAAE,CAAA;CAC3B;AAWD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,+BAA+B,EAAE,GAAG,eAAe,CAOzF;AAyFD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,mBAAmB,GAAG,SAAS,EACzC,IAAI,EAAE,mBAAmB,GACxB,mBAAmB,CAcrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyInvalidBlock.d.ts","sourceRoot":"","sources":["../../../../../src/modules/slashing/verify/verifyInvalidBlock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verifyInvalidBlock.d.ts","sourceRoot":"","sources":["../../../../../src/modules/slashing/verify/verifyInvalidBlock.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,8BAA8B,CAAA;AAyFtF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBA+ChC,CAAA"}
|
package/dist/neutral/modules/validation/hydratedBlockState/validators/RequiredBalance.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequiredBalance.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/validation/hydratedBlockState/validators/RequiredBalance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,oCAAoC,EAAE,MAAM,sBAAsB,CAAA;AAiBzF,eAAO,MAAM,kCAAkC,EAAE,
|
|
1
|
+
{"version":3,"file":"RequiredBalance.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/validation/hydratedBlockState/validators/RequiredBalance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,oCAAoC,EAAE,MAAM,sBAAsB,CAAA;AAiBzF,eAAO,MAAM,kCAAkC,EAAE,oCAgEhD,CAAA"}
|
|
@@ -458,8 +458,10 @@ function producerTuningFromConfig(config) {
|
|
|
458
458
|
// src/modules/services/simple/block/runner/SimpleBlockRunnerInstrumentation.ts
|
|
459
459
|
var SIMPLE_BLOCK_RUNNER_INSTRUMENTATION_SINGLETON = "simpleBlockRunnerInstrumentation";
|
|
460
460
|
var SimpleBlockRunnerTimingNames = [
|
|
461
|
+
"blockRewardTransfers",
|
|
461
462
|
"mempoolPendingBlocksFetch",
|
|
462
|
-
"mempoolPendingTransactionsFetch"
|
|
463
|
+
"mempoolPendingTransactionsFetch",
|
|
464
|
+
"timePayloadGeneration"
|
|
463
465
|
];
|
|
464
466
|
function registerSimpleBlockRunnerInstrumentation(context, instrumentation) {
|
|
465
467
|
context.singletons[SIMPLE_BLOCK_RUNNER_INSTRUMENTATION_SINGLETON] = instrumentation;
|
|
@@ -606,7 +608,8 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
|
|
|
606
608
|
});
|
|
607
609
|
const blockIdBuilder = new PayloadBuilder2({ schema: BlockNumberSchema });
|
|
608
610
|
const blockId = blockIdBuilder.fields({ block }).build();
|
|
609
|
-
const
|
|
611
|
+
const diviner = this._blockRewardDiviner;
|
|
612
|
+
const rewards = await this.instrument("blockRewardTransfers", async () => await diviner.divine([blockId]));
|
|
610
613
|
return rewards;
|
|
611
614
|
}
|
|
612
615
|
/**
|
|
@@ -658,7 +661,7 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
|
|
|
658
661
|
nonTxPayloads.push(...rewardTransferPayloads);
|
|
659
662
|
const transactionTransfers = await generateTransactionFeeTransfers(this.address, nextBlockTransactions);
|
|
660
663
|
const timePayload = await this.generateTimePayload();
|
|
661
|
-
const [initialFundedTransactions, initialFundedTransfers] = await this.filterByFunded(head, nextBlockTransactions, transactionTransfers, shouldValidateBalances);
|
|
664
|
+
const [initialFundedTransactions, initialFundedTransfers] = await this.filterByFunded(head._hash, nextBlockTransactions, transactionTransfers, shouldValidateBalances);
|
|
662
665
|
const stepRewardBalances = await this.accountBalanceViewer.accountBalances([XYO_STEP_REWARD_ADDRESS]);
|
|
663
666
|
const stepRewardPoolBalance = stepRewardBalances[String(XYO_STEP_REWARD_ADDRESS)];
|
|
664
667
|
const { block: proposedBlock, errors: proposedErrors } = await this.runBuildValidateRetryLoop({
|
|
@@ -737,10 +740,14 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
|
|
|
737
740
|
async filterByFunded(head, txs, transfers, validateBalances = false) {
|
|
738
741
|
const fundedTransfers = [];
|
|
739
742
|
const fundedTransactions = [];
|
|
743
|
+
const transferByFrom = /* @__PURE__ */ new Map();
|
|
744
|
+
for (const transfer of transfers) {
|
|
745
|
+
if (!transferByFrom.has(transfer.from)) transferByFrom.set(transfer.from, transfer);
|
|
746
|
+
}
|
|
747
|
+
const balances = validateBalances ? await this.readSenderBalances(head, txs, transferByFrom) : /* @__PURE__ */ new Map();
|
|
740
748
|
const committedOutflow = /* @__PURE__ */ new Map();
|
|
741
|
-
const balanceCache = /* @__PURE__ */ new Map();
|
|
742
749
|
for (const tx of txs) {
|
|
743
|
-
const transfer =
|
|
750
|
+
const transfer = transferByFrom.get(tx[0].from);
|
|
744
751
|
if (!transfer) continue;
|
|
745
752
|
if (!validateBalances) {
|
|
746
753
|
fundedTransfers.push(transfer);
|
|
@@ -748,12 +755,7 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
|
|
|
748
755
|
continue;
|
|
749
756
|
}
|
|
750
757
|
const { from } = transfer;
|
|
751
|
-
|
|
752
|
-
if (balance === void 0) {
|
|
753
|
-
const accountBalances = await this.accountBalanceViewer.accountBalances([from]);
|
|
754
|
-
balance = accountBalances[String(from)] ?? AttoXL1(0n);
|
|
755
|
-
balanceCache.set(from, balance);
|
|
756
|
-
}
|
|
758
|
+
const balance = balances.get(from) ?? AttoXL1(0n);
|
|
757
759
|
const projectedOutflow = (committedOutflow.get(from) ?? 0n) + this.computeTransactionOutflow(tx);
|
|
758
760
|
if (balance >= projectedOutflow) {
|
|
759
761
|
committedOutflow.set(from, projectedOutflow);
|
|
@@ -769,7 +771,7 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
|
|
|
769
771
|
}
|
|
770
772
|
async generateTimePayload() {
|
|
771
773
|
const timeStart = Date.now();
|
|
772
|
-
const timePayload = await this.timeSyncViewer.currentTimePayload();
|
|
774
|
+
const timePayload = await this.instrument("timePayloadGeneration", async () => await this.timeSyncViewer.currentTimePayload());
|
|
773
775
|
const timeDuration = Date.now() - timeStart;
|
|
774
776
|
if (timeDuration > 100) {
|
|
775
777
|
this.logger?.warn(`[Slow] Generated time payload in ${timeDuration}ms`);
|
|
@@ -858,6 +860,30 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
|
|
|
858
860
|
)).map(([candidate]) => candidate);
|
|
859
861
|
return selectSupersededCandidate(candidates, this.address, block, previous);
|
|
860
862
|
}
|
|
863
|
+
/**
|
|
864
|
+
* Balances for every distinct sender that has a paired transfer, read at `head` in one request.
|
|
865
|
+
*
|
|
866
|
+
* Senders are all known before any balance is needed and the lookups are independent, so they go
|
|
867
|
+
* out together. The previous shape awaited one `accountBalances([from])` per distinct sender
|
|
868
|
+
* inside the filter loop — a full round trip each wherever the viewer is bound over RPC, so the
|
|
869
|
+
* filter slowed in proportion to how busy the chain was, worst when candidates are contested.
|
|
870
|
+
*
|
|
871
|
+
* Reads are qualified to the parent `head`, matching the post-submit block validator
|
|
872
|
+
* (`RequiredBalanceBlockStateValidator` reads at `block[0].previous`). Unqualified reads resolved
|
|
873
|
+
* the viewer's *current* head per call, so the producer could admit a tx against a balance the
|
|
874
|
+
* validator would then reject — the wedge this filter exists to prevent — and successive senders
|
|
875
|
+
* could be read at different heads if the head moved mid-loop.
|
|
876
|
+
* @param head Hash of the parent block the candidate builds on
|
|
877
|
+
* @param txs The candidate transactions, in inclusion order
|
|
878
|
+
* @param transferByFrom Fee transfers keyed by sender, first transfer per sender
|
|
879
|
+
* @returns Balance at `head` per distinct sender, zero when the viewer omits one
|
|
880
|
+
*/
|
|
881
|
+
async readSenderBalances(head, txs, transferByFrom) {
|
|
882
|
+
const senders = [...new Set(txs.map((tx) => tx[0].from).filter((from) => transferByFrom.has(from)))];
|
|
883
|
+
if (senders.length === 0) return /* @__PURE__ */ new Map();
|
|
884
|
+
const balances = await this.accountBalanceViewer.accountBalances(senders, { head });
|
|
885
|
+
return new Map(senders.map((from) => [from, balances[from] ?? AttoXL1(0n)]));
|
|
886
|
+
}
|
|
861
887
|
async rejectExhaustedBlock(block, errors) {
|
|
862
888
|
this.logger?.warn(`Validation of produced block failed: ${errors.at(0)?.message}`);
|
|
863
889
|
if (this._deadLetterQueueRunner) {
|