@xyo-network/chain-services 1.3.17 → 1.3.19

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ChainIndexService.d.ts","sourceRoot":"","sources":["../../src/ChainIndexService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EACL,iBAAiB,EAAE,aAAa,EAAE,OAAO,EAC1C,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,WAAW,EAAoB,MAAM,kBAAkB,CAAA;AAEhE,MAAM,WAAW,0BAA2B,SAAQ,iBAAiB;IACnE,SAAS,CAAC,EAAE,iBAAiB,CAAA;CAC9B;AAED,MAAM,WAAW,iBAAkB,SAAQ,OAAO;IAChD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,aAAa,GAAG,SAAS,CAAC,CAAA;IACzD,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;CAChD;AAED,qBACa,oBAAqB,SAAQ,WAAW,CAAC,0BAA0B,CAAE,YAAW,iBAAiB;IAC5G,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,kBAAkB,CAA+B;IAEzD,SAAS,KAAK,iBAAiB;;;;;;;;;;yMAE9B;IAED,SAAS,KAAK,iBAAiB;;;;;;;;;;6LAE9B;IAEc,aAAa;IAI5B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,UAAU,CAAC,aAAa,GAAG,SAAS,CAAC;IAK/D,UAAU,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;CAGjD"}
1
+ {"version":3,"file":"ChainIndexService.d.ts","sourceRoot":"","sources":["../../src/ChainIndexService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EACL,iBAAiB,EAAE,aAAa,EAAE,OAAO,EAC1C,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,WAAW,EAAoB,MAAM,kBAAkB,CAAA;AAEhE,MAAM,WAAW,0BAA2B,SAAQ,iBAAiB;IACnE,SAAS,CAAC,EAAE,iBAAiB,CAAA;CAC9B;AAED,MAAM,WAAW,iBAAkB,SAAQ,OAAO;IAChD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,aAAa,GAAG,SAAS,CAAC,CAAA;IACzD,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;CAChD;AAED,qBACa,oBAAqB,SAAQ,WAAW,CAAC,0BAA0B,CAAE,YAAW,iBAAiB;IAC5G,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,kBAAkB,CAA+B;IAEzD,SAAS,KAAK,iBAAiB;;;;;;;;oQAE9B;IAED,SAAS,KAAK,iBAAiB;;;;;;;;wPAE9B;IAEc,aAAa;IAI5B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,UAAU,CAAC,aAAa,GAAG,SAAS,CAAC;IAK/D,UAAU,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;CAGjD"}
@@ -28,9 +28,7 @@ export declare class XyoValidator<TParams extends XyoValidatorParams = XyoValida
28
28
  config: import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/archivist-model").ArchivistConfig>;
29
29
  ephemeralQueryAccountEnabled?: boolean;
30
30
  moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
31
- privateChildren?: import("@xyo-network/module-model").ModuleInstance[];
32
- publicChildren?: import("@xyo-network/module-model").ModuleInstance[];
33
- } & import("@xyo-network/archivist-model").ArchivistParamFields & object, import("@xyo-network/archivist-model").ArchivistModuleEventData, import("@xyo-network/payload-model").Payload>;
31
+ } & import("@xyo-network/module-model").ModuleChildrenParams & import("@xyo-network/archivist-model").ArchivistParamFields & object, import("@xyo-network/archivist-model").ArchivistModuleEventData, import("@xyo-network/payload-model").Payload>;
34
32
  protected get rewardService(): BlockRewardService;
35
33
  validatePendingBlock(_block: BlockBoundWitness): Promisable<Error[]>;
36
34
  validatePendingTransaction(hydratedTransaction: HydratedTransaction): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"XyoValidator.d.ts","sourceRoot":"","sources":["../../../src/ChainValidator/XyoValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE/E,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,oCAAoC,EACpC,mBAAmB,EAEnB,kBAAkB,EACnB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,WAAW,EAAoB,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAM5C,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,OAAO,CAAC,EAAE,eAAe,CAAA;IACzB,uBAAuB,CAAC,EAAE,aAAa,CAAA;IACvC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,mBAAmB,CAAC,EAAE,iB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BAAuB,CAAC,EAAE,aAAa,CAAA;IACvC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,mBAAmB,CAAC,EAAE,iBAAiB,CAAA;IACvC,aAAa,CAAC,EAAE,kBAAkB,CAAA;IAClC,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC,0BAA0B,CAAC,EAAE,oCAAoC,CAAA;CAClE;AAED,qBACa,YAAY,CAAC,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,CAAE,SAAQ,WAAW,CAAC,OAAO,CAAE,YAAW,SAAS;IAClI,IAAI,OAAO,sBAEV;IAED,SAAS,KAAK,OAAO,oBAEpB;IAED,SAAS,KAAK,uBAAuB,mFAEpC;IAED,SAAS,KAAK,SAAS,qBAEtB;IAED,SAAS,KAAK,eAAe,oBAE5B;IAED,SAAS,KAAK,mBAAmB;;;;;;;;wPAEhC;IAED,SAAS,KAAK,aAAa,uBAE1B;IAED,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC;IAK9D,0BAA0B,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;CAQ7F"}
@@ -10,19 +10,38 @@ export interface XyoPendingTransactionsServiceParams extends BaseServiceParams {
10
10
  }
11
11
  export declare class XyoPendingTransactionsService extends BaseService<XyoPendingTransactionsServiceParams> implements PendingTransactionsService {
12
12
  private static readonly MutexPriority;
13
- private _cleanedToBlock;
14
- private _pendingTransactionsLocalArchivist;
15
- private _pendingTransactionsLocalArchivistCursor;
16
- private _updatePendingTransactionsLocalArchivistMutex;
13
+ /**
14
+ * A mutex to ensure that the counting the number of pending transactions is
15
+ * not called concurrently
16
+ */
17
+ private _countPendingTransactionsMutex;
18
+ /**
19
+ * A local Archivist optimized for fast retrieval that stores only validated
20
+ * pending transactions
21
+ */
22
+ private _curatedPendingTransactionsArchivist;
23
+ /**
24
+ * The last count of total pending transactions
25
+ */
26
+ private _pendingTransactionsCount;
27
+ /**
28
+ * A mutex to ensure that the curated pending transactions archivist is
29
+ * updated in a thread-safe manner
30
+ */
31
+ private _updateCuratedPendingTransactionsArchivistMutex;
17
32
  private get chainArchivist();
18
33
  private get chainIdentification();
19
34
  private get pendingTransactionsArchivist();
35
+ private get pendingTransactionsCount();
20
36
  private get pendingTransactionsLocalArchivist();
21
37
  private get rejectedTransactionsArchivist();
22
38
  createHandler(): Promise<void>;
23
- getPendingTransactions(head: Hash, limit: number, timeout?: number): Promise<HydratedTransactionWithStorageMeta[]>;
39
+ getPendingTransactions(head: Hash, limit: number): Promise<HydratedTransactionWithStorageMeta[]>;
40
+ private countPendingTransactions;
24
41
  private filterAlreadyFinalizedTransactions;
25
- private removeAlreadyIncludedTransactions;
26
- private updatePendingTransactionsLocalArchivist;
42
+ private insertNewTransactions;
43
+ private removeFinalizedTransactions;
44
+ private removeRejectedTransactions;
45
+ private removeTransactions;
27
46
  }
28
47
  //# sourceMappingURL=PendingTransactions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PendingTransactions.d.ts","sourceRoot":"","sources":["../../../src/PendingTransactions/PendingTransactions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAMhE,OAAO,EAC6C,iBAAiB,EAAE,mBAAmB,EAAE,kCAAkC,EAC5H,0BAA0B,EAC3B,MAAM,2BAA2B,CAAA;AAIlC,OAAO,EAAE,WAAW,EAAoB,MAAM,mBAAmB,CAAA;AAEjE,MAAM,WAAW,mCAAoC,SAAQ,iBAAiB;IAC5E,cAAc,CAAC,EAAE,iBAAiB,CAAA;IAClC,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IACzC,4BAA4B,CAAC,EAAE,iBAAiB,CAAA;IAChD,6BAA6B,CAAC,EAAE,iBAAiB,CAAA;CAClD;AAED,qBACa,6BA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,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAiB3B;IAEV;;;OAGG;IACH,OAAO,CAAC,8BAA8B,CAAc;IAEpD;;;OAGG;IACH,OAAO,CAAC,oCAAoC,CAA6B;IAEzE;;OAEG;IACH,OAAO,CAAC,yBAAyB,CAAY;IAE7C;;;OAGG;IACH,OAAO,CAAC,+CAA+C,CAAc;IAErE,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,KAAK,mBAAmB,GAE9B;IAED,OAAO,KAAK,4BAA4B,GAEvC;IAED,OAAO,KAAK,wBAAwB,GAGnC;IAED,OAAO,KAAK,iCAAiC,GAE5C;IAED,OAAO,KAAK,6BAA6B,GAExC;IAEc,aAAa;IA4BtB,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kCAAkC,EAAE,CAAC;YAsBxF,wBAAwB;YASxB,kCAAkC;YASlC,qBAAqB;YAmBrB,2BAA2B;YAI3B,0BAA0B;YAI1B,kBAAkB;CAWjC"}
@@ -27,9 +27,7 @@ export declare class XyoStakeIntentService extends BaseService<XyoStakeIntentSer
27
27
  config: import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/archivist-model").ArchivistConfig>;
28
28
  ephemeralQueryAccountEnabled?: boolean;
29
29
  moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
30
- privateChildren?: import("@xyo-network/module-model").ModuleInstance[];
31
- publicChildren?: import("@xyo-network/module-model").ModuleInstance[];
32
- } & import("@xyo-network/archivist-model").ArchivistParamFields & object, import("@xyo-network/archivist-model").ArchivistModuleEventData, Payload>;
30
+ } & import("@xyo-network/module-model").ModuleChildrenParams & import("@xyo-network/archivist-model").ArchivistParamFields & object, import("@xyo-network/archivist-model").ArchivistModuleEventData, Payload>;
33
31
  protected get chainIterator(): EventingChainBlockNumberIterator;
34
32
  protected get chainStakeViewer(): ChainStakeViewer;
35
33
  protected get stakeIntentStateArchivist(): ArchivistInstance<import("@xylabs/base").BaseParamsFields & {
@@ -40,9 +38,7 @@ export declare class XyoStakeIntentService extends BaseService<XyoStakeIntentSer
40
38
  config: import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/archivist-model").ArchivistConfig>;
41
39
  ephemeralQueryAccountEnabled?: boolean;
42
40
  moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
43
- privateChildren?: import("@xyo-network/module-model").ModuleInstance[];
44
- publicChildren?: import("@xyo-network/module-model").ModuleInstance[];
45
- } & import("@xyo-network/archivist-model").ArchivistParamFields & object, import("@xyo-network/archivist-model").ArchivistModuleEventData, Payload>;
41
+ } & import("@xyo-network/module-model").ModuleChildrenParams & import("@xyo-network/archivist-model").ArchivistParamFields & object, import("@xyo-network/archivist-model").ArchivistModuleEventData, Payload>;
46
42
  createHandler(): Promise<void>;
47
43
  getDeclaredCandidateRanges(address: Address, intent: Intent): Promise<Readonly<Readonly<[number, number]>[]>>;
48
44
  getDeclaredCandidatesForBlock(block: number, intent: Intent): Promise<Address[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"XyoStakeIntentService.d.ts","sourceRoot":"","sources":["../../../src/StakeIntent/XyoStakeIntentService.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAAa,IAAI,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,iBAAiB,EAAwB,MAAM,8BAA8B,CAAA;AAKtF,OAAO,EAEc,WAAW,EAE/B,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAE,OAAO,EAAmB,MAAM,4BAA4B,CAAA;AACrE,OAAO,KAAK,EACV,iBAAiB,EAAE,gCAAgC,EAAE,MAAM,EAC5D,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAEuI,gBAAgB,EAE5J,kBAAkB,EACnB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,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Aa,IAAI,OAAO,CAAC,IAAI,CAAC;IAQvC,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAO7G,6BAA6B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAUhF,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YAK3E,kBAAkB;YAkClB,YAAY;YAQZ,YAAY;YA+BZ,WAAW;CAgC1B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/package.json",
3
3
  "name": "@xyo-network/chain-services",
4
- "version": "1.3.17",
4
+ "version": "1.3.19",
5
5
  "description": "XYO Layer One SDK Services",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -34,48 +34,50 @@
34
34
  "deploy3": "echo Deploy3 not allowed!"
35
35
  },
36
36
  "dependencies": {
37
- "@xylabs/array": "^4.9.3",
38
- "@xylabs/assert": "^4.9.3",
39
- "@xylabs/base": "^4.9.3",
40
- "@xylabs/decimal-precision": "^4.9.3",
41
- "@xylabs/exists": "^4.9.3",
42
- "@xylabs/hex": "^4.9.3",
43
- "@xylabs/promise": "^4.9.3",
44
- "@xyo-network/account-model": "^3.14.17",
45
- "@xyo-network/archivist-memory": "^3.14.17",
46
- "@xyo-network/archivist-model": "^3.14.17",
47
- "@xyo-network/boundwitness-model": "^3.14.17",
48
- "@xyo-network/boundwitness-validator": "^3.14.17",
49
- "@xyo-network/boundwitness-wrapper": "^3.14.17",
50
- "@xyo-network/chain-analyze": "^1.3.17",
51
- "@xyo-network/chain-modules": "^1.3.17",
52
- "@xyo-network/chain-protocol": "^1.3.17",
53
- "@xyo-network/chain-utils": "^1.3.17",
54
- "@xyo-network/chain-validation": "^1.3.17",
55
- "@xyo-network/chain-wrappers": "^1.3.17",
56
- "@xyo-network/module-event-emitter": "^3.14.17",
57
- "@xyo-network/payload-builder": "^3.14.17",
58
- "@xyo-network/payload-model": "^3.14.17",
37
+ "@opentelemetry/api": "^1.9.0",
38
+ "@xylabs/array": "^4.9.15",
39
+ "@xylabs/assert": "^4.9.15",
40
+ "@xylabs/base": "^4.9.15",
41
+ "@xylabs/decimal-precision": "^4.9.15",
42
+ "@xylabs/exists": "^4.9.15",
43
+ "@xylabs/forget": "^4.9.15",
44
+ "@xylabs/hex": "^4.9.15",
45
+ "@xylabs/promise": "^4.9.15",
46
+ "@xyo-network/account-model": "^3.15.5",
47
+ "@xyo-network/archivist-memory": "^3.15.5",
48
+ "@xyo-network/archivist-model": "^3.15.5",
49
+ "@xyo-network/boundwitness-model": "^3.15.5",
50
+ "@xyo-network/boundwitness-validator": "^3.15.5",
51
+ "@xyo-network/boundwitness-wrapper": "^3.15.5",
52
+ "@xyo-network/chain-analyze": "^1.3.19",
53
+ "@xyo-network/chain-modules": "^1.3.19",
54
+ "@xyo-network/chain-protocol": "^1.3.19",
55
+ "@xyo-network/chain-utils": "^1.3.19",
56
+ "@xyo-network/chain-validation": "^1.3.19",
57
+ "@xyo-network/chain-wrappers": "^1.3.19",
58
+ "@xyo-network/module-event-emitter": "^3.15.5",
59
+ "@xyo-network/payload-builder": "^3.15.5",
60
+ "@xyo-network/payload-model": "^3.15.5",
59
61
  "@xyo-network/typechain": "^3.5.2",
60
- "@xyo-network/xl1-protocol": "^1.3.12",
61
- "@xyo-network/xl1-protocol-sdk": "^1.3.17",
62
+ "@xyo-network/xl1-protocol": "^1.3.13",
63
+ "@xyo-network/xl1-protocol-sdk": "^1.3.19",
62
64
  "async-mutex": "^0.5.0",
63
- "ethers": "6.13.7",
65
+ "ethers": "6.14.0",
64
66
  "lru-cache": "^11.1.0",
65
67
  "web3-types": "^1.10.0"
66
68
  },
67
69
  "devDependencies": {
68
- "@types/node": "^22.15.14",
69
- "@xylabs/delay": "^4.9.3",
70
+ "@types/node": "^22.15.17",
71
+ "@xylabs/delay": "^4.9.15",
70
72
  "@xylabs/ts-scripts-yarn3": "^6.5.5",
71
73
  "@xylabs/tsconfig": "^6.5.5",
72
- "@xylabs/vitest-extended": "^4.9.3",
73
- "@xyo-network/account": "^3.14.17",
74
- "@xyo-network/account-model": "^3.14.17",
75
- "@xyo-network/chain-ethereum": "^1.3.17",
76
- "@xyo-network/chain-validation": "^1.3.17",
77
- "@xyo-network/wallet": "^3.14.17",
78
- "knip": "^5.54.1",
74
+ "@xylabs/vitest-extended": "^4.9.15",
75
+ "@xyo-network/account": "^3.15.5",
76
+ "@xyo-network/account-model": "^3.15.5",
77
+ "@xyo-network/chain-ethereum": "^1.3.19",
78
+ "@xyo-network/chain-validation": "^1.3.19",
79
+ "@xyo-network/wallet": "^3.15.5",
80
+ "knip": "^5.55.1",
79
81
  "typescript": "^5.8.3",
80
82
  "vitest": "^3.1.3",
81
83
  "vitest-mock-extended": "^3.1.0"
@@ -17,18 +17,10 @@ export class BaseService<TParams extends BaseServiceParams = BaseServiceParams>
17
17
  return globalThis['xyoServiceSingletons'] ?? (globalThis['xyoServiceSingletons'] = {})
18
18
  }
19
19
 
20
- get meter() {
21
- return this.params.meterProvider?.getMeter(this.name)
22
- }
23
-
24
20
  get name() {
25
21
  return this.constructor.name
26
22
  }
27
23
 
28
- get tracer() {
29
- return this.params.traceProvider?.getTracer(this.name)
30
- }
31
-
32
24
  static async create<TService extends BaseService<TParams>, TParams extends BaseServiceParams = TService['params']>(
33
25
  this: CreatableService<TService>,
34
26
  params: TParams,
@@ -54,17 +46,19 @@ export class BaseService<TParams extends BaseServiceParams = BaseServiceParams>
54
46
  return span(`${this.name}:${name}`, fn, this.tracer)
55
47
  }
56
48
 
57
- async spanAsync<T>(name: string, fn: () => Promise<T>, timeout?: number): Promise<T> {
58
- return await spanAsync(`${this.name}:${name}`, fn, this.tracer, timeout)
49
+ async spanAsync<T>(name: string, fn: () => Promise<T>): Promise<T> {
50
+ return await spanAsync(`${this.name}:${name}`, fn, this.tracer)
59
51
  }
60
52
  }
61
53
 
62
54
  export abstract class BaseAccountableService<
63
55
  TParams extends BaseAccountableServiceParams = BaseAccountableServiceParams,
64
- > extends BaseService<TParams> {}
56
+ > extends BaseService<TParams> {
57
+ // Base class for services that have an account
58
+ }
65
59
 
66
60
  export interface CreatableService<T extends BaseService = BaseService> extends Service {
67
- new (params: T['params']): T
61
+ new(params: T['params']): T
68
62
  create<T extends BaseService>(this: CreatableService<T>, params: T['params']): Promisable<T>
69
63
  }
70
64
 
@@ -1,10 +1,11 @@
1
+ import { ValueType } from '@opentelemetry/api'
1
2
  import { filterAs, filterAsync } from '@xylabs/array'
2
3
  import { assertEx } from '@xylabs/assert'
3
4
  import { exists } from '@xylabs/exists'
5
+ import { forget } from '@xylabs/forget'
4
6
  import { Hash } from '@xylabs/hex'
5
7
  import { MemoryArchivist } from '@xyo-network/archivist-memory'
6
8
  import { ArchivistInstance } from '@xyo-network/archivist-model'
7
- import { hydrateBlock } from '@xyo-network/chain-protocol'
8
9
  import { validateTransaction } from '@xyo-network/chain-validation'
9
10
  import {
10
11
  Payload, Sequence, WithStorageMeta,
@@ -44,16 +45,30 @@ export class XyoPendingTransactionsService extends BaseService<XyoPendingTransac
44
45
  * Priority for removing finalized transactions
45
46
  */
46
47
  RemoveFinalizedTransactions: 1,
47
- }
48
-
49
- // used to remember the last block's transactions that was removed due to it being in the chain
50
- private _cleanedToBlock: Hash | undefined
51
-
52
- // a local archivist that has only the transactions in it (used as queue)
53
- private _pendingTransactionsLocalArchivist: MemoryArchivist | undefined
54
- private _pendingTransactionsLocalArchivistCursor: Sequence | undefined
55
-
56
- private _updatePendingTransactionsLocalArchivistMutex = new Mutex()
48
+ } as const
49
+
50
+ /**
51
+ * A mutex to ensure that the counting the number of pending transactions is
52
+ * not called concurrently
53
+ */
54
+ private _countPendingTransactionsMutex = new Mutex()
55
+
56
+ /**
57
+ * A local Archivist optimized for fast retrieval that stores only validated
58
+ * pending transactions
59
+ */
60
+ private _curatedPendingTransactionsArchivist: MemoryArchivist | undefined
61
+
62
+ /**
63
+ * The last count of total pending transactions
64
+ */
65
+ private _pendingTransactionsCount: number = 0
66
+
67
+ /**
68
+ * A mutex to ensure that the curated pending transactions archivist is
69
+ * updated in a thread-safe manner
70
+ */
71
+ private _updateCuratedPendingTransactionsArchivistMutex = new Mutex()
57
72
 
58
73
  private get chainArchivist() {
59
74
  return assertEx(this.params.chainArchivist, () => 'No completed blocks with data archivist')
@@ -67,8 +82,13 @@ export class XyoPendingTransactionsService extends BaseService<XyoPendingTransac
67
82
  return assertEx(this.params.pendingTransactionsArchivist, () => 'No pending transactions archivist')
68
83
  }
69
84
 
85
+ private get pendingTransactionsCount() {
86
+ forget(this.countPendingTransactions())
87
+ return this._pendingTransactionsCount
88
+ }
89
+
70
90
  private get pendingTransactionsLocalArchivist() {
71
- return assertEx(this._pendingTransactionsLocalArchivist, () => 'No pending transactions curate archivist')
91
+ return assertEx(this._curatedPendingTransactionsArchivist, () => 'No pending transactions curated archivist')
72
92
  }
73
93
 
74
94
  private get rejectedTransactionsArchivist() {
@@ -77,45 +97,35 @@ export class XyoPendingTransactionsService extends BaseService<XyoPendingTransac
77
97
 
78
98
  override async createHandler() {
79
99
  await super.createHandler()
80
- this._pendingTransactionsLocalArchivist = await MemoryArchivist.create({ account: 'random' })
100
+ this._curatedPendingTransactionsArchivist = await MemoryArchivist.create({ account: 'random' })
101
+
81
102
  // On new pending transactions, insert them into the curated archivist
82
103
  this.pendingTransactionsArchivist.on('inserted', async ({ payloads }) => {
83
- await this._updatePendingTransactionsLocalArchivistMutex.runExclusive(async () => {
84
- // Check incoming transactions against finalized transactions
85
- const unprocessedTransactions = await this.filterAlreadyFinalizedTransactions(payloads)
86
- // Hydrate all unprocessed transactions
87
- const hydratedUnprocessedTransactions = (await Promise.all(unprocessedTransactions.map((tx) => {
88
- return tryHydrateTransaction(this.pendingTransactionsArchivist, tx._hash)
89
- }))).filter(exists)
90
- // Filter to only valid transactions
91
- const validTransactions = await filterAsync(hydratedUnprocessedTransactions, async (tx) => {
92
- const errors = await validateTransaction(tx, this.chainIdentification.id)
93
- return errors.length > 0 ? false : true
94
- })
95
- await this.pendingTransactionsLocalArchivist.insert(flattenHydratedTransactions(validTransactions))
96
- }, XyoPendingTransactionsService.MutexPriority.InsertNewTransactions)
104
+ await this.insertNewTransactions(payloads)
97
105
  })
106
+
98
107
  // On new finalized blocks, remove the transactions from the curated archivist
99
108
  this.chainArchivist.on('inserted', async ({ payloads }) => {
100
- await this._updatePendingTransactionsLocalArchivistMutex.runExclusive(async () => {
101
- const transactions = filterAs(payloads, asOptionalTransactionBoundWitnessWithStorageMeta)
102
- await this.pendingTransactionsLocalArchivist.delete(transactions.map(tx => tx._hash))
103
- }, XyoPendingTransactionsService.MutexPriority.RemoveFinalizedTransactions)
109
+ await this.removeFinalizedTransactions(payloads)
104
110
  })
111
+
105
112
  // On new rejected blocks, remove the transactions from the curated archivist
106
113
  this.rejectedTransactionsArchivist.on('inserted', async ({ payloads }) => {
107
- await this._updatePendingTransactionsLocalArchivistMutex.runExclusive(async () => {
108
- const transactions = filterAs(payloads, asOptionalTransactionBoundWitnessWithStorageMeta)
109
- await this.pendingTransactionsLocalArchivist.delete(transactions.map(tx => tx._hash))
110
- }, XyoPendingTransactionsService.MutexPriority.RemoveRejectedTransactions)
114
+ await this.removeRejectedTransactions(payloads)
115
+ })
116
+
117
+ const pendingTransactionsGauge = this.meter?.createObservableGauge(
118
+ 'xyo_pending_transactions_count',
119
+ { description: 'The current number of pending transactions', valueType: ValueType.INT },
120
+ )
121
+ pendingTransactionsGauge?.addCallback((observer) => {
122
+ observer.observe(this.pendingTransactionsCount)
111
123
  })
112
124
  }
113
125
 
114
- async getPendingTransactions(head: Hash, limit: number, timeout = 1_000_000): Promise<HydratedTransactionWithStorageMeta[]> {
126
+ async getPendingTransactions(head: Hash, limit: number): Promise<HydratedTransactionWithStorageMeta[]> {
115
127
  return await this.spanAsync('getPendingTransactions', async () => {
116
- // await this.updatePendingTransactionsLocalArchivist()
117
- // await this.removeAlreadyIncludedTransactions(head)
118
- return await this._updatePendingTransactionsLocalArchivistMutex.runExclusive(async () => {
128
+ return await this._updateCuratedPendingTransactionsArchivistMutex.runExclusive(async () => {
119
129
  const foundPendingTransactions: WithStorageMeta<TransactionBoundWitness>[] = []
120
130
  let cursor: Sequence | undefined
121
131
  while (foundPendingTransactions.length < limit) {
@@ -132,7 +142,16 @@ export class XyoPendingTransactionsService extends BaseService<XyoPendingTransac
132
142
  )
133
143
  return hydratedTransactions.filter(exists)
134
144
  }, XyoPendingTransactionsService.MutexPriority.ReadTransactions)
135
- }, timeout)
145
+ })
146
+ }
147
+
148
+ private async countPendingTransactions() {
149
+ if (this._countPendingTransactionsMutex.isLocked()) return
150
+ await this._countPendingTransactionsMutex.runExclusive(async () => {
151
+ const payloads = (await this._curatedPendingTransactionsArchivist?.all()) ?? []
152
+ const pendingTransactions = filterAs(payloads, asOptionalTransactionBoundWitnessWithStorageMeta)
153
+ this._pendingTransactionsCount = pendingTransactions.length
154
+ })
136
155
  }
137
156
 
138
157
  private async filterAlreadyFinalizedTransactions(payloads: WithStorageMeta<Payload>[]): Promise<WithStorageMeta<TransactionBoundWitness>[]> {
@@ -144,49 +163,42 @@ export class XyoPendingTransactionsService extends BaseService<XyoPendingTransac
144
163
  return nonFinalizedTransactions
145
164
  }
146
165
 
147
- private async removeAlreadyIncludedTransactions(head?: Hash, timeout = 1_000_000) {
148
- return await this.spanAsync('removeAlreadyIncludedTransactions', async () => {
149
- let headPtr: Hash | null = head ?? null
150
- while (headPtr !== null) {
151
- const [block, payloads] = assertEx(await hydrateBlock(this.chainArchivist, headPtr), () => `Failed to find head [${head}]`)
152
- if (block._hash === this._cleanedToBlock) break
153
- await this.pendingTransactionsLocalArchivist.delete(
154
- payloads.map(payload => asOptionalTransactionBoundWitnessWithStorageMeta(payload)?._hash).filter(exists),
155
- )
156
- this._cleanedToBlock = block._hash
157
- headPtr = block?.previous
158
- }
159
- }, timeout)
166
+ private async insertNewTransactions(payloads: WithStorageMeta<Payload>[]) {
167
+ return await this.spanAsync('InsertNewTransactions', async () => {
168
+ return await this._updateCuratedPendingTransactionsArchivistMutex.runExclusive(async () => {
169
+ // Check incoming transactions against finalized transactions
170
+ const unprocessedTransactions = await this.filterAlreadyFinalizedTransactions(payloads)
171
+ // Hydrate all unprocessed transactions
172
+ const hydratedUnprocessedTransactions = (await Promise.all(unprocessedTransactions.map((tx) => {
173
+ return tryHydrateTransaction(this.pendingTransactionsArchivist, tx._hash)
174
+ }))).filter(exists)
175
+ // Filter to only valid transactions
176
+ const validTransactions = await filterAsync(hydratedUnprocessedTransactions, async (tx) => {
177
+ const errors = await validateTransaction(tx, this.chainIdentification.id)
178
+ return errors.length > 0 ? false : true
179
+ })
180
+ await this.pendingTransactionsLocalArchivist.insert(flattenHydratedTransactions(validTransactions))
181
+ }, XyoPendingTransactionsService.MutexPriority.InsertNewTransactions)
182
+ })
160
183
  }
161
184
 
162
- private async updatePendingTransactionsLocalArchivist(timeout = 1_000_000) {
163
- return await this.spanAsync('updatePendingTransactionsLocalArchivist', async () => {
164
- if (this._updatePendingTransactionsLocalArchivistMutex.isLocked()) {
165
- console.warn('updatePendingTransactionsLocalArchivist busy - skipping')
166
- return
167
- }
168
- return await this._updatePendingTransactionsLocalArchivistMutex.runExclusive(async () => {
169
- // const localWithDataArchivist = this.pendingTransactionsArchivist
170
- // sync from remote
171
- // await this.spanAsync('sync from remote [pending]', async () => {
172
- // this._pendingTransactionsLocalAllDataArchivistCursor = await synchronizeArchivists(
173
- // this.externalPendingTransactionsWithDataArchivist,
174
- // localWithDataArchivist,
175
- // this._pendingTransactionsLocalAllDataArchivistCursor,
176
- // )
177
- // }, timeout / 2)
178
- // // extract transactions only [from localWithDataArchivist]
179
- // await this.spanAsync('sync from local [pending]', async () => {
180
- // this._pendingTransactionsLocalArchivistCursor = await synchronizeArchivists(
181
- // localWithDataArchivist,
182
- // this.pendingTransactionsLocalArchivist,
183
- // this._pendingTransactionsLocalArchivistCursor,
184
- // isTransactionBoundWitness,
185
- // isTransactionBoundWitness,
186
- // )
187
- // }, timeout / 10)
188
- await Promise.resolve()
189
- })
190
- }, timeout)
185
+ private async removeFinalizedTransactions(payloads: WithStorageMeta<Payload>[]) {
186
+ return await this.removeTransactions(payloads, 'RemoveFinalizedTransactions')
187
+ }
188
+
189
+ private async removeRejectedTransactions(payloads: WithStorageMeta<Payload>[]) {
190
+ return await this.removeTransactions(payloads, 'RemoveRejectedTransactions')
191
+ }
192
+
193
+ private async removeTransactions(
194
+ payloads: WithStorageMeta<Payload>[],
195
+ priority: keyof typeof XyoPendingTransactionsService.MutexPriority,
196
+ ) {
197
+ return await this.spanAsync(priority, async () => {
198
+ return await this._updateCuratedPendingTransactionsArchivistMutex.runExclusive(async () => {
199
+ const transactions = filterAs(payloads, asOptionalTransactionBoundWitnessWithStorageMeta)
200
+ await this.pendingTransactionsLocalArchivist.delete(transactions.map(tx => tx._hash))
201
+ }, XyoPendingTransactionsService.MutexPriority[priority])
202
+ })
191
203
  }
192
204
  }