@leofcoin/chain 1.10.15 → 1.10.17
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/exports/beacon-envelope.js +6 -6
- package/exports/beacon-epoch.js +1 -1
- package/exports/beacon-lifecycle.js +1 -1
- package/exports/beacon-round.js +1 -1
- package/exports/beacon.js +15 -14
- package/exports/browser/_commonjsHelpers-B85MJLTf.js +5 -0
- package/exports/browser/beacon-envelope.js +61 -150
- package/exports/browser/beacon-epoch.js +2 -2
- package/exports/browser/beacon-lifecycle.js +3 -3
- package/exports/browser/beacon-round.js +2 -2
- package/exports/browser/beacon-wire.js +3 -3
- package/exports/browser/beacon.js +2483 -1228
- package/exports/browser/{browser-DvU1xNFS-DmmNUdE-.js → browser-CCfR9KOM-CpStHgTj.js} +4 -4
- package/exports/browser/{browser-crypto-B9N9KlL4.js → browser-crypto-CH0ua22L.js} +284 -159
- package/exports/browser/chain.js +30 -16
- package/exports/browser/{client-DDC8C510-3uaB70KL.js → client-C_pBoi1g-_pfKzCvX.js} +256 -80
- package/exports/browser/{connection-monitor-GPztgSSJ.js → connection-monitor-D-krNiRH.js} +4 -4
- package/exports/browser/{hkdf-CnZvwpZ9.js → hkdf-BUHINPFj.js} +2 -94
- package/exports/browser/{index-Ccn5sExe.js → index-DmuI-29u.js} +55 -52
- package/exports/browser/{index-Bxr5Iztg-WbFIosyf.js → index-dTQVgkpf-BbdshWB0.js} +4 -4
- package/exports/browser/index.browser-CFfJpgKV.js +857 -0
- package/exports/browser/{messages-DH0tgNM9-C2CtyLsf.js → messages-BGHaihSi-eHZVl0y9.js} +10 -5
- package/exports/browser/{node-browser-BYi7D_oa.js → node-browser-BNe-en1l.js} +950 -482
- package/exports/browser/node-browser.js +4 -4
- package/exports/browser/{sha2-piimb6xL.js → sha2-BKcEJzgd.js} +144 -3
- package/exports/browser/weierstrass-BVfhtHbl.js +3596 -0
- package/exports/browser/workers/block-worker.js +5 -3
- package/exports/browser/workers/machine-worker.js +50 -22
- package/exports/{workers/worker-DMCj1e6z-CTYVa2yX.js → browser/workers/worker-BDTWOCzS-COrAszCt.js} +304 -168
- package/exports/chain.js +10 -5
- package/exports/{constants-CMYKv-Rt.js → constants-Dy9i9S_o.js} +1 -1
- package/exports/hash-format-state.js +17 -0
- package/exports/node.js +1 -1
- package/exports/workers/block-worker.js +5 -3
- package/exports/workers/machine-worker.js +50 -22
- package/exports/{browser/workers/worker-DMCj1e6z-CTYVa2yX.js → workers/worker-BDTWOCzS-COrAszCt.js} +304 -168
- package/package.json +14 -13
- package/exports/browser/weierstrass-Q0QND1ZT.js +0 -2156
package/exports/chain.js
CHANGED
|
@@ -10,9 +10,10 @@ import semver from 'semver';
|
|
|
10
10
|
import { randombytes } from '@leofcoin/crypto';
|
|
11
11
|
import EasyWorker from '@vandeurenglenn/easy-worker';
|
|
12
12
|
import { ContractDeploymentError, ExecutionError, isResolveError, ResolveError, isExecutionError } from '@leofcoin/errors';
|
|
13
|
-
import { P as PROTOCOL_VERSION, R as REACHED_ONE_ZERO_ZERO } from './constants-
|
|
13
|
+
import { P as PROTOCOL_VERSION, R as REACHED_ONE_ZERO_ZERO } from './constants-Dy9i9S_o.js';
|
|
14
14
|
import ConnectionMonitor from './connection-monitor.js';
|
|
15
15
|
import { q as quorumThreshold } from './quorum-S_qdgiAY.js';
|
|
16
|
+
import { assertHashFormatState } from './hash-format-state.js';
|
|
16
17
|
import '@leofcoin/networks';
|
|
17
18
|
|
|
18
19
|
const limit = 1800;
|
|
@@ -2182,8 +2183,9 @@ class Chain extends VersionControl {
|
|
|
2182
2183
|
this.#committingHeights = /* @__PURE__ */ new Set();
|
|
2183
2184
|
/** Prevents casting duplicate prevote/precommit per height:round */
|
|
2184
2185
|
this.#castedVotes = /* @__PURE__ */ new Set();
|
|
2185
|
-
this.ready = new Promise((resolve) => {
|
|
2186
|
+
this.ready = new Promise((resolve, reject) => {
|
|
2186
2187
|
this.readyResolve = resolve;
|
|
2188
|
+
this.readyReject = reject;
|
|
2187
2189
|
});
|
|
2188
2190
|
// ── Tendermint consensus handlers ────────────────────────────────────────
|
|
2189
2191
|
/**
|
|
@@ -2367,7 +2369,7 @@ class Chain extends VersionControl {
|
|
|
2367
2369
|
const hash = await this.#sendTransaction(message);
|
|
2368
2370
|
debug(`added ${hash}`);
|
|
2369
2371
|
};
|
|
2370
|
-
this.#init();
|
|
2372
|
+
this.#init().catch((error) => this.readyReject(error));
|
|
2371
2373
|
}
|
|
2372
2374
|
#state;
|
|
2373
2375
|
#slotTime;
|
|
@@ -2663,15 +2665,18 @@ class Chain extends VersionControl {
|
|
|
2663
2665
|
message: nameServiceMessage
|
|
2664
2666
|
}
|
|
2665
2667
|
];
|
|
2666
|
-
await Promise.all(
|
|
2668
|
+
const prepared = await Promise.all(
|
|
2667
2669
|
contracts.map(async ({ address, message }) => {
|
|
2668
2670
|
message = await new ContractMessage(Uint8Array.from(message.split(",").map((string) => Number(string))));
|
|
2669
|
-
await
|
|
2671
|
+
if (await message.hash() !== address) throw new Error(`genesis contract hash mismatch for ${address}`);
|
|
2672
|
+
return { address, encoded: message.encoded };
|
|
2670
2673
|
})
|
|
2671
2674
|
);
|
|
2675
|
+
await Promise.all(prepared.map(({ address, encoded }) => globalThis.contractStore.put(address, encoded)));
|
|
2672
2676
|
console.log("handle native contracts");
|
|
2673
2677
|
}
|
|
2674
2678
|
async #init() {
|
|
2679
|
+
await assertHashFormatState(globalThis.chainStore, globalThis.stateStore);
|
|
2675
2680
|
this.#participants = [];
|
|
2676
2681
|
this.#participating = false;
|
|
2677
2682
|
this.#connectionMonitor = new ConnectionMonitor();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { P as PROTOCOL_VERSION } from './constants-Dy9i9S_o.js';
|
|
2
|
+
import '@leofcoin/networks';
|
|
3
|
+
|
|
4
|
+
const assertHashFormatState = async (chainStore, stateStore) => {
|
|
5
|
+
if (await chainStore.has("version")) {
|
|
6
|
+
const version = new TextDecoder().decode(await chainStore.get("version"));
|
|
7
|
+
const parsed = /^(\d+)\.(\d+)\.\d+$/.exec(version);
|
|
8
|
+
const current = PROTOCOL_VERSION.split(".");
|
|
9
|
+
if (parsed && parsed[1] === current[0] && parsed[2] === current[1]) return;
|
|
10
|
+
throw new Error(`stored protocol ${version} is incompatible with canonical hash protocol ${PROTOCOL_VERSION}; back up existing data and use a separate migrated data root`);
|
|
11
|
+
}
|
|
12
|
+
if (await chainStore.has("lastBlock") || await stateStore?.has("lastBlock")) {
|
|
13
|
+
throw new Error("existing chainstate has no protocol version; explicit canonical hash migration required");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { PROTOCOL_VERSION, assertHashFormatState };
|
package/exports/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Peernet from '@leofcoin/peernet';
|
|
2
2
|
import nodeConfig from '@leofcoin/lib/node-config';
|
|
3
|
-
import { D as DEFAULT_NODE_OPTIONS } from './constants-
|
|
3
|
+
import { D as DEFAULT_NODE_OPTIONS } from './constants-Dy9i9S_o.js';
|
|
4
4
|
import { guardPeerMessages } from './connection-monitor.js';
|
|
5
5
|
import '@leofcoin/networks';
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasyWorker, F as FormatInterface, p as proto$3,
|
|
1
|
+
import { E as EasyWorker, F as FormatInterface, p as proto$3, e as encodeFrames, d as decodeFrames, a as proto$2 } from './worker-BDTWOCzS-COrAszCt.js';
|
|
2
2
|
|
|
3
3
|
class ValidatorMessage extends FormatInterface {
|
|
4
4
|
get messageName() {
|
|
@@ -33,14 +33,16 @@ class BlockMessage extends FormatInterface {
|
|
|
33
33
|
}
|
|
34
34
|
return super.encode({
|
|
35
35
|
...decoded,
|
|
36
|
-
validators:
|
|
36
|
+
validators: encodeFrames(validators)
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
decode(encoded) {
|
|
40
40
|
encoded = encoded || this.encoded;
|
|
41
41
|
super.decode(encoded);
|
|
42
42
|
// @ts-ignore
|
|
43
|
-
|
|
43
|
+
// Preserve historical acceptance of padded length prefixes. Tightening
|
|
44
|
+
// canonical protocol validation is a separate, versioned decision.
|
|
45
|
+
this.decoded.validators = decodeFrames(this.decoded.validators, 0, { canonical: false }).map((validator) => new ValidatorMessage(validator).decoded);
|
|
44
46
|
return this.decoded;
|
|
45
47
|
}
|
|
46
48
|
}
|