@skalenetwork/upgrade-tools 3.0.0-update-deploy-lib.2 → 3.0.0-update-deploy-lib.3
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/dist/src/migration/clients/clientStrategyFactory.d.ts +4 -2
- package/dist/src/migration/clients/clientStrategyFactory.js +4 -0
- package/dist/src/migration/clients/clientStrategyFactory.js.map +1 -1
- package/dist/src/migration/clients/erigonClientStrategy.d.ts +7 -0
- package/dist/src/migration/clients/erigonClientStrategy.js +48 -0
- package/dist/src/migration/clients/erigonClientStrategy.js.map +1 -0
- package/dist/src/migration/clients/gethClientStrategy.js +7 -5
- package/dist/src/migration/clients/gethClientStrategy.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { ErigonClientStrategy } from "./erigonClientStrategy";
|
|
1
2
|
import { GethClientStrategy } from "./gethClientStrategy";
|
|
2
3
|
import { JsonRpcProvider } from "ethers";
|
|
3
4
|
export declare enum Client {
|
|
4
|
-
GETH = "geth"
|
|
5
|
+
GETH = "geth",
|
|
6
|
+
ERIGON = "erigon"
|
|
5
7
|
}
|
|
6
|
-
export declare const clientStrategyFactory: (clientType: Client, provider: JsonRpcProvider) => GethClientStrategy;
|
|
8
|
+
export declare const clientStrategyFactory: (clientType: Client, provider: JsonRpcProvider) => ErigonClientStrategy | GethClientStrategy;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.clientStrategyFactory = exports.Client = void 0;
|
|
4
|
+
const erigonClientStrategy_1 = require("./erigonClientStrategy");
|
|
4
5
|
const gethClientStrategy_1 = require("./gethClientStrategy");
|
|
5
6
|
var Client;
|
|
6
7
|
(function (Client) {
|
|
7
8
|
Client["GETH"] = "geth";
|
|
9
|
+
Client["ERIGON"] = "erigon";
|
|
8
10
|
})(Client || (exports.Client = Client = {}));
|
|
9
11
|
const clientStrategyFactory = (clientType, provider) => {
|
|
10
12
|
switch (clientType) {
|
|
11
13
|
case Client.GETH:
|
|
12
14
|
return new gethClientStrategy_1.GethClientStrategy(provider);
|
|
15
|
+
case Client.ERIGON:
|
|
16
|
+
return new erigonClientStrategy_1.ErigonClientStrategy(provider);
|
|
13
17
|
default:
|
|
14
18
|
throw Error(`Unable to create Client ${clientType}`);
|
|
15
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientStrategyFactory.js","sourceRoot":"","sources":["../../../../src/migration/clients/clientStrategyFactory.ts"],"names":[],"mappings":";;;AAAA,6DAAwD;AAGxD,IAAY,
|
|
1
|
+
{"version":3,"file":"clientStrategyFactory.js","sourceRoot":"","sources":["../../../../src/migration/clients/clientStrategyFactory.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;AAC5D,6DAAwD;AAGxD,IAAY,MAGX;AAHD,WAAY,MAAM;IACd,uBAAa,CAAA;IACb,2BAAiB,CAAA;AACrB,CAAC,EAHW,MAAM,sBAAN,MAAM,QAGjB;AAEM,MAAM,qBAAqB,GAAG,CAAC,UAAkB,EAAE,QAAyB,EAAE,EAAE;IACnF,QAAQ,UAAU,EAAE,CAAC;QACjB,KAAK,MAAM,CAAC,IAAI;YACZ,OAAO,IAAI,uCAAkB,CAAC,QAAQ,CAAC,CAAC;QAC5C,KAAK,MAAM,CAAC,MAAM;YACd,OAAO,IAAI,2CAAoB,CAAC,QAAQ,CAAC,CAAC;QAE9C;YACI,MAAM,KAAK,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;IAC7D,CAAC;AACL,CAAC,CAAA;AAVY,QAAA,qBAAqB,yBAUjC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IClientStrategy, Slot } from "./iClientStrategy";
|
|
2
|
+
import { JsonRpcProvider } from "ethers";
|
|
3
|
+
export declare class ErigonClientStrategy implements IClientStrategy {
|
|
4
|
+
private provider;
|
|
5
|
+
constructor(provider: JsonRpcProvider);
|
|
6
|
+
dumpStorageForContract(contractAddress: string, blockHash: string): Promise<Slot[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErigonClientStrategy = void 0;
|
|
4
|
+
const iClientStrategy_1 = require("./iClientStrategy");
|
|
5
|
+
const DEFAULT_TX_INDEX = 0;
|
|
6
|
+
/*
|
|
7
|
+
* Changing might produce unwanted behaviour for erigon
|
|
8
|
+
* NextKey in erigon is the original (preimage) key, and not the hashed in.
|
|
9
|
+
* However, when requesting multiple slots, they do not appear to be ordered by original slot key
|
|
10
|
+
* For predictable behaviour, maintain at 1
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_N_SLOTS_TO_FETCH = 1;
|
|
13
|
+
class ErigonClientStrategy {
|
|
14
|
+
constructor(provider) {
|
|
15
|
+
this.provider = provider;
|
|
16
|
+
}
|
|
17
|
+
async dumpStorageForContract(contractAddress, blockHash) {
|
|
18
|
+
let startSlot = iClientStrategy_1.ZERO_KEY;
|
|
19
|
+
const slots = [];
|
|
20
|
+
// eslint-disable-next-line no-constant-condition
|
|
21
|
+
while (startSlot) {
|
|
22
|
+
// eslint-disable-next-line no-await-in-loop
|
|
23
|
+
const { storage, nextKey } = await this.provider.send('debug_storageRangeAt', [
|
|
24
|
+
blockHash,
|
|
25
|
+
DEFAULT_TX_INDEX,
|
|
26
|
+
contractAddress,
|
|
27
|
+
startSlot,
|
|
28
|
+
DEFAULT_N_SLOTS_TO_FETCH
|
|
29
|
+
]);
|
|
30
|
+
Object.entries(storage).forEach((entry) => {
|
|
31
|
+
// eslint-disable-next-line no-magic-numbers
|
|
32
|
+
const slot = entry[1];
|
|
33
|
+
if (slot.key !== null) {
|
|
34
|
+
slots.push(slot);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
// eslint-disable-next-line no-magic-numbers
|
|
38
|
+
const slot = Object.entries(storage)[0][1];
|
|
39
|
+
if (slot.key !== null) {
|
|
40
|
+
slots.push(slot);
|
|
41
|
+
}
|
|
42
|
+
startSlot = nextKey;
|
|
43
|
+
}
|
|
44
|
+
return slots;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.ErigonClientStrategy = ErigonClientStrategy;
|
|
48
|
+
//# sourceMappingURL=erigonClientStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erigonClientStrategy.js","sourceRoot":"","sources":["../../../../src/migration/clients/erigonClientStrategy.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAElE,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC,MAAa,oBAAoB;IAG7B,YAAY,QAAyB;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,sBAAsB,CACxB,eAAuB,EACvB,SAAiB;QAEjB,IAAI,SAAS,GAAG,0BAAQ,CAAC;QACzB,MAAM,KAAK,GAAW,EAAE,CAAC;QACzB,iDAAiD;QACjD,OAAO,SAAS,EAAE,CAAC;YACf,4CAA4C;YAC5C,MAAM,EAAC,OAAO,EAAE,OAAO,EAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC/C,sBAAsB,EACtB;gBACI,SAAS;gBACT,gBAAgB;gBAChB,eAAe;gBACf,SAAS;gBACT,wBAAwB;aAC3B,CACJ,CAAC;YACF,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtC,4CAA4C;gBAC5C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAS,CAAC;gBAC9B,IAAK,IAAI,CAAC,GAAG,KAAK,IAAI,EAAG,CAAC;oBACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC;YACL,CAAC,CAAC,CAAC;YACH,4CAA4C;YAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAS,CAAC;YACnD,IAAK,IAAI,CAAC,GAAG,KAAK,IAAI,EAAG,CAAC;gBACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;YACD,SAAS,GAAG,OAAO,CAAC;QACxB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA1CD,oDA0CC"}
|
|
@@ -21,11 +21,13 @@ class GethClientStrategy {
|
|
|
21
21
|
hashedKey,
|
|
22
22
|
DEFAULT_N_SLOTS_TO_FETCH
|
|
23
23
|
]);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
Object.entries(storage).forEach((entry) => {
|
|
25
|
+
// eslint-disable-next-line no-magic-numbers
|
|
26
|
+
const slot = entry[1];
|
|
27
|
+
if (slot.key !== null) {
|
|
28
|
+
slots.push(slot);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
29
31
|
hashedKey = nextKey;
|
|
30
32
|
}
|
|
31
33
|
return slots;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gethClientStrategy.js","sourceRoot":"","sources":["../../../../src/migration/clients/gethClientStrategy.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAElE,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC,MAAa,kBAAkB;IAG3B,YAAY,QAAyB;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,sBAAsB,CACxB,eAAuB,EACvB,SAAiB;QAEjB,IAAI,SAAS,GAAG,0BAAQ,CAAC;QACzB,MAAM,KAAK,GAAW,EAAE,CAAC;QACzB,iDAAiD;QACjD,OAAO,SAAS,EAAE,CAAC;YACf,4CAA4C;YAC5C,MAAM,EAAC,OAAO,EAAE,OAAO,EAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC/C,sBAAsB,EACtB;gBACI,SAAS;gBACT,gBAAgB;gBAChB,eAAe;gBACf,SAAS;gBACT,wBAAwB;aAC3B,CACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"gethClientStrategy.js","sourceRoot":"","sources":["../../../../src/migration/clients/gethClientStrategy.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAElE,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC,MAAa,kBAAkB;IAG3B,YAAY,QAAyB;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,sBAAsB,CACxB,eAAuB,EACvB,SAAiB;QAEjB,IAAI,SAAS,GAAG,0BAAQ,CAAC;QACzB,MAAM,KAAK,GAAW,EAAE,CAAC;QACzB,iDAAiD;QACjD,OAAO,SAAS,EAAE,CAAC;YACf,4CAA4C;YAC5C,MAAM,EAAC,OAAO,EAAE,OAAO,EAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC/C,sBAAsB,EACtB;gBACI,SAAS;gBACT,gBAAgB;gBAChB,eAAe;gBACf,SAAS;gBACT,wBAAwB;aAC3B,CACJ,CAAC;YACF,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtC,4CAA4C;gBAC5C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAS,CAAC;gBAC9B,IAAK,IAAI,CAAC,GAAG,KAAK,IAAI,EAAG,CAAC;oBACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC;YACL,CAAC,CAAC,CAAC;YACH,SAAS,GAAG,OAAO,CAAC;QACxB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AArCD,gDAqCC"}
|