@dusk-network/app-core 0.3.0 → 0.3.2
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 +19 -0
- package/README.md +5 -4
- package/package.json +1 -1
- package/src/bridge.d.ts +46 -10
- package/src/bridge.js +708 -231
- package/src/history.d.ts +2 -0
- package/src/history.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are listed here. It follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [0.3.2]
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- `/bridge`: an RPC search reads each block more than once while its transfers wait, from the first transfer's block on, rather than once
|
|
10
|
+
- `/bridge`: on an RPC, an earlier one of equal transfers takes a credit a later one could have had once the blocks before it are read again, rather than at once
|
|
11
|
+
|
|
12
|
+
## [0.3.1]
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `/history`: `historyRange` reads on from a `page`
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- `/bridge`: each transfer reads only its own hours of its account's history, read on from its `scan` while a call can't read it all: it waits then, rather than staying unsure
|
|
21
|
+
- `/bridge`: a transfer the archive doesn't list in its account's history yet waits, rather than taking an earlier one's credit
|
|
22
|
+
- `/bridge`: a deposit whose call's arguments the archive doesn't give counts as one that could be equal, rather than none
|
|
23
|
+
|
|
5
24
|
## [0.3.0]
|
|
6
25
|
|
|
7
26
|
### Added
|
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ const history = createHistory({
|
|
|
98
98
|
|
|
99
99
|
### Other reads
|
|
100
100
|
|
|
101
|
-
- `historyRange(archive, { account, from, to, direction, pages })`: an account's entries between two heights, a page at a time.
|
|
101
|
+
- `historyRange(archive, { account, from, to, direction, pages, page })`: an account's entries between two heights, a page at a time, from `page` on.
|
|
102
102
|
- `fetchTxDetails(archive, hashes, options)` and `fetchTxNonce(archive, hash)`: a transaction's time, outcome, fee and call, and its nonce.
|
|
103
103
|
- `archive.query(text)`: one GraphQL request, its integers past 2^53 kept as text. A request answered 429, 502, 503 or 504 is sent again, twice at most.
|
|
104
104
|
|
|
@@ -201,11 +201,12 @@ arrivalsOf(arrivals); // Map { hash => { hash: "0x029e…", at: 1793080333000 }
|
|
|
201
201
|
- Each credit pays one transfer. Equal transfers (the same route, recipient and payout) are paid in the order they were sent: the oldest takes the first credit after it, from 2 minutes before its block, as the chains' clocks differ. The app passes the transfers it still waits for, and the credits its others arrived with (`taken`): none of those pays a waiting one, though an earlier transfer read from the chain takes its own back, as one given but not looked for does.
|
|
202
202
|
- A transfer's time is its Dusk block's, never the device's clock. One without it yet isn't looked for. One sent more than a week ago (`waitMs`) is unknown, and isn't asked about.
|
|
203
203
|
- A deposit is followed on DuskEVM's explorer (`via: "explorer"`, the default): the recipient's incoming calls, newest first, read once for all its deposits, back past the oldest, 5 pages at most. Those calls don't say who deposited, so a payment is a deposit's only when it can't be another's: within 2 minutes either side of its block, once those minutes are over, with no other payment of its amount there (a failed one counts) that isn't another given deposit's. Nothing is asked before then.
|
|
204
|
-
- On DuskEVM's RPC (`via: "rpc"`), a deposit is found by DuskEVM's bridge event from its sender's DuskEVM address. With `/history`'s archive, each sender's equal deposits in the hours before its own are read from its history and paid first; a
|
|
204
|
+
- On DuskEVM's RPC (`via: "rpc"`), a deposit is found by DuskEVM's bridge event from its sender's DuskEVM address. With `/history`'s archive, each sender's equal deposits in the hours before its own are read from its history and paid first; a deposit there whose call can't be read leaves the order unclear. Without it, the RPC's credits are taken as the explorer's are. A deposit given without its sender takes no credit from the sender of another equal one given.
|
|
205
205
|
- A migration is paid by a transfer to the account from its route's payout account, with the migration's transaction hash as the memo, of exactly its amount: from the account's entries, less any `refund` paid to the account with it, or from the archive's memo index, which gives each payout's own amount. One from that account of another amount leaves it unsure, not waiting: the value of an entry an earlier version kept holds any gas refund paid to the account. With `entries`, the payouts there of migrations the app didn't list come too (`unlisted`), each with its `payer`; where one account pays out more than one route, a payout of a migration not listed doesn't say which: its `route` is null.
|
|
206
|
-
- A transfer out is read from the chain: what the route's account received, the address its memo gives as the route's bridge reads it (0x and 40 hex digits, any case, nothing around them), and its block. It arrives with the DUSK token's `Transfer` from its route's payout address to that address, of what the account received less the fee. The account's history lists every transfer that named the same address, in any case: equal ones in the hours before (a given one's by its own fee) are paid first, and one that can't be read
|
|
206
|
+
- A transfer out is read from the chain: what the route's account received, the address its memo gives as the route's bridge reads it (0x and 40 hex digits, any case, nothing around them), and its block. It arrives with the DUSK token's `Transfer` from its route's payout address to that address, of what the account received less the fee. The account's history lists every transfer that named the same address, in any case: equal ones in the hours before (a given one's by its own fee) are paid first, and one that can't be read leaves the order unclear. One that pays nothing out is `no-payout`, with its `problem`. `serviceTransferOf` gives what left the account (`sent`), and what the account received (`amount`) only where no gas was left to refund: an entry's value holds any refund paid to another account.
|
|
207
|
+
- With the archive, each transfer reads only its own hours of its account's history (its sender's for a deposit, the route's account's for a transfer out), further back while equal ones before it run on, and only once the archive lists the transfer there. A call reads 4 pages of it (`HISTORY_PAGES`) for each: a transfer whose history is longer waits, and the next call reads on from its `scan`.
|
|
207
208
|
- A route without its payout account or address in the network's file pays out nothing that can be told apart: `no-route`.
|
|
208
|
-
- An RPC search starts at a block from before the transfer, estimated from the chain's pace and checked by its time, and reads 8 windows of 5,000 blocks at most, narrower where the RPC asks for it. A result that isn't arrived says where the next search starts, with what it searched for and the credits found so far (`scan`): the app keeps it with the arrivals it was made with, and passes both back. A search for another sender or amount starts afresh.
|
|
209
|
+
- An RPC search starts at a block from before the transfer, estimated from the chain's pace and checked by its time, and reads 8 windows of 5,000 blocks at most, narrower where the RPC asks for it. It reads each block more than once: its window at the head reaches back 1,000 blocks, so the newest blocks are read again on each call, and once it has reached the head with a transfer not arrived, it reads its blocks again from the first, a pass at a time with the windows a call has left (one at least while a pass is under way, so 9 where the search ahead takes all 8), in windows no wider than the RPC took: the first a minute later, each one after as long again as it has been since it reached the head. Where a later equal transfer, still without its credit, could have had the credit an earlier one takes, the earlier one waits until the blocks are read again 8 times since the credit was found, one pass after the other. A result that isn't arrived says where the next search starts, with what it searched for and the credits found so far (`scan`): the app keeps it with the arrivals it was made with, and passes both back. A search for another sender or amount starts afresh.
|
|
209
210
|
|
|
210
211
|
A result is facts: `arrived`, with the other side's transaction, its block's time, the lux it paid and its block; `waiting`; or `unknown`, with why: `unsure` (a credit could be another's), `late` (none came in its window), `beyond` (the explorer's pages don't reach it), `searching` (carry on from `scan`), `expired`, `no-route`, `no-payout` or `error`. The words are the app's.
|
|
211
212
|
|
package/package.json
CHANGED
package/src/bridge.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export declare const EXPLORER_PAGES: 5;
|
|
|
76
76
|
/** Blocks one log search asks for at once; narrower where the RPC asks for it. */
|
|
77
77
|
export declare const LOG_WINDOW: 5000;
|
|
78
78
|
|
|
79
|
-
/** Log searches one call makes for a group of equal transfers, by default. */
|
|
79
|
+
/** Log searches one call makes for a group of equal transfers, by default: one more where the search ahead takes them all while its blocks are read again. */
|
|
80
80
|
export declare const LOG_WINDOWS: 8;
|
|
81
81
|
|
|
82
82
|
/** Equal deposits sent within this of each other are paid in their order: 2 hours, in milliseconds. */
|
|
@@ -85,7 +85,7 @@ export declare const DEPOSIT_HORIZON_MS: 7200000;
|
|
|
85
85
|
/** Equal transfers out sent within this of each other are paid in their order, or 4 times the route's usual time: 12 hours, in milliseconds. */
|
|
86
86
|
export declare const SERVICE_HORIZON_MS: 43200000;
|
|
87
87
|
|
|
88
|
-
/** Pages of
|
|
88
|
+
/** Pages of its account's history one call reads for a transfer's earlier equal ones; a longer history is read on in the next call, from its `scan`. */
|
|
89
89
|
export declare const HISTORY_PAGES: 4;
|
|
90
90
|
|
|
91
91
|
/** `Transfer(address,address,uint256)`: the DUSK token's transfer that pays a transfer out. */
|
|
@@ -94,15 +94,45 @@ export declare const TRANSFER_TOPIC: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f1
|
|
|
94
94
|
/** `ETHBridgeFinalized(address,address,uint256,bytes)`: DuskEVM's bridge paying a deposit, from the depositor's DuskEVM address. */
|
|
95
95
|
export declare const ETH_BRIDGE_FINALIZED_TOPIC: "0x31b2166ff604fc5672ea5df08a78081d2bc6d746cadce880747f3643d819e83d";
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* How far a transfer's own history is read: what it was read for (`of`),
|
|
99
|
+
* all of it from `lo` up to the transfer's block once `lo` is set, the
|
|
100
|
+
* range read next (`next`: its first block, its last and the page it
|
|
101
|
+
* carries on from), and the transfers found in it that could be equal to
|
|
102
|
+
* it, each with what it paid, in lux (`value`).
|
|
103
|
+
*/
|
|
104
|
+
export type HistoryScan = {
|
|
105
|
+
of: string;
|
|
106
|
+
lo: number | null;
|
|
107
|
+
next: { from: number; to: number; page: number } | null;
|
|
108
|
+
found: ReadonlyArray<{ hash: string; height: number; value: string }>;
|
|
109
|
+
};
|
|
110
|
+
|
|
97
111
|
/**
|
|
98
112
|
* Where a search stopped: the block the next one starts at, the time of the
|
|
99
113
|
* transfer it began from, the logs it searched for (`search`), and the
|
|
100
114
|
* credits it found before (`seen`), which the next one counts again. A
|
|
101
115
|
* search for other logs, as for another sender or amount, starts afresh.
|
|
102
|
-
*
|
|
103
|
-
* is
|
|
116
|
+
* The block it began at (`start`), and its passes over the blocks it read
|
|
117
|
+
* before (`recheck`): where the one under way is (`from`, null between
|
|
118
|
+
* two), when the next one begins (`at`), how many are done, as each credit
|
|
119
|
+
* seen has the passes done before it was found (`pass`), when the search
|
|
120
|
+
* first reached the head (`since`), in milliseconds, and the widest window
|
|
121
|
+
* the blocks are read again in, where the RPC refused a wider one (`size`).
|
|
122
|
+
* With the archive, how far the transfer's own history is read
|
|
123
|
+
* (`history`): a history longer than one call reads is read on from there,
|
|
124
|
+
* before any search. Kept by the app with the credits it was made with,
|
|
125
|
+
* and passed back as it is.
|
|
104
126
|
*/
|
|
105
|
-
export type Scan = {
|
|
127
|
+
export type Scan = {
|
|
128
|
+
from?: string;
|
|
129
|
+
basis?: number;
|
|
130
|
+
search?: string;
|
|
131
|
+
seen?: ReadonlyArray<{ hash: string; block: string; at: number; sender: string | null; pass?: number }>;
|
|
132
|
+
start?: string;
|
|
133
|
+
recheck?: { from: string | null; at: number; passes: number; since: number; size?: number };
|
|
134
|
+
history?: HistoryScan;
|
|
135
|
+
};
|
|
106
136
|
|
|
107
137
|
/**
|
|
108
138
|
* Why a transfer's credit is unknown:
|
|
@@ -190,7 +220,9 @@ export type DepositArrivalOptions = {
|
|
|
190
220
|
/**
|
|
191
221
|
* `/history`'s archive, for "rpc": each sender's equal deposits in the
|
|
192
222
|
* hours before its own are read from its history, those given but not
|
|
193
|
-
* looked for too, and paid first.
|
|
223
|
+
* looked for too, and paid first. Each deposit reads its own hours, once
|
|
224
|
+
* the archive lists it there, `HISTORY_PAGES` pages a call: a deposit
|
|
225
|
+
* whose history is read on in the next call waits, with its `scan`.
|
|
194
226
|
* Without it, or for a deposit without its sender and height, its credit
|
|
195
227
|
* is a deposit's only as where they can't be told apart.
|
|
196
228
|
*/
|
|
@@ -226,7 +258,8 @@ export type DepositArrivalOptions = {
|
|
|
226
258
|
* deposits, newest first, back past the oldest one waited for, at most
|
|
227
259
|
* `maxPages` pages; none is asked while every deposit's window is still
|
|
228
260
|
* open. On the RPC, a group of equal deposits from one sender is searched
|
|
229
|
-
* from about when the first was sent, `maxWindows` windows at most
|
|
261
|
+
* from about when the first was sent, `maxWindows` windows at most (one more
|
|
262
|
+
* where the search ahead takes them all while its blocks are read again).
|
|
230
263
|
* A network without DuskEVM asks nothing. Throws a TypeError for a deposit
|
|
231
264
|
* that isn't one, and for a network there's no file for.
|
|
232
265
|
*/
|
|
@@ -279,9 +312,12 @@ export type ServiceArrivalOptions = {
|
|
|
279
312
|
* route's account received in the hours before that named the same address,
|
|
280
313
|
* in any case, and pay out the same are paid first: its history lists them,
|
|
281
314
|
* and their own transactions say what each received (one given but not
|
|
282
|
-
* looked for pays out what its own fee leaves). One that can't be
|
|
283
|
-
*
|
|
284
|
-
*
|
|
315
|
+
* looked for pays out what its own fee leaves). One that can't be read
|
|
316
|
+
* leaves the order unclear: unsure. Each transfer reads its own hours of
|
|
317
|
+
* that history, once the archive lists it there, `HISTORY_PAGES` pages a
|
|
318
|
+
* call: one whose history is read on in the next call waits, with its
|
|
319
|
+
* `scan`. Throws a TypeError without an archive, and for a network there's
|
|
320
|
+
* no file for.
|
|
285
321
|
*/
|
|
286
322
|
export declare function serviceArrivals(options: ServiceArrivalOptions): Promise<{ arrivals: Map<string, Arrival>; requests: number }>;
|
|
287
323
|
|