@xyo-network/xl1-protocol-sdk 1.26.23 → 1.26.24

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.
@@ -3011,15 +3011,44 @@ function elevatedPayloads([tx, payloads]) {
3011
3011
  throw new Error("Not all elevated payloads could be found in the transaction payloads");
3012
3012
  }
3013
3013
 
3014
+ // src/primitives/uncle/getProducerKey.ts
3015
+ function getProducerKey(block) {
3016
+ return block[0].addresses.toSorted().join(",");
3017
+ }
3018
+
3014
3019
  // src/primitives/uncle/scoreUncle.ts
3020
+ var PRODUCER_DIVERSITY_BONUS = 1e3;
3015
3021
  function scoreUncle(finalizedWindowedChain, blocks) {
3016
- return blocks.length;
3022
+ if (blocks.length === 0) return 0;
3023
+ let score = blocks.length;
3024
+ const head = finalizedWindowedChain.at(-1);
3025
+ if (head && blocks[0]) {
3026
+ const headProducer = getProducerKey(head);
3027
+ const candidateProducer = getProducerKey(blocks[0]);
3028
+ if (headProducer !== candidateProducer) {
3029
+ score += PRODUCER_DIVERSITY_BONUS;
3030
+ }
3031
+ }
3032
+ return score;
3017
3033
  }
3018
3034
 
3019
3035
  // src/primitives/uncle/findBestUncle.ts
3020
- function findBestUncle(finalizedWindowedChain, uncles) {
3036
+ var DEFAULT_MIN_CANDIDATES = 2;
3037
+ var DEFAULT_BACKOFF_MS = 12e4;
3038
+ function findBestUncle(finalizedWindowedChain, uncles, options) {
3039
+ if (uncles.length === 0) return void 0;
3040
+ const minCandidates = options?.minCandidates ?? DEFAULT_MIN_CANDIDATES;
3041
+ const backoffMs = options?.backoffMs ?? DEFAULT_BACKOFF_MS;
3042
+ const now = options?.now ?? Date.now();
3043
+ if (uncles.length < minCandidates) {
3044
+ const headEpoch = finalizedWindowedChain.at(-1)?.[0].$epoch ?? 0;
3045
+ const headAge = now - headEpoch;
3046
+ if (headAge < backoffMs) {
3047
+ return void 0;
3048
+ }
3049
+ }
3021
3050
  const scores = uncles.map((uncle) => [scoreUncle(finalizedWindowedChain, uncle), uncle]).toSorted((a, b) => b[0] - a[0]);
3022
- return scores[0]?.[1] ?? finalizedWindowedChain;
3051
+ return scores[0]?.[1];
3023
3052
  }
3024
3053
 
3025
3054
  // src/primitives/uncle/findUncles.ts
@@ -6209,7 +6238,9 @@ export {
6209
6238
  ChainIndexingServiceStateSchema,
6210
6239
  ConfigZod,
6211
6240
  CreatableProviderContextZod,
6241
+ DEFAULT_BACKOFF_MS,
6212
6242
  DEFAULT_MAX_ATTEMPTS,
6243
+ DEFAULT_MIN_CANDIDATES,
6213
6244
  DEFAULT_TOLERANCE_MS,
6214
6245
  DEFAULT_WALLET_PATH,
6215
6246
  DataLakeConfigZod,
@@ -6230,6 +6261,7 @@ export {
6230
6261
  MemoryMap,
6231
6262
  MemoryPermissionsStore,
6232
6263
  MnemonicStringZod,
6264
+ PRODUCER_DIVERSITY_BONUS,
6233
6265
  PostMessageRpcRemoteConfigZod,
6234
6266
  ProviderConfigZod,
6235
6267
  ProviderFactory,
@@ -6358,6 +6390,7 @@ export {
6358
6390
  getBlockRateBlocks,
6359
6391
  getEmptyContext,
6360
6392
  getEmptyProviderContext,
6393
+ getProducerKey,
6361
6394
  getTimeConfigInMilliseconds,
6362
6395
  getUrl,
6363
6396
  getWindowedChain,