@ouronet/ouronet-core 4.5.0 → 4.5.1
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/CHANGELOG.md +47 -0
- package/README.md +4 -0
- package/dist/interactions/guardFunctions.js +48 -1
- package/dist/interactions/ouroRotateFunctions.js +48 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,53 @@ All notable changes to `@ouronet/ouronet-core`.
|
|
|
4
4
|
|
|
5
5
|
This package is the historical continuation of `@ouronet/ouronet-core` v0.x–v3.3.8. v4.0.0 split it into a two-package npm workspace under `StoaChain/stoa-js` — chain-generic infrastructure moved out into [`@stoachain/stoa-core`](https://www.npmjs.com/package/@stoachain/stoa-core), this package retained the Ouronet-specific business logic. The `4.0.0` heading below is the first release after the split.
|
|
6
6
|
|
|
7
|
+
## 4.5.1 — 2026-09-07
|
|
8
|
+
|
|
9
|
+
**PATCH — the two rotation executors were submitting underpriced transactions.**
|
|
10
|
+
|
|
11
|
+
### What was broken
|
|
12
|
+
|
|
13
|
+
`guardFunctions.rotateGuard` and `ouroRotateFunctions.rotateKadenaPaymentKey` set
|
|
14
|
+
`creationTime` in `setMeta` but never set `gasPrice`. The vendored client fills the gap with
|
|
15
|
+
its own default of `1.0e-8` — which is exactly the Yin Engine's **genesis** floor of 10,000
|
|
16
|
+
ANU. The floor has risen 1 ANU every 3 hours since 2026-02-23, so from its first tick onward
|
|
17
|
+
both rotations were built below the chain-wide minimum price and rejected as underpriced.
|
|
18
|
+
|
|
19
|
+
Paying via the Gas Station does not exempt a transaction from this: `DALOS.GAS_PAYER` decides
|
|
20
|
+
*who* pays, not *how little*. The minimum-price rule is evaluated before the payer guard runs,
|
|
21
|
+
so a well-funded `STOA_AUTONOMIC_OURONETGASSTATION` made no difference.
|
|
22
|
+
|
|
23
|
+
This is the same live-gas-floor defect 4.5.0 fixed in `crossChainFunctions.ts`; these two files
|
|
24
|
+
were not part of that change. User-visible symptom: Codex's **Rotate Guard** and **Rotate
|
|
25
|
+
Payment Key** modals failing at submit.
|
|
26
|
+
|
|
27
|
+
### What changed
|
|
28
|
+
|
|
29
|
+
Both `setMeta` calls now spread the same `stoaGasMeta()` helper 4.5.0 introduced, which returns
|
|
30
|
+
`{ creationTime, gasPrice }` from a **single clock read** — the price is derived from the exact
|
|
31
|
+
`creationTime` that ships in the command, so the two can never disagree. The ANU → STOA
|
|
32
|
+
conversion is string-padding-built (`"0." + String(anu).padStart(12, "0")`), never float
|
|
33
|
+
division, so the value stays exact at 12 decimals.
|
|
34
|
+
|
|
35
|
+
The helper is a **temporary local duplicate** — the third copy in this repo, after
|
|
36
|
+
`crossChainFunctions.ts` and OuronetUI's `src/lib/gas-price.ts`. All copies carry the same
|
|
37
|
+
constants (genesis 10,000 ANU at `1771869600`, +1 ANU per 3 h, capped at 400,000 ANU) and all
|
|
38
|
+
should be deleted together once `@stoachain/stoa-core/gas` ships the formula; it still exports
|
|
39
|
+
only the static `GAS_PRICE_MIN_ANU = 10_000`.
|
|
40
|
+
|
|
41
|
+
**Note for auditors:** 17 other `interactions/*` files call `setMeta` without a `gasPrice` and
|
|
42
|
+
are underpriced by the same mechanism. They are out of scope for this patch and unfixed.
|
|
43
|
+
|
|
44
|
+
### Verification
|
|
45
|
+
|
|
46
|
+
New `tests/v4-5-1-rotation-gas-price.test.ts` locks the behaviour for both executors (12
|
|
47
|
+
specs): price tracks the live floor, is derived from the shipped `creationTime`, holds at the
|
|
48
|
+
genesis floor at tick 0, caps at 400,000 ANU, stays exact at 12 decimals, and matches between
|
|
49
|
+
the simulated build and the auto-gas-limit rebuild. Confirmed non-vacuous — 8 of the 12 fail
|
|
50
|
+
against the pre-fix source.
|
|
51
|
+
|
|
52
|
+
Non-breaking. No exported signatures changed. **800 specs pass.**
|
|
53
|
+
|
|
7
54
|
## 4.5.0 — 2026-09-07
|
|
8
55
|
|
|
9
56
|
**MINOR — cross-chain gas payer switched to `stoa-xchain-gas`; live Yin-Engine gas pricing.**
|
package/README.md
CHANGED
|
@@ -23,6 +23,8 @@ Chain-generic infrastructure (signing, wallet, crypto, network failover, gas, gu
|
|
|
23
23
|
|
|
24
24
|
## Status
|
|
25
25
|
|
|
26
|
+
**`4.5.1` on public npmjs** — **PATCH (the two rotation executors were submitting underpriced transactions).** Released 2026-09-07. `guardFunctions.rotateGuard` and `ouroRotateFunctions.rotateKadenaPaymentKey` set `creationTime` but never set `gasPrice`, so the vendored client stamped its `1.0e-8` default — exactly the Yin Engine's *genesis* floor of 10,000 ANU. Since the floor rises 1 ANU every 3 hours, both rotations were built below the chain-wide minimum price and rejected as underpriced from the floor's first tick onward. Gas-Station payment is no exemption: `DALOS.GAS_PAYER` decides *who* pays, not *how little*, and the minimum-price rule runs before the payer guard. Same defect 4.5.0 fixed in `crossChainFunctions.ts`; these two files were not part of that change. Both `setMeta` calls now spread the same `stoaGasMeta()` helper — `{ creationTime, gasPrice }` from a single clock read, with a padding-built (never float-divided) ANU → STOA conversion. New `tests/v4-5-1-rotation-gas-price.test.ts` locks it with 12 specs, 8 of which fail against the pre-fix source. Note for auditors: 17 other `interactions/*` files call `setMeta` without a `gasPrice` and remain underpriced by the same mechanism — out of scope here. Non-breaking — no exported signatures changed. **800 specs pass.**
|
|
27
|
+
|
|
26
28
|
**`4.5.0` on public npmjs** — **MINOR (cross-chain gas payer switched to `stoa-xchain-gas`; live Yin-Engine gas pricing).** Released 2026-09-07. `crossChainFunctions.ts`'s non-chain-0 gas payer moves off the legacy `kadena-xchain-gas` account (a static `gasPrice <= 0.00000001` / `gasLimit <= 850` guard) onto StoaChain's own `stoa-xchain-gas` account, whose guard (`pact/genesis/stoa/stoa-genesis-5.pact`) requires `gasPrice <= UC_MinimumGasPriceANU()` — a *live floor*, not a fixed ceiling. All four `gasPrice` call sites in this file (the legacy `buildCrossChainTransfer`, both `buildCTransferAcross` branches — including the chain-0 `DALOS.GAS_PAYER` path, previously on the static `GAS_PRICE_MIN_ANU` — and `buildContinuationTransaction`'s default payer) now derive `{ creationTime, gasPrice }` from a local Yin-Engine helper instead of a hardcoded price. That helper is a temporary duplicate of OuronetUI's `src/lib/gas-price.ts` — it belongs in `@stoachain/stoa-core/gas` once that package ships the same formula (it currently still exports only the static `GAS_PRICE_MIN_ANU = 10_000`); consolidate then. Verified against a live StoaChain node: both the initial `C_TransferAcross` (chain-0, `DALOS.GAS_PAYER`) and the `stoa-xchain-gas`-paid continuation landed successfully at 11,565 ANU/gas. Non-breaking — no exported signatures changed, only the default `gasPayerAccount` value and the internal price derivation. **787 specs pass.**
|
|
27
29
|
|
|
28
30
|
**`4.4.0` on public npmjs** — **MINOR (codec writer held at 1.2; reader still accepts 1.2 and 1.3).** Released 2026-07-22. Corrects 4.3.6/4.3.7, which shipped an unreleased 1.3 *writer* and so produced backups that apps on a 1.2-only reader could not open. The reader is unchanged and still accepts both, so any 1.3 file already written stays readable; the writer stamps 1.2 again. Nothing is lost — this writer never emitted the 1.3-only `foreignKeys` block. Those two versions are deprecated and point here. **787 specs pass.**
|
|
@@ -47,6 +49,8 @@ Chain-generic infrastructure (signing, wallet, crypto, network failover, gas, gu
|
|
|
47
49
|
|
|
48
50
|
**`4.2.0` on public npmjs** — **MINOR (atomic with `@stoachain/stoa-core@4.2.0` + `@stoachain/kadena-stoic-legacy@4.2.0`).** Released 2026-05-09. Closes 6 audit findings: **F-ARCH-001** (Phase 1 dex god-file split — ~10 entity-oriented files + thin re-export shim), **F-ARCH-002** (Phase 2 ouro god-file split + chain/UI surgical separation — ~11 entity-oriented files + thin re-export shim), **F-ARCH-003** (Phase 3 parameterized liquidity executor — 5 thin wrappers + 1 internal `executeLiquidityOp`, LOC reduction ~600 → ~200), **F-API-002** (Phase 4 — 12 functions honor declared `Promise<T | null>` contract, return null on RPC failure instead of rethrowing), **F-API-018** (Phase 5 readonly sweep — ~50 public-type fields in `codex/types.ts` and all `*Params` interfaces), **F-TEST-006** (Phase 7 — +127 specs across 6 modules: `infoOneFunctions`, `coilFunctions`, `kpayFunctions`, `pensionFunctions`, `activateFunctions`, `guardFunctions`). NEW deliverable: [`INTEGRATION-GUIDE.md`](https://github.com/StoaChain/stoa-js/blob/main/INTEGRATION-GUIDE.md) at repo root — comprehensive cold-start consumer onboarding doc, 13 sections, full v4.0 → v4.1 → v4.2 architectural arc. 8 new `v4-2-0-*.test.ts` regression-lock files. Test count: **710 specs pass** (was ~330 in v4.1.1). Cross-reference: see [`MIGRATION-v4.2.md`](https://github.com/StoaChain/stoa-js/blob/main/MIGRATION-v4.2.md) at the monorepo root.
|
|
49
51
|
|
|
52
|
+
**v4.5.1** — live Yin-Engine gas pricing for the two rotation executors (`rotateGuard`, `rotateKadenaPaymentKey`). Released 2026-09-07. Both omitted `gasPrice` entirely and inherited the client's `1.0e-8` genesis-floor default, so every rotation submitted after the floor's first tick was rejected as underpriced. No signature changes. **800 specs pass.**
|
|
53
|
+
|
|
50
54
|
**v4.5.0** — cross-chain gas payer switched to `stoa-xchain-gas` with live Yin-Engine pricing (replaces the legacy `kadena-xchain-gas` static ceiling). Released 2026-09-07. All four `gasPrice` sites in `crossChainFunctions.ts` now derive price from the current Yin floor instead of a hardcoded value; verified landing on a live StoaChain node at 11,565 ANU/gas. No signature changes. **787 specs pass.**
|
|
51
55
|
|
|
52
56
|
**v4.4.0** — codec writer held at `"1.2"`; reader still accepts `"1.2"` and `"1.3"`. Released 2026-07-22. Corrects the 4.3.6/4.3.7 mispublish, which shipped an unreleased 1.3 writer under version numbers the old `@stoachain` package had already used. **787 specs pass.**
|
|
@@ -7,6 +7,47 @@ import { universalSignTransaction, fromKeypair } from "@stoachain/stoa-core/sign
|
|
|
7
7
|
import { createSimulationError, logDetailedError } from "@stoachain/stoa-core/errors";
|
|
8
8
|
import { safeCreationTime } from "@stoachain/stoa-core/pact";
|
|
9
9
|
import { getLogger } from "@stoachain/stoa-core/observability";
|
|
10
|
+
/**
|
|
11
|
+
* Yin Engine — StoaChain's time-varying minimum gas price.
|
|
12
|
+
*
|
|
13
|
+
* TEMPORARY LOCAL COPY, identical to the one in `crossChainFunctions.ts`
|
|
14
|
+
* (v4.5.0). Both belong in `@stoachain/stoa-core/gas` long-term — that package
|
|
15
|
+
* still exposes only the static `GAS_PRICE_MIN_ANU = 10_000`, which is the
|
|
16
|
+
* genesis floor and has been stale since 2026-02-23. Delete every copy in the
|
|
17
|
+
* same change that consumes the chain-generic version.
|
|
18
|
+
*
|
|
19
|
+
* The floor starts at 10,000 ANU at genesis and rises by 1 ANU every 3 hours,
|
|
20
|
+
* capped at 400,000 ANU. Source of truth: `UC_MinimumGasPriceANU` in
|
|
21
|
+
* `pact/stoa-coin/new-coin.pact` (evaluated against `(at "block-time"
|
|
22
|
+
* (chain-data))` on-chain — creationTime is a close client-side proxy for it).
|
|
23
|
+
*
|
|
24
|
+
* This applies to gas-station-paid transactions too: `DALOS.GAS_PAYER` decides
|
|
25
|
+
* WHO pays, not HOW LITTLE. The chain-wide "gasPrice must be >= the live
|
|
26
|
+
* floor" rule is checked before the payer guard ever runs, so a transaction
|
|
27
|
+
* left at the client's `1.0e-8` default is rejected as underpriced no matter
|
|
28
|
+
* how well-funded the Ouronet Gas Station is.
|
|
29
|
+
*/
|
|
30
|
+
const YIN_GENESIS_TIME_S = 1771869600; // 2026-02-23T18:00:00Z — tick 0
|
|
31
|
+
const YIN_GENESIS_MIN_GAS_ANU = 10000;
|
|
32
|
+
const YIN_MAX_GAS_ANU = 400000;
|
|
33
|
+
const YIN_GAS_PRICE_INTERVAL_S = 10800; // 3 h per tick
|
|
34
|
+
function minGasPriceAnu(creationTimeS) {
|
|
35
|
+
const elapsed = creationTimeS - YIN_GENESIS_TIME_S;
|
|
36
|
+
const ticks = elapsed <= 0 ? 0 : Math.floor(elapsed / YIN_GAS_PRICE_INTERVAL_S);
|
|
37
|
+
return Math.min(YIN_GENESIS_MIN_GAS_ANU + ticks, YIN_MAX_GAS_ANU);
|
|
38
|
+
}
|
|
39
|
+
/** Built by string padding, never float division — avoids exponential notation / precision loss. */
|
|
40
|
+
function anuToStoaNumber(anu) {
|
|
41
|
+
return Number("0." + String(anu).padStart(12, "0"));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* One clock read: the `creationTime` to stamp and the `gasPrice` derived
|
|
45
|
+
* FROM THAT EXACT VALUE, so the two can never disagree.
|
|
46
|
+
*/
|
|
47
|
+
function stoaGasMeta() {
|
|
48
|
+
const creationTime = safeCreationTime();
|
|
49
|
+
return { creationTime, gasPrice: anuToStoaNumber(minGasPriceAnu(creationTime)) };
|
|
50
|
+
}
|
|
10
51
|
/**
|
|
11
52
|
* Query RotateGuard info object from the chain.
|
|
12
53
|
* (ouronet-ns.DALOS-INFO.DALOS-INFO|URC_RotateGuard <patron> <account>)
|
|
@@ -69,9 +110,15 @@ export async function rotateGuard(params) {
|
|
|
69
110
|
builder = builder
|
|
70
111
|
.setMeta({
|
|
71
112
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
72
|
-
creationTime: safeCreationTime(),
|
|
73
113
|
chainId: KADENA_CHAIN_ID,
|
|
74
114
|
gasLimit: gasLimitOverride || gasLimit,
|
|
115
|
+
// `stoaGasMeta()` supplies both `creationTime` (via `safeCreationTime()`)
|
|
116
|
+
// and the `gasPrice` derived from that exact value, per the Yin Engine
|
|
117
|
+
// (see the module-level comment above). Pre-4.5.1 this set only
|
|
118
|
+
// `creationTime`, leaving `gasPrice` at the vendored client's
|
|
119
|
+
// `1.0e-8` default — the genesis floor — so every rotation submitted
|
|
120
|
+
// after the floor's first tick was rejected as underpriced.
|
|
121
|
+
...stoaGasMeta(),
|
|
75
122
|
})
|
|
76
123
|
.setNetworkId(KADENA_NETWORK)
|
|
77
124
|
// Gas Station key: GAS_PAYER capability
|
|
@@ -11,6 +11,47 @@ import { universalSignTransaction, fromKeypair } from "@stoachain/stoa-core/sign
|
|
|
11
11
|
import { createSimulationError, logDetailedError } from "@stoachain/stoa-core/errors";
|
|
12
12
|
import { pactRead } from "@stoachain/stoa-core/reads";
|
|
13
13
|
import { getLogger } from "@stoachain/stoa-core/observability";
|
|
14
|
+
/**
|
|
15
|
+
* Yin Engine — StoaChain's time-varying minimum gas price.
|
|
16
|
+
*
|
|
17
|
+
* TEMPORARY LOCAL COPY, identical to the one in `crossChainFunctions.ts`
|
|
18
|
+
* (v4.5.0). Both belong in `@stoachain/stoa-core/gas` long-term — that package
|
|
19
|
+
* still exposes only the static `GAS_PRICE_MIN_ANU = 10_000`, which is the
|
|
20
|
+
* genesis floor and has been stale since 2026-02-23. Delete every copy in the
|
|
21
|
+
* same change that consumes the chain-generic version.
|
|
22
|
+
*
|
|
23
|
+
* The floor starts at 10,000 ANU at genesis and rises by 1 ANU every 3 hours,
|
|
24
|
+
* capped at 400,000 ANU. Source of truth: `UC_MinimumGasPriceANU` in
|
|
25
|
+
* `pact/stoa-coin/new-coin.pact` (evaluated against `(at "block-time"
|
|
26
|
+
* (chain-data))` on-chain — creationTime is a close client-side proxy for it).
|
|
27
|
+
*
|
|
28
|
+
* This applies to gas-station-paid transactions too: `DALOS.GAS_PAYER` decides
|
|
29
|
+
* WHO pays, not HOW LITTLE. The chain-wide "gasPrice must be >= the live
|
|
30
|
+
* floor" rule is checked before the payer guard ever runs, so a transaction
|
|
31
|
+
* left at the client's `1.0e-8` default is rejected as underpriced no matter
|
|
32
|
+
* how well-funded the Ouronet Gas Station is.
|
|
33
|
+
*/
|
|
34
|
+
const YIN_GENESIS_TIME_S = 1771869600; // 2026-02-23T18:00:00Z — tick 0
|
|
35
|
+
const YIN_GENESIS_MIN_GAS_ANU = 10000;
|
|
36
|
+
const YIN_MAX_GAS_ANU = 400000;
|
|
37
|
+
const YIN_GAS_PRICE_INTERVAL_S = 10800; // 3 h per tick
|
|
38
|
+
function minGasPriceAnu(creationTimeS) {
|
|
39
|
+
const elapsed = creationTimeS - YIN_GENESIS_TIME_S;
|
|
40
|
+
const ticks = elapsed <= 0 ? 0 : Math.floor(elapsed / YIN_GAS_PRICE_INTERVAL_S);
|
|
41
|
+
return Math.min(YIN_GENESIS_MIN_GAS_ANU + ticks, YIN_MAX_GAS_ANU);
|
|
42
|
+
}
|
|
43
|
+
/** Built by string padding, never float division — avoids exponential notation / precision loss. */
|
|
44
|
+
function anuToStoaNumber(anu) {
|
|
45
|
+
return Number("0." + String(anu).padStart(12, "0"));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* One clock read: the `creationTime` to stamp and the `gasPrice` derived
|
|
49
|
+
* FROM THAT EXACT VALUE, so the two can never disagree.
|
|
50
|
+
*/
|
|
51
|
+
function stoaGasMeta() {
|
|
52
|
+
const creationTime = safeCreationTime();
|
|
53
|
+
return { creationTime, gasPrice: anuToStoaNumber(minGasPriceAnu(creationTime)) };
|
|
54
|
+
}
|
|
14
55
|
/**
|
|
15
56
|
* Query RotateKadena info object from the chain.
|
|
16
57
|
* (ouronet-ns.INFO-ZERO.DALOS-INFO|URC_RotateKadena <patron> <account>)
|
|
@@ -70,9 +111,15 @@ export async function rotateKadenaPaymentKey(patronAddress, accountAddress, newP
|
|
|
70
111
|
builder = builder
|
|
71
112
|
.setMeta({
|
|
72
113
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
73
|
-
creationTime: safeCreationTime(),
|
|
74
114
|
chainId: KADENA_CHAIN_ID,
|
|
75
115
|
gasLimit: gasLimitOverride || gasLimit,
|
|
116
|
+
// `stoaGasMeta()` supplies both `creationTime` (via `safeCreationTime()`)
|
|
117
|
+
// and the `gasPrice` derived from that exact value, per the Yin Engine
|
|
118
|
+
// (see the module-level comment above). Pre-4.5.1 this set only
|
|
119
|
+
// `creationTime`, leaving `gasPrice` at the vendored client's
|
|
120
|
+
// `1.0e-8` default — the genesis floor — so every payment-key rotation
|
|
121
|
+
// submitted after the floor's first tick was rejected as underpriced.
|
|
122
|
+
...stoaGasMeta(),
|
|
76
123
|
})
|
|
77
124
|
.setNetworkId(KADENA_NETWORK)
|
|
78
125
|
// Gas Station key: GAS_PAYER capability (SEPARATE from guard keys)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouronet/ouronet-core",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.1",
|
|
4
4
|
"description": "Ouronet-specific business logic for the Ouronet protocol on StoaChain — interactions/* read+execute functions for the ouronet-ns Pact modules, the Codex encrypted-multi-wallet format, Ouronet protocol accounts and tokens. Depends on @stoachain/stoa-core for chain-generic infrastructure (signing, wallet, crypto, network, etc.).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|