@typeberry/jam 0.4.0-fcdfbb1 → 0.4.1-dae2283
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/README.md +5 -0
- package/bootstrap-generator.mjs +33 -8
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +313 -208
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +8 -7
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +315 -210
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24314,7 +24314,11 @@ var TestSuite;
|
|
|
24314
24314
|
})(TestSuite || (TestSuite = {}));
|
|
24315
24315
|
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
24316
24316
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
24317
|
-
|
|
24317
|
+
/**
|
|
24318
|
+
* Current version is set to track the jam-conformance testing.
|
|
24319
|
+
* Since we are currently at 0.7.1 not 0.7.2, we set our default version accordingly.
|
|
24320
|
+
*/
|
|
24321
|
+
const DEFAULT_VERSION = GpVersion.V0_7_1;
|
|
24318
24322
|
const env = typeof process === "undefined" ? {} : process.env;
|
|
24319
24323
|
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
24320
24324
|
let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
@@ -24373,8 +24377,8 @@ class Compatibility {
|
|
|
24373
24377
|
/**
|
|
24374
24378
|
* Allows selecting different values for different Gray Paper versions from one record.
|
|
24375
24379
|
*
|
|
24376
|
-
*
|
|
24377
|
-
*
|
|
24380
|
+
* fallback The default value to return if no value is found for the current.
|
|
24381
|
+
* versions A record mapping versions to values, checking if the version is greater or equal to the current version.
|
|
24378
24382
|
* @returns The value for the current version, or the default value.
|
|
24379
24383
|
*/
|
|
24380
24384
|
static selectIfGreaterOrEqual({ fallback, versions, }) {
|
|
@@ -24537,7 +24541,7 @@ const workspacePathFix = dev_env.NODE_ENV === "development"
|
|
|
24537
24541
|
|
|
24538
24542
|
;// CONCATENATED MODULE: ./packages/core/utils/opaque.ts
|
|
24539
24543
|
/**
|
|
24540
|
-
*
|
|
24544
|
+
* `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
|
|
24541
24545
|
* specified unique token Token. It means that base type cannot be assigned to unique type by accident.
|
|
24542
24546
|
* Good examples of opaque types include:
|
|
24543
24547
|
* - JWTs or other tokens - these are special kinds of string used for authorization purposes.
|
|
@@ -34210,11 +34214,32 @@ const ENTROPY_ENTRIES = 4;
|
|
|
34210
34214
|
|
|
34211
34215
|
var UpdatePreimageKind;
|
|
34212
34216
|
(function (UpdatePreimageKind) {
|
|
34213
|
-
/**
|
|
34217
|
+
/**
|
|
34218
|
+
* Insert new preimage and optionally update it's lookup history.
|
|
34219
|
+
*
|
|
34220
|
+
* Used in: `provide`
|
|
34221
|
+
*
|
|
34222
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/383904383904?v=0.7.2
|
|
34223
|
+
*/
|
|
34214
34224
|
UpdatePreimageKind[UpdatePreimageKind["Provide"] = 0] = "Provide";
|
|
34215
|
-
/**
|
|
34225
|
+
/**
|
|
34226
|
+
* Remove a preimage and it's lookup history.
|
|
34227
|
+
*
|
|
34228
|
+
* Used in: `forget` and `eject`
|
|
34229
|
+
*
|
|
34230
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/38c701380202?v=0.7.2
|
|
34231
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/379102379302?v=0.7.2
|
|
34232
|
+
*/
|
|
34216
34233
|
UpdatePreimageKind[UpdatePreimageKind["Remove"] = 1] = "Remove";
|
|
34217
|
-
/**
|
|
34234
|
+
/**
|
|
34235
|
+
* Update or add lookup history for preimage hash/len to given value.
|
|
34236
|
+
*
|
|
34237
|
+
* Used in: `solicit` and `forget`
|
|
34238
|
+
*
|
|
34239
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/382802382802?v=0.7.2
|
|
34240
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/384002384b02?v=0.7.2
|
|
34241
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/38c60038ea00?v=0.7.2
|
|
34242
|
+
*/
|
|
34218
34243
|
UpdatePreimageKind[UpdatePreimageKind["UpdateOrAdd"] = 2] = "UpdateOrAdd";
|
|
34219
34244
|
})(UpdatePreimageKind || (UpdatePreimageKind = {}));
|
|
34220
34245
|
/**
|
|
@@ -34222,7 +34247,7 @@ var UpdatePreimageKind;
|
|
|
34222
34247
|
*
|
|
34223
34248
|
* Can be one of the following cases:
|
|
34224
34249
|
* 1. Provide a new preimage blob and set the lookup history to available at `slot`.
|
|
34225
|
-
* 2. Remove (
|
|
34250
|
+
* 2. Remove (forget) a preimage and it's lookup history.
|
|
34226
34251
|
* 3. Update `LookupHistory` with given value.
|
|
34227
34252
|
*/
|
|
34228
34253
|
class UpdatePreimage {
|
|
@@ -35445,7 +35470,6 @@ class LeafNode {
|
|
|
35445
35470
|
/**
|
|
35446
35471
|
* Get the byte length of embedded value.
|
|
35447
35472
|
*
|
|
35448
|
-
* @remark
|
|
35449
35473
|
* Note in case this node only contains hash this is going to be 0.
|
|
35450
35474
|
*/
|
|
35451
35475
|
getValueLength() {
|
|
@@ -35456,7 +35480,6 @@ class LeafNode {
|
|
|
35456
35480
|
/**
|
|
35457
35481
|
* Returns the embedded value.
|
|
35458
35482
|
*
|
|
35459
|
-
* @remark
|
|
35460
35483
|
* Note that this is going to be empty for a regular leaf node (i.e. containing a hash).
|
|
35461
35484
|
*/
|
|
35462
35485
|
getValue() {
|
|
@@ -35466,7 +35489,6 @@ class LeafNode {
|
|
|
35466
35489
|
/**
|
|
35467
35490
|
* Returns contained value hash.
|
|
35468
35491
|
*
|
|
35469
|
-
* @remark
|
|
35470
35492
|
* Note that for embedded value this is going to be full 0-padded 32 bytes.
|
|
35471
35493
|
*/
|
|
35472
35494
|
getValueHash() {
|
|
@@ -39014,7 +39036,11 @@ class PartiallyUpdatedState {
|
|
|
39014
39036
|
const service = this.state.getService(serviceId);
|
|
39015
39037
|
return service?.getPreimage(hash) ?? null;
|
|
39016
39038
|
}
|
|
39017
|
-
/**
|
|
39039
|
+
/**
|
|
39040
|
+
* Get status of a preimage of current service taking into account any updates.
|
|
39041
|
+
*
|
|
39042
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/110201110201?v=0.7.2
|
|
39043
|
+
*/
|
|
39018
39044
|
getLookupHistory(currentTimeslot, serviceId, hash, length) {
|
|
39019
39045
|
const updatedService = this.stateUpdate.services.updated.get(serviceId);
|
|
39020
39046
|
/** Return lookup history item for newly created service */
|
|
@@ -39051,12 +39077,7 @@ class PartiallyUpdatedState {
|
|
|
39051
39077
|
return new LookupHistoryItem(hash, updatedPreimage.length, tryAsLookupHistorySlots([currentTimeslot]));
|
|
39052
39078
|
}
|
|
39053
39079
|
case UpdatePreimageKind.Remove: {
|
|
39054
|
-
|
|
39055
|
-
// kinda impossible, since we know it's there because it's removed.
|
|
39056
|
-
if (state === null) {
|
|
39057
|
-
return null;
|
|
39058
|
-
}
|
|
39059
|
-
return new LookupHistoryItem(hash, state.length, tryAsLookupHistorySlots([...state.slots, currentTimeslot]));
|
|
39080
|
+
return null;
|
|
39060
39081
|
}
|
|
39061
39082
|
case UpdatePreimageKind.UpdateOrAdd: {
|
|
39062
39083
|
return action.item;
|
|
@@ -39149,7 +39170,7 @@ const gas_tryAsSmallGas = (v) => opaque_asOpaqueType(numbers_tryAsU32(v));
|
|
|
39149
39170
|
/** Attempt to convert given number into U64 gas representation. */
|
|
39150
39171
|
const tryAsBigGas = (v) => opaque_asOpaqueType(numbers_tryAsU64(v));
|
|
39151
39172
|
/** Attempt to convert given number into gas. */
|
|
39152
|
-
const
|
|
39173
|
+
const gas_tryAsGas = (v) => typeof v === "number" && v < 2 ** 32 ? gas_tryAsSmallGas(v) : tryAsBigGas(v);
|
|
39153
39174
|
|
|
39154
39175
|
;// CONCATENATED MODULE: ./packages/core/pvm-interface/memory.ts
|
|
39155
39176
|
|
|
@@ -39432,7 +39453,7 @@ const tryAsRegisterIndex = (index) => {
|
|
|
39432
39453
|
debug_check `${index >= 0 && index < registers_NO_OF_REGISTERS} Incorrect register index: ${index}!`;
|
|
39433
39454
|
return opaque_asOpaqueType(index);
|
|
39434
39455
|
};
|
|
39435
|
-
class
|
|
39456
|
+
class registers_Registers {
|
|
39436
39457
|
bytes;
|
|
39437
39458
|
asSigned;
|
|
39438
39459
|
asUnsigned;
|
|
@@ -39451,7 +39472,7 @@ class Registers {
|
|
|
39451
39472
|
}
|
|
39452
39473
|
static fromBytes(bytes) {
|
|
39453
39474
|
debug_check `${bytes.length === registers_NO_OF_REGISTERS << REGISTER_SIZE_SHIFT} Invalid size of registers array.`;
|
|
39454
|
-
return new
|
|
39475
|
+
return new registers_Registers(bytes);
|
|
39455
39476
|
}
|
|
39456
39477
|
getBytesAsLittleEndian(index, len) {
|
|
39457
39478
|
const offset = index << REGISTER_SIZE_SHIFT;
|
|
@@ -39765,49 +39786,10 @@ class NoopMissing {
|
|
|
39765
39786
|
}
|
|
39766
39787
|
}
|
|
39767
39788
|
|
|
39768
|
-
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/gas.ts
|
|
39769
|
-
|
|
39770
|
-
|
|
39771
|
-
/** Create a new gas counter instance depending on the gas value. */
|
|
39772
|
-
function gasCounter(gas) {
|
|
39773
|
-
return new GasCounterU64(numbers_tryAsU64(gas));
|
|
39774
|
-
}
|
|
39775
|
-
class GasCounterU64 {
|
|
39776
|
-
gas;
|
|
39777
|
-
initialGas;
|
|
39778
|
-
constructor(gas) {
|
|
39779
|
-
this.gas = gas;
|
|
39780
|
-
this.initialGas = tryAsGas(gas);
|
|
39781
|
-
}
|
|
39782
|
-
set(g) {
|
|
39783
|
-
this.gas = numbers_tryAsU64(g);
|
|
39784
|
-
}
|
|
39785
|
-
get() {
|
|
39786
|
-
return tryAsGas(this.gas);
|
|
39787
|
-
}
|
|
39788
|
-
sub(g) {
|
|
39789
|
-
const result = this.gas - numbers_tryAsU64(g);
|
|
39790
|
-
if (result >= 0n) {
|
|
39791
|
-
this.gas = numbers_tryAsU64(result);
|
|
39792
|
-
return false;
|
|
39793
|
-
}
|
|
39794
|
-
this.gas = numbers_tryAsU64(0n);
|
|
39795
|
-
return true;
|
|
39796
|
-
}
|
|
39797
|
-
used() {
|
|
39798
|
-
const gasConsumed = numbers_tryAsU64(this.initialGas) - this.gas;
|
|
39799
|
-
// In we have less than zero left we assume that all gas has been consumed.
|
|
39800
|
-
if (gasConsumed < 0) {
|
|
39801
|
-
return this.initialGas;
|
|
39802
|
-
}
|
|
39803
|
-
return tryAsGas(gasConsumed);
|
|
39804
|
-
}
|
|
39805
|
-
}
|
|
39806
|
-
|
|
39807
39789
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/memory/memory-index.ts
|
|
39808
39790
|
|
|
39809
39791
|
|
|
39810
|
-
const
|
|
39792
|
+
const memory_index_tryAsMemoryIndex = (index) => {
|
|
39811
39793
|
debug_check `${index >= 0 && index <= MAX_MEMORY_INDEX} Incorrect memory index: ${index}!`;
|
|
39812
39794
|
return opaque_asOpaqueType(index);
|
|
39813
39795
|
};
|
|
@@ -39821,25 +39803,25 @@ const tryAsSbrkIndex = (index) => {
|
|
|
39821
39803
|
|
|
39822
39804
|
const memory_consts_PAGE_SIZE_SHIFT = 12;
|
|
39823
39805
|
// PAGE_SIZE has to be a power of 2
|
|
39824
|
-
const
|
|
39806
|
+
const memory_consts_PAGE_SIZE = 1 << memory_consts_PAGE_SIZE_SHIFT;
|
|
39825
39807
|
const MIN_ALLOCATION_SHIFT = (() => {
|
|
39826
39808
|
const MIN_ALLOCATION_SHIFT = 7;
|
|
39827
39809
|
debug_check `${MIN_ALLOCATION_SHIFT >= 0 && MIN_ALLOCATION_SHIFT < memory_consts_PAGE_SIZE_SHIFT} incorrect minimal allocation shift`;
|
|
39828
39810
|
return MIN_ALLOCATION_SHIFT;
|
|
39829
39811
|
})();
|
|
39830
|
-
const MIN_ALLOCATION_LENGTH =
|
|
39831
|
-
const LAST_PAGE_NUMBER = (MEMORY_SIZE -
|
|
39812
|
+
const MIN_ALLOCATION_LENGTH = memory_consts_PAGE_SIZE >> MIN_ALLOCATION_SHIFT;
|
|
39813
|
+
const LAST_PAGE_NUMBER = (MEMORY_SIZE - memory_consts_PAGE_SIZE) / memory_consts_PAGE_SIZE;
|
|
39832
39814
|
/** https://graypaper.fluffylabs.dev/#/68eaa1f/35a60235a602?v=0.6.4 */
|
|
39833
39815
|
const RESERVED_NUMBER_OF_PAGES = 16;
|
|
39834
39816
|
/** https://graypaper.fluffylabs.dev/#/68eaa1f/35a60235a602?v=0.6.4 */
|
|
39835
|
-
const MAX_NUMBER_OF_PAGES = MEMORY_SIZE /
|
|
39817
|
+
const MAX_NUMBER_OF_PAGES = MEMORY_SIZE / memory_consts_PAGE_SIZE;
|
|
39836
39818
|
|
|
39837
39819
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/memory/pages/page-utils.ts
|
|
39838
39820
|
|
|
39839
39821
|
|
|
39840
39822
|
/** Ensure that given memory `index` is within `[0...PAGE_SIZE)` and can be used to index a page */
|
|
39841
39823
|
const tryAsPageIndex = (index) => {
|
|
39842
|
-
debug_check `${index >= 0 && index <
|
|
39824
|
+
debug_check `${index >= 0 && index < memory_consts_PAGE_SIZE}, Incorect page index: ${index}!`;
|
|
39843
39825
|
return opaque_asOpaqueType(index);
|
|
39844
39826
|
};
|
|
39845
39827
|
/** Ensure that given `index` represents an index of one of the pages. */
|
|
@@ -39867,17 +39849,17 @@ function getNextPageNumber(pageNumber) {
|
|
|
39867
39849
|
|
|
39868
39850
|
|
|
39869
39851
|
function alignToPageSize(length) {
|
|
39870
|
-
return
|
|
39852
|
+
return memory_consts_PAGE_SIZE * Math.ceil(length / memory_consts_PAGE_SIZE);
|
|
39871
39853
|
}
|
|
39872
39854
|
function getPageNumber(address) {
|
|
39873
39855
|
return tryAsPageNumber(address >>> memory_consts_PAGE_SIZE_SHIFT);
|
|
39874
39856
|
}
|
|
39875
39857
|
function getStartPageIndex(address) {
|
|
39876
|
-
return
|
|
39858
|
+
return memory_index_tryAsMemoryIndex((address >>> memory_consts_PAGE_SIZE_SHIFT) << memory_consts_PAGE_SIZE_SHIFT);
|
|
39877
39859
|
}
|
|
39878
39860
|
function getStartPageIndexFromPageNumber(pageNumber) {
|
|
39879
39861
|
// >>> 0 is needed to avoid changing sign of the number
|
|
39880
|
-
return
|
|
39862
|
+
return memory_index_tryAsMemoryIndex((pageNumber << memory_consts_PAGE_SIZE_SHIFT) >>> 0);
|
|
39881
39863
|
}
|
|
39882
39864
|
|
|
39883
39865
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/memory/errors.ts
|
|
@@ -39899,7 +39881,7 @@ class PageFault {
|
|
|
39899
39881
|
return new PageFault(numbers_tryAsU32(startPageIndex), isAccessFault);
|
|
39900
39882
|
}
|
|
39901
39883
|
static fromMemoryIndex(maybeMemoryIndex, isAccessFault = false) {
|
|
39902
|
-
const memoryIndex =
|
|
39884
|
+
const memoryIndex = memory_index_tryAsMemoryIndex(maybeMemoryIndex % MEMORY_SIZE);
|
|
39903
39885
|
const startPageIndex = getStartPageIndex(memoryIndex);
|
|
39904
39886
|
return new PageFault(numbers_tryAsU32(startPageIndex), isAccessFault);
|
|
39905
39887
|
}
|
|
@@ -39978,9 +39960,9 @@ class MemoryRange {
|
|
|
39978
39960
|
constructor(start, length) {
|
|
39979
39961
|
this.start = start;
|
|
39980
39962
|
this.length = length;
|
|
39981
|
-
this.end =
|
|
39963
|
+
this.end = memory_index_tryAsMemoryIndex((this.start + this.length) % MEMORY_SIZE);
|
|
39982
39964
|
if (length > 0) {
|
|
39983
|
-
this.lastIndex =
|
|
39965
|
+
this.lastIndex = memory_index_tryAsMemoryIndex((this.end - 1 + MEMORY_SIZE) % MEMORY_SIZE);
|
|
39984
39966
|
}
|
|
39985
39967
|
}
|
|
39986
39968
|
/** Creates a memory range from given starting point and length */
|
|
@@ -40023,7 +40005,7 @@ class MemoryRange {
|
|
|
40023
40005
|
*
|
|
40024
40006
|
* it should be in `memory-consts` but it cannot be there because of circular dependency
|
|
40025
40007
|
*/
|
|
40026
|
-
const RESERVED_MEMORY_RANGE = MemoryRange.fromStartAndLength(
|
|
40008
|
+
const RESERVED_MEMORY_RANGE = MemoryRange.fromStartAndLength(memory_index_tryAsMemoryIndex(0), RESERVED_NUMBER_OF_PAGES * memory_consts_PAGE_SIZE);
|
|
40027
40009
|
|
|
40028
40010
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/memory/page-range.ts
|
|
40029
40011
|
|
|
@@ -40061,7 +40043,7 @@ class PageRange {
|
|
|
40061
40043
|
// lastIndex is not null because we just ensured that the range is not empty
|
|
40062
40044
|
const pageWithLastIndex = getPageNumber(range.lastIndex ?? range.end);
|
|
40063
40045
|
const endPage = getNextPageNumber(pageWithLastIndex);
|
|
40064
|
-
if ((startPage === endPage || startPage === pageWithLastIndex) && range.length >
|
|
40046
|
+
if ((startPage === endPage || startPage === pageWithLastIndex) && range.length > memory_consts_PAGE_SIZE) {
|
|
40065
40047
|
// full range
|
|
40066
40048
|
return new PageRange(startPage, MAX_NUMBER_OF_PAGES);
|
|
40067
40049
|
}
|
|
@@ -40125,8 +40107,8 @@ class ReadablePage extends MemoryPage {
|
|
|
40125
40107
|
}
|
|
40126
40108
|
loadInto(result, startIndex, length) {
|
|
40127
40109
|
const endIndex = startIndex + length;
|
|
40128
|
-
if (endIndex >
|
|
40129
|
-
return result_Result.error(PageFault.fromMemoryIndex(this.start +
|
|
40110
|
+
if (endIndex > memory_consts_PAGE_SIZE) {
|
|
40111
|
+
return result_Result.error(PageFault.fromMemoryIndex(this.start + memory_consts_PAGE_SIZE), () => `Page fault: read beyond page boundary at ${this.start + memory_consts_PAGE_SIZE}`);
|
|
40130
40112
|
}
|
|
40131
40113
|
const bytes = this.data.subarray(startIndex, endIndex);
|
|
40132
40114
|
// we zero the bytes, since data might not yet be initialized at `endIndex`.
|
|
@@ -40159,8 +40141,8 @@ class WriteablePage extends MemoryPage {
|
|
|
40159
40141
|
constructor(pageNumber, initialData) {
|
|
40160
40142
|
super(pageNumber);
|
|
40161
40143
|
const dataLength = initialData?.length ?? 0;
|
|
40162
|
-
const initialPageLength = Math.min(
|
|
40163
|
-
this.buffer = new ArrayBuffer(initialPageLength, { maxByteLength:
|
|
40144
|
+
const initialPageLength = Math.min(memory_consts_PAGE_SIZE, Math.max(dataLength, MIN_ALLOCATION_LENGTH));
|
|
40145
|
+
this.buffer = new ArrayBuffer(initialPageLength, { maxByteLength: memory_consts_PAGE_SIZE });
|
|
40164
40146
|
this.view = new Uint8Array(this.buffer);
|
|
40165
40147
|
if (initialData !== undefined) {
|
|
40166
40148
|
this.view.set(initialData);
|
|
@@ -40168,8 +40150,8 @@ class WriteablePage extends MemoryPage {
|
|
|
40168
40150
|
}
|
|
40169
40151
|
loadInto(result, startIndex, length) {
|
|
40170
40152
|
const endIndex = startIndex + length;
|
|
40171
|
-
if (endIndex >
|
|
40172
|
-
return result_Result.error(PageFault.fromMemoryIndex(this.start +
|
|
40153
|
+
if (endIndex > memory_consts_PAGE_SIZE) {
|
|
40154
|
+
return result_Result.error(PageFault.fromMemoryIndex(this.start + memory_consts_PAGE_SIZE), () => `Page fault: read beyond page boundary at ${this.start + memory_consts_PAGE_SIZE}`);
|
|
40173
40155
|
}
|
|
40174
40156
|
const bytes = this.view.subarray(startIndex, endIndex);
|
|
40175
40157
|
// we zero the bytes, since the view might not yet be initialized at `endIndex`.
|
|
@@ -40178,16 +40160,16 @@ class WriteablePage extends MemoryPage {
|
|
|
40178
40160
|
return result_Result.ok(result_OK);
|
|
40179
40161
|
}
|
|
40180
40162
|
storeFrom(startIndex, bytes) {
|
|
40181
|
-
if (this.buffer.byteLength < startIndex + bytes.length && this.buffer.byteLength <
|
|
40182
|
-
const newLength = Math.min(
|
|
40163
|
+
if (this.buffer.byteLength < startIndex + bytes.length && this.buffer.byteLength < memory_consts_PAGE_SIZE) {
|
|
40164
|
+
const newLength = Math.min(memory_consts_PAGE_SIZE, Math.max(MIN_ALLOCATION_LENGTH, startIndex + bytes.length));
|
|
40183
40165
|
this.buffer.resize(newLength);
|
|
40184
40166
|
}
|
|
40185
40167
|
this.view.set(bytes, startIndex);
|
|
40186
40168
|
return result_Result.ok(result_OK);
|
|
40187
40169
|
}
|
|
40188
40170
|
setData(pageIndex, data) {
|
|
40189
|
-
if (this.buffer.byteLength < pageIndex + data.length && this.buffer.byteLength <
|
|
40190
|
-
const newLength = Math.min(
|
|
40171
|
+
if (this.buffer.byteLength < pageIndex + data.length && this.buffer.byteLength < memory_consts_PAGE_SIZE) {
|
|
40172
|
+
const newLength = Math.min(memory_consts_PAGE_SIZE, Math.max(MIN_ALLOCATION_LENGTH, pageIndex + data.length));
|
|
40191
40173
|
this.buffer.resize(newLength);
|
|
40192
40174
|
}
|
|
40193
40175
|
this.view.set(data, pageIndex);
|
|
@@ -40238,10 +40220,10 @@ class Memory {
|
|
|
40238
40220
|
this.memory = memory;
|
|
40239
40221
|
}
|
|
40240
40222
|
store(address, bytes) {
|
|
40241
|
-
return this.storeFrom(
|
|
40223
|
+
return this.storeFrom(memory_index_tryAsMemoryIndex(address), bytes);
|
|
40242
40224
|
}
|
|
40243
40225
|
read(address, output) {
|
|
40244
|
-
return this.loadInto(output,
|
|
40226
|
+
return this.loadInto(output, memory_index_tryAsMemoryIndex(address));
|
|
40245
40227
|
}
|
|
40246
40228
|
reset() {
|
|
40247
40229
|
this.sbrkIndex = tryAsSbrkIndex(RESERVED_MEMORY_RANGE.end);
|
|
@@ -40268,8 +40250,8 @@ class Memory {
|
|
|
40268
40250
|
let currentPosition = address;
|
|
40269
40251
|
let bytesLeft = bytes.length;
|
|
40270
40252
|
for (const page of pages) {
|
|
40271
|
-
const pageStartIndex = tryAsPageIndex(currentPosition %
|
|
40272
|
-
const bytesToWrite = Math.min(
|
|
40253
|
+
const pageStartIndex = tryAsPageIndex(currentPosition % memory_consts_PAGE_SIZE);
|
|
40254
|
+
const bytesToWrite = Math.min(memory_consts_PAGE_SIZE - pageStartIndex, bytesLeft);
|
|
40273
40255
|
const sourceStartIndex = currentPosition - address;
|
|
40274
40256
|
const source = bytes.subarray(sourceStartIndex, sourceStartIndex + bytesToWrite);
|
|
40275
40257
|
page.storeFrom(pageStartIndex, source);
|
|
@@ -40318,8 +40300,8 @@ class Memory {
|
|
|
40318
40300
|
let currentPosition = startAddress;
|
|
40319
40301
|
let bytesLeft = result.length;
|
|
40320
40302
|
for (const page of pages) {
|
|
40321
|
-
const pageStartIndex = tryAsPageIndex(currentPosition %
|
|
40322
|
-
const bytesToRead = Math.min(
|
|
40303
|
+
const pageStartIndex = tryAsPageIndex(currentPosition % memory_consts_PAGE_SIZE);
|
|
40304
|
+
const bytesToRead = Math.min(memory_consts_PAGE_SIZE - pageStartIndex, bytesLeft);
|
|
40323
40305
|
const destinationStartIndex = currentPosition - startAddress;
|
|
40324
40306
|
const destination = result.subarray(destinationStartIndex);
|
|
40325
40307
|
page.loadInto(destination, pageStartIndex, bytesToRead);
|
|
@@ -40346,7 +40328,7 @@ class Memory {
|
|
|
40346
40328
|
const newSbrkIndex = tryAsSbrkIndex(alignToPageSize(newVirtualSbrkIndex));
|
|
40347
40329
|
// TODO [MaSi]: `getPageNumber` works incorrectly for SbrkIndex. Sbrk index should be changed to MemoryIndex
|
|
40348
40330
|
const firstPageNumber = getPageNumber(currentSbrkIndex);
|
|
40349
|
-
const pagesToAllocate = (newSbrkIndex - currentSbrkIndex) /
|
|
40331
|
+
const pagesToAllocate = (newSbrkIndex - currentSbrkIndex) / memory_consts_PAGE_SIZE;
|
|
40350
40332
|
const rangeToAllocate = PageRange.fromStartAndLength(firstPageNumber, pagesToAllocate);
|
|
40351
40333
|
for (const pageNumber of rangeToAllocate) {
|
|
40352
40334
|
const page = new WriteablePage(pageNumber);
|
|
@@ -40401,8 +40383,8 @@ class MemoryBuilder {
|
|
|
40401
40383
|
setReadablePages(start, end, data = new Uint8Array()) {
|
|
40402
40384
|
this.ensureNotFinalized();
|
|
40403
40385
|
debug_check `${start < end} end has to be bigger than start`;
|
|
40404
|
-
debug_check `${start %
|
|
40405
|
-
debug_check `${end %
|
|
40386
|
+
debug_check `${start % memory_consts_PAGE_SIZE === 0} start needs to be a multiple of page size (${memory_consts_PAGE_SIZE})`;
|
|
40387
|
+
debug_check `${end % memory_consts_PAGE_SIZE === 0} end needs to be a multiple of page size (${memory_consts_PAGE_SIZE})`;
|
|
40406
40388
|
debug_check `${data.length <= end - start} the initial data is longer than address range`;
|
|
40407
40389
|
const length = end - start;
|
|
40408
40390
|
const range = MemoryRange.fromStartAndLength(start, length);
|
|
@@ -40411,7 +40393,7 @@ class MemoryBuilder {
|
|
|
40411
40393
|
const noOfPages = pages.length;
|
|
40412
40394
|
for (let i = 0; i < noOfPages; i++) {
|
|
40413
40395
|
const pageNumber = pages[i];
|
|
40414
|
-
const dataChunk = data.subarray(i *
|
|
40396
|
+
const dataChunk = data.subarray(i * memory_consts_PAGE_SIZE, (i + 1) * memory_consts_PAGE_SIZE);
|
|
40415
40397
|
const page = new ReadablePage(pageNumber, dataChunk);
|
|
40416
40398
|
this.initialMemory.set(pageNumber, page);
|
|
40417
40399
|
}
|
|
@@ -40429,8 +40411,8 @@ class MemoryBuilder {
|
|
|
40429
40411
|
setWriteablePages(start, end, data = new Uint8Array()) {
|
|
40430
40412
|
this.ensureNotFinalized();
|
|
40431
40413
|
debug_check `${start < end} end has to be bigger than start`;
|
|
40432
|
-
debug_check `${start %
|
|
40433
|
-
debug_check `${end %
|
|
40414
|
+
debug_check `${start % memory_consts_PAGE_SIZE === 0} start needs to be a multiple of page size (${memory_consts_PAGE_SIZE})`;
|
|
40415
|
+
debug_check `${end % memory_consts_PAGE_SIZE === 0} end needs to be a multiple of page size (${memory_consts_PAGE_SIZE})`;
|
|
40434
40416
|
debug_check `${data.length <= end - start} the initial data is longer than address range`;
|
|
40435
40417
|
const length = end - start;
|
|
40436
40418
|
const range = MemoryRange.fromStartAndLength(start, length);
|
|
@@ -40439,7 +40421,7 @@ class MemoryBuilder {
|
|
|
40439
40421
|
const noOfPages = pages.length;
|
|
40440
40422
|
for (let i = 0; i < noOfPages; i++) {
|
|
40441
40423
|
const pageNumber = pages[i];
|
|
40442
|
-
const dataChunk = data.subarray(i *
|
|
40424
|
+
const dataChunk = data.subarray(i * memory_consts_PAGE_SIZE, (i + 1) * memory_consts_PAGE_SIZE);
|
|
40443
40425
|
const page = new WriteablePage(pageNumber, dataChunk);
|
|
40444
40426
|
this.initialMemory.set(pageNumber, page);
|
|
40445
40427
|
}
|
|
@@ -40451,8 +40433,8 @@ class MemoryBuilder {
|
|
|
40451
40433
|
*/
|
|
40452
40434
|
setData(start, data) {
|
|
40453
40435
|
this.ensureNotFinalized();
|
|
40454
|
-
const pageOffset = start %
|
|
40455
|
-
const remainingSpaceOnPage =
|
|
40436
|
+
const pageOffset = start % memory_consts_PAGE_SIZE;
|
|
40437
|
+
const remainingSpaceOnPage = memory_consts_PAGE_SIZE - pageOffset;
|
|
40456
40438
|
debug_check `${data.length <= remainingSpaceOnPage} The data has to fit into a single page.`;
|
|
40457
40439
|
const length = data.length;
|
|
40458
40440
|
const range = MemoryRange.fromStartAndLength(start, length);
|
|
@@ -40643,27 +40625,27 @@ class Program {
|
|
|
40643
40625
|
static fromSpi(blob, args, hasMetadata) {
|
|
40644
40626
|
const { code: spiCode, metadata } = hasMetadata ? extractCodeAndMetadata(blob) : { code: blob };
|
|
40645
40627
|
const { code, memory: rawMemory, registers } = decodeStandardProgram(spiCode, args);
|
|
40646
|
-
const regs = new
|
|
40628
|
+
const regs = new registers_Registers();
|
|
40647
40629
|
regs.copyFrom(registers);
|
|
40648
40630
|
const memoryBuilder = new MemoryBuilder();
|
|
40649
40631
|
for (const { start, end, data } of rawMemory.readable) {
|
|
40650
|
-
const startIndex =
|
|
40651
|
-
const endIndex =
|
|
40632
|
+
const startIndex = memory_index_tryAsMemoryIndex(start);
|
|
40633
|
+
const endIndex = memory_index_tryAsMemoryIndex(end);
|
|
40652
40634
|
memoryBuilder.setReadablePages(startIndex, endIndex, data ?? new Uint8Array());
|
|
40653
40635
|
}
|
|
40654
40636
|
for (const { start, end, data } of rawMemory.writeable) {
|
|
40655
|
-
const startIndex =
|
|
40656
|
-
const endIndex =
|
|
40637
|
+
const startIndex = memory_index_tryAsMemoryIndex(start);
|
|
40638
|
+
const endIndex = memory_index_tryAsMemoryIndex(end);
|
|
40657
40639
|
memoryBuilder.setWriteablePages(startIndex, endIndex, data ?? new Uint8Array());
|
|
40658
40640
|
}
|
|
40659
|
-
const heapStart =
|
|
40641
|
+
const heapStart = memory_index_tryAsMemoryIndex(rawMemory.sbrkIndex);
|
|
40660
40642
|
const heapEnd = tryAsSbrkIndex(rawMemory.heapEnd);
|
|
40661
40643
|
const memory = memoryBuilder.finalize(heapStart, heapEnd);
|
|
40662
40644
|
return new Program(code, regs, memory, metadata);
|
|
40663
40645
|
}
|
|
40664
40646
|
static fromGeneric(blob, hasMetadata) {
|
|
40665
40647
|
const { code, metadata } = hasMetadata ? extractCodeAndMetadata(blob) : { code: blob };
|
|
40666
|
-
const regs = new
|
|
40648
|
+
const regs = new registers_Registers();
|
|
40667
40649
|
const memory = new Memory();
|
|
40668
40650
|
return new Program(code, regs, memory, metadata);
|
|
40669
40651
|
}
|
|
@@ -41678,6 +41660,45 @@ class BasicBlocks {
|
|
|
41678
41660
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/basic-blocks/index.ts
|
|
41679
41661
|
|
|
41680
41662
|
|
|
41663
|
+
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/gas.ts
|
|
41664
|
+
|
|
41665
|
+
|
|
41666
|
+
/** Create a new gas counter instance depending on the gas value. */
|
|
41667
|
+
function gasCounter(gas) {
|
|
41668
|
+
return new GasCounterU64(numbers_tryAsU64(gas));
|
|
41669
|
+
}
|
|
41670
|
+
class GasCounterU64 {
|
|
41671
|
+
gas;
|
|
41672
|
+
initialGas;
|
|
41673
|
+
constructor(gas) {
|
|
41674
|
+
this.gas = gas;
|
|
41675
|
+
this.initialGas = gas_tryAsGas(gas);
|
|
41676
|
+
}
|
|
41677
|
+
set(g) {
|
|
41678
|
+
this.gas = numbers_tryAsU64(g);
|
|
41679
|
+
}
|
|
41680
|
+
get() {
|
|
41681
|
+
return gas_tryAsGas(this.gas);
|
|
41682
|
+
}
|
|
41683
|
+
sub(g) {
|
|
41684
|
+
const result = this.gas - numbers_tryAsU64(g);
|
|
41685
|
+
if (result >= 0n) {
|
|
41686
|
+
this.gas = numbers_tryAsU64(result);
|
|
41687
|
+
return false;
|
|
41688
|
+
}
|
|
41689
|
+
this.gas = numbers_tryAsU64(0n);
|
|
41690
|
+
return true;
|
|
41691
|
+
}
|
|
41692
|
+
used() {
|
|
41693
|
+
const gasConsumed = numbers_tryAsU64(this.initialGas) - this.gas;
|
|
41694
|
+
// In we have less than zero left we assume that all gas has been consumed.
|
|
41695
|
+
if (gasConsumed < 0) {
|
|
41696
|
+
return this.initialGas;
|
|
41697
|
+
}
|
|
41698
|
+
return gas_tryAsGas(gasConsumed);
|
|
41699
|
+
}
|
|
41700
|
+
}
|
|
41701
|
+
|
|
41681
41702
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/instruction-gas-map.ts
|
|
41682
41703
|
|
|
41683
41704
|
|
|
@@ -42254,7 +42275,7 @@ class LoadOps {
|
|
|
42254
42275
|
}
|
|
42255
42276
|
loadNumber(address, registerIndex, numberLength) {
|
|
42256
42277
|
const registerBytes = this.regs.getBytesAsLittleEndian(registerIndex, REG_SIZE_BYTES);
|
|
42257
|
-
const loadResult = this.memory.loadInto(registerBytes.subarray(0, numberLength),
|
|
42278
|
+
const loadResult = this.memory.loadInto(registerBytes.subarray(0, numberLength), memory_index_tryAsMemoryIndex(address));
|
|
42258
42279
|
if (loadResult.isError) {
|
|
42259
42280
|
if (loadResult.error.isAccessFault) {
|
|
42260
42281
|
this.instructionResult.status = pvm_interpreter_result_Result.FAULT_ACCESS;
|
|
@@ -42270,7 +42291,7 @@ class LoadOps {
|
|
|
42270
42291
|
loadSignedNumber(address, registerIndex, numberLength) {
|
|
42271
42292
|
// load all bytes from register to correctly handle the sign.
|
|
42272
42293
|
const registerBytes = this.regs.getBytesAsLittleEndian(registerIndex, REG_SIZE_BYTES);
|
|
42273
|
-
const loadResult = this.memory.loadInto(registerBytes.subarray(0, numberLength),
|
|
42294
|
+
const loadResult = this.memory.loadInto(registerBytes.subarray(0, numberLength), memory_index_tryAsMemoryIndex(address));
|
|
42274
42295
|
if (loadResult.isError) {
|
|
42275
42296
|
if (loadResult.error.isAccessFault) {
|
|
42276
42297
|
this.instructionResult.status = pvm_interpreter_result_Result.FAULT_ACCESS;
|
|
@@ -42692,7 +42713,7 @@ class StoreOps {
|
|
|
42692
42713
|
this.store(address, secondImmediateDecoder.getExtendedBytesAsLittleEndian());
|
|
42693
42714
|
}
|
|
42694
42715
|
store(address, bytes) {
|
|
42695
|
-
const storeResult = this.memory.storeFrom(
|
|
42716
|
+
const storeResult = this.memory.storeFrom(memory_index_tryAsMemoryIndex(address), bytes);
|
|
42696
42717
|
if (storeResult.isOk) {
|
|
42697
42718
|
return;
|
|
42698
42719
|
}
|
|
@@ -42701,7 +42722,7 @@ class StoreOps {
|
|
|
42701
42722
|
}
|
|
42702
42723
|
else {
|
|
42703
42724
|
this.instructionResult.status = pvm_interpreter_result_Result.FAULT;
|
|
42704
|
-
this.instructionResult.exitParam = getStartPageIndex(
|
|
42725
|
+
this.instructionResult.exitParam = getStartPageIndex(memory_index_tryAsMemoryIndex(storeResult.error.address));
|
|
42705
42726
|
}
|
|
42706
42727
|
}
|
|
42707
42728
|
}
|
|
@@ -43500,11 +43521,11 @@ class ProgramDecoder {
|
|
|
43500
43521
|
|
|
43501
43522
|
|
|
43502
43523
|
const interpreter_logger = logger_Logger.new(import.meta.filename, "pvm");
|
|
43503
|
-
class
|
|
43524
|
+
class interpreter_Interpreter {
|
|
43504
43525
|
useSbrkGas;
|
|
43505
|
-
registers = new
|
|
43526
|
+
registers = new registers_Registers();
|
|
43506
43527
|
memory = new Memory();
|
|
43507
|
-
gas = gasCounter(
|
|
43528
|
+
gas = gasCounter(gas_tryAsGas(0));
|
|
43508
43529
|
code = new Uint8Array();
|
|
43509
43530
|
mask = Mask.empty();
|
|
43510
43531
|
pc = 0;
|
|
@@ -43638,8 +43659,8 @@ class Interpreter {
|
|
|
43638
43659
|
break;
|
|
43639
43660
|
case ArgumentType.TWO_REGISTERS:
|
|
43640
43661
|
if (this.useSbrkGas && currentInstruction === Instruction.SBRK) {
|
|
43641
|
-
const calculateSbrkCost = (length) => (alignToPageSize(length) /
|
|
43642
|
-
const underflow = this.gas.sub(
|
|
43662
|
+
const calculateSbrkCost = (length) => (alignToPageSize(length) / memory_consts_PAGE_SIZE) * 16;
|
|
43663
|
+
const underflow = this.gas.sub(gas_tryAsGas(calculateSbrkCost(this.registers.getLowerU32(argsResult.firstRegisterIndex))));
|
|
43643
43664
|
if (underflow) {
|
|
43644
43665
|
this.status = status_Status.OOG;
|
|
43645
43666
|
return this.status;
|
|
@@ -43734,12 +43755,88 @@ class Interpreter {
|
|
|
43734
43755
|
}
|
|
43735
43756
|
}
|
|
43736
43757
|
|
|
43758
|
+
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/debugger-adapter.ts
|
|
43759
|
+
|
|
43760
|
+
|
|
43761
|
+
|
|
43762
|
+
|
|
43763
|
+
|
|
43764
|
+
|
|
43765
|
+
class DebuggerAdapter {
|
|
43766
|
+
pvm;
|
|
43767
|
+
constructor(useSbrkGas = false) {
|
|
43768
|
+
this.pvm = new Interpreter({ useSbrkGas });
|
|
43769
|
+
}
|
|
43770
|
+
resetGeneric(rawProgram, flatRegisters, initialGas) {
|
|
43771
|
+
this.pvm.resetGeneric(rawProgram, 0, tryAsGas(initialGas), new Registers(flatRegisters));
|
|
43772
|
+
}
|
|
43773
|
+
reset(rawProgram, pc, gas, maybeRegisters, maybeMemory) {
|
|
43774
|
+
this.pvm.resetGeneric(rawProgram, pc, tryAsGas(gas), maybeRegisters, maybeMemory);
|
|
43775
|
+
}
|
|
43776
|
+
getPageDump(pageNumber) {
|
|
43777
|
+
const page = this.pvm.getMemoryPage(pageNumber);
|
|
43778
|
+
if (page === null) {
|
|
43779
|
+
// page wasn't allocated so we return an empty page
|
|
43780
|
+
return safeAllocUint8Array(PAGE_SIZE);
|
|
43781
|
+
}
|
|
43782
|
+
if (page.length === PAGE_SIZE) {
|
|
43783
|
+
// page was allocated and has a proper size so we can simply return it
|
|
43784
|
+
return page;
|
|
43785
|
+
}
|
|
43786
|
+
// page was allocated but it is shorter than PAGE_SIZE so we have to extend it
|
|
43787
|
+
const fullPage = safeAllocUint8Array(PAGE_SIZE);
|
|
43788
|
+
fullPage.set(page);
|
|
43789
|
+
return fullPage;
|
|
43790
|
+
}
|
|
43791
|
+
setMemory(address, value) {
|
|
43792
|
+
this.pvm.memory.storeFrom(tryAsMemoryIndex(address), value);
|
|
43793
|
+
}
|
|
43794
|
+
getExitArg() {
|
|
43795
|
+
return this.pvm.getExitParam() ?? 0;
|
|
43796
|
+
}
|
|
43797
|
+
getStatus() {
|
|
43798
|
+
return this.pvm.getStatus();
|
|
43799
|
+
}
|
|
43800
|
+
nextStep() {
|
|
43801
|
+
return this.pvm.nextStep() === Status.OK;
|
|
43802
|
+
}
|
|
43803
|
+
nSteps(steps) {
|
|
43804
|
+
check `${steps >>> 0 > 0} Expected a positive integer got ${steps}`;
|
|
43805
|
+
for (let i = 0; i < steps; i++) {
|
|
43806
|
+
const isOk = this.nextStep();
|
|
43807
|
+
if (!isOk) {
|
|
43808
|
+
return false;
|
|
43809
|
+
}
|
|
43810
|
+
}
|
|
43811
|
+
return true;
|
|
43812
|
+
}
|
|
43813
|
+
getRegisters() {
|
|
43814
|
+
return this.pvm.registers.getAllU64();
|
|
43815
|
+
}
|
|
43816
|
+
setRegisters(registers) {
|
|
43817
|
+
this.pvm.registers.copyFrom(new Registers(registers));
|
|
43818
|
+
}
|
|
43819
|
+
getProgramCounter() {
|
|
43820
|
+
return this.pvm.getPC();
|
|
43821
|
+
}
|
|
43822
|
+
setNextProgramCounter(nextPc) {
|
|
43823
|
+
this.pvm.setNextPC(nextPc);
|
|
43824
|
+
}
|
|
43825
|
+
getGasLeft() {
|
|
43826
|
+
return BigInt(this.pvm.gas.get());
|
|
43827
|
+
}
|
|
43828
|
+
setGasLeft(gas) {
|
|
43829
|
+
this.pvm.gas.set(tryAsGas(gas));
|
|
43830
|
+
}
|
|
43831
|
+
}
|
|
43832
|
+
|
|
43737
43833
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/index.ts
|
|
43738
43834
|
|
|
43739
43835
|
|
|
43740
43836
|
|
|
43741
43837
|
|
|
43742
43838
|
|
|
43839
|
+
|
|
43743
43840
|
;// CONCATENATED MODULE: ./node_modules/@fluffylabs/anan-as/build/debug-raw.js
|
|
43744
43841
|
async function instantiate(module, imports = {}) {
|
|
43745
43842
|
const adaptedImports = {
|
|
@@ -44193,12 +44290,12 @@ class AnanasMemory {
|
|
|
44193
44290
|
}
|
|
44194
44291
|
class AnanasGasCounter {
|
|
44195
44292
|
instance;
|
|
44196
|
-
initialGas =
|
|
44293
|
+
initialGas = gas_tryAsGas(0n);
|
|
44197
44294
|
constructor(instance) {
|
|
44198
44295
|
this.instance = instance;
|
|
44199
44296
|
}
|
|
44200
44297
|
get() {
|
|
44201
|
-
return
|
|
44298
|
+
return gas_tryAsGas(this.instance.getGasLeft());
|
|
44202
44299
|
}
|
|
44203
44300
|
set(g) {
|
|
44204
44301
|
this.instance.setGasLeft(BigInt(g));
|
|
@@ -44303,7 +44400,7 @@ class InterpreterInstanceManager {
|
|
|
44303
44400
|
const instances = [];
|
|
44304
44401
|
switch (interpreter) {
|
|
44305
44402
|
case PvmBackend.BuiltIn:
|
|
44306
|
-
instances.push(new
|
|
44403
|
+
instances.push(new interpreter_Interpreter({
|
|
44307
44404
|
useSbrkGas: false,
|
|
44308
44405
|
}));
|
|
44309
44406
|
break;
|
|
@@ -44477,10 +44574,10 @@ class Info {
|
|
|
44477
44574
|
const chunk = encodedInfo.raw.subarray(Number(offset), Number(offset + length));
|
|
44478
44575
|
const writeResult = memory.storeFrom(outputStart, chunk);
|
|
44479
44576
|
if (writeResult.isError) {
|
|
44480
|
-
logger_logger.trace `INFO(${serviceId}, off: ${offset}, len: ${length}) <- PANIC`;
|
|
44577
|
+
logger_logger.trace `[${this.currentServiceId}] INFO(${serviceId}, off: ${offset}, len: ${length}) <- PANIC`;
|
|
44481
44578
|
return PvmExecution.Panic;
|
|
44482
44579
|
}
|
|
44483
|
-
logger_logger.trace `INFO(${serviceId}, off: ${offset}, len: ${length}) <- ${bytes_BytesBlob.blobFrom(chunk)}`;
|
|
44580
|
+
logger_logger.trace `[${this.currentServiceId}] INFO(${serviceId}, off: ${offset}, len: ${length}) <- ${bytes_BytesBlob.blobFrom(chunk)}`;
|
|
44484
44581
|
if (accountInfo === null) {
|
|
44485
44582
|
regs.set(IN_OUT_REG, HostCallResult.NONE);
|
|
44486
44583
|
return;
|
|
@@ -44704,7 +44801,7 @@ class AccumulateExternalities {
|
|
|
44704
44801
|
const bytes = serviceInfo.storageUtilisationBytes - length - LOOKUP_HISTORY_ENTRY_BYTES;
|
|
44705
44802
|
return this.updatedState.updateServiceStorageUtilisation(this.currentServiceId, items, bytes, serviceInfo);
|
|
44706
44803
|
};
|
|
44707
|
-
// https://graypaper.fluffylabs.dev/#/
|
|
44804
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/380802380802?v=0.7.2
|
|
44708
44805
|
if (s.status === PreimageStatusKind.Requested) {
|
|
44709
44806
|
const res = updateStorageUtilisation();
|
|
44710
44807
|
if (res.isError) {
|
|
@@ -44717,7 +44814,7 @@ class AccumulateExternalities {
|
|
|
44717
44814
|
return result_Result.ok(result_OK);
|
|
44718
44815
|
}
|
|
44719
44816
|
const t = this.currentTimeslot;
|
|
44720
|
-
// https://graypaper.fluffylabs.dev/#/
|
|
44817
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/380802380802?v=0.7.2
|
|
44721
44818
|
if (s.status === PreimageStatusKind.Unavailable) {
|
|
44722
44819
|
const y = s.data[1];
|
|
44723
44820
|
if (y < t - this.chainSpec.preimageExpungePeriod) {
|
|
@@ -44733,14 +44830,14 @@ class AccumulateExternalities {
|
|
|
44733
44830
|
}
|
|
44734
44831
|
return result_Result.error(ForgetPreimageError.NotExpired, () => `Preimage not expired: y=${y}, timeslot=${t}, period=${this.chainSpec.preimageExpungePeriod}`);
|
|
44735
44832
|
}
|
|
44736
|
-
// https://graypaper.fluffylabs.dev/#/
|
|
44833
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/382802383302?v=0.7.2
|
|
44737
44834
|
if (s.status === PreimageStatusKind.Available) {
|
|
44738
44835
|
this.updatedState.updatePreimage(serviceId, UpdatePreimage.updateOrAdd({
|
|
44739
44836
|
lookupHistory: new LookupHistoryItem(status.hash, status.length, tryAsLookupHistorySlots([s.data[0], t])),
|
|
44740
44837
|
}));
|
|
44741
44838
|
return result_Result.ok(result_OK);
|
|
44742
44839
|
}
|
|
44743
|
-
// https://graypaper.fluffylabs.dev/#/
|
|
44840
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/384002384c02?v=0.7.2
|
|
44744
44841
|
if (s.status === PreimageStatusKind.Reavailable) {
|
|
44745
44842
|
const y = s.data[1];
|
|
44746
44843
|
if (y < t - this.chainSpec.preimageExpungePeriod) {
|
|
@@ -45900,12 +45997,12 @@ function createMergeContext(chainSpec, state, inputState, results) {
|
|
|
45900
45997
|
}
|
|
45901
45998
|
function updatePrivilegedService(currentServiceId, serviceIdUpdatedByManager, selfUpdatedServiceId) {
|
|
45902
45999
|
if (currentServiceId === serviceIdUpdatedByManager) {
|
|
45903
|
-
return
|
|
46000
|
+
return selfUpdatedServiceId;
|
|
45904
46001
|
}
|
|
45905
|
-
return
|
|
46002
|
+
return serviceIdUpdatedByManager;
|
|
45906
46003
|
}
|
|
45907
46004
|
function mergePrivilegedServices(mergeContext, [serviceId, { stateUpdate }]) {
|
|
45908
|
-
const { outputState, currentPrivilegedServices, chainSpec } = mergeContext;
|
|
46005
|
+
const { outputState, currentPrivilegedServices, chainSpec, privilegedServicesUpdatedByManager } = mergeContext;
|
|
45909
46006
|
const currentManager = currentPrivilegedServices.manager;
|
|
45910
46007
|
const currentRegistrar = currentPrivilegedServices.registrar;
|
|
45911
46008
|
const currentDelegator = currentPrivilegedServices.delegator;
|
|
@@ -45923,28 +46020,35 @@ function mergePrivilegedServices(mergeContext, [serviceId, { stateUpdate }]) {
|
|
|
45923
46020
|
});
|
|
45924
46021
|
}
|
|
45925
46022
|
if (serviceId === currentRegistrar) {
|
|
45926
|
-
const newRegistrar = updatePrivilegedService(currentPrivilegedServices.registrar,
|
|
46023
|
+
const newRegistrar = updatePrivilegedService(currentPrivilegedServices.registrar, privilegedServicesUpdatedByManager.registrar, privilegedServices.registrar);
|
|
45927
46024
|
outputState.privilegedServices = PrivilegedServices.create({
|
|
45928
46025
|
...outputState.privilegedServices,
|
|
45929
46026
|
registrar: newRegistrar,
|
|
45930
46027
|
});
|
|
45931
46028
|
}
|
|
45932
46029
|
if (serviceId === currentDelegator) {
|
|
45933
|
-
const newDelegator = updatePrivilegedService(currentPrivilegedServices.delegator,
|
|
46030
|
+
const newDelegator = updatePrivilegedService(currentPrivilegedServices.delegator, privilegedServicesUpdatedByManager.delegator, privilegedServices.delegator);
|
|
45934
46031
|
outputState.privilegedServices = PrivilegedServices.create({
|
|
45935
46032
|
...outputState.privilegedServices,
|
|
45936
46033
|
delegator: newDelegator,
|
|
45937
46034
|
});
|
|
45938
46035
|
}
|
|
45939
|
-
|
|
45940
|
-
const newAssigners = currentAssigners.map((currentAssigner, coreIndex) =>
|
|
45941
|
-
|
|
45942
|
-
|
|
45943
|
-
|
|
45944
|
-
|
|
45945
|
-
|
|
45946
|
-
|
|
46036
|
+
let shouldUpdateAssigners = false;
|
|
46037
|
+
const newAssigners = currentAssigners.map((currentAssigner, coreIndex) => {
|
|
46038
|
+
if (serviceId === currentAssigner) {
|
|
46039
|
+
const newAssigner = updatePrivilegedService(currentPrivilegedServices.assigners[coreIndex], privilegedServicesUpdatedByManager.assigners[coreIndex], privilegedServices.assigners[coreIndex]);
|
|
46040
|
+
shouldUpdateAssigners = shouldUpdateAssigners || newAssigner !== currentAssigner;
|
|
46041
|
+
return newAssigner;
|
|
46042
|
+
}
|
|
46043
|
+
return currentAssigner;
|
|
45947
46044
|
});
|
|
46045
|
+
if (shouldUpdateAssigners) {
|
|
46046
|
+
const newAssignersPerCore = tryAsPerCore(newAssigners, chainSpec);
|
|
46047
|
+
outputState.privilegedServices = PrivilegedServices.create({
|
|
46048
|
+
...outputState.privilegedServices,
|
|
46049
|
+
assigners: newAssignersPerCore,
|
|
46050
|
+
});
|
|
46051
|
+
}
|
|
45948
46052
|
}
|
|
45949
46053
|
}
|
|
45950
46054
|
function mergeValidatorsData(mergeContext, [serviceId, { stateUpdate }]) {
|
|
@@ -46089,7 +46193,7 @@ class Assign {
|
|
|
46089
46193
|
const memoryReadResult = memory.loadInto(res, authorizationQueueStart);
|
|
46090
46194
|
// error while reading the memory.
|
|
46091
46195
|
if (memoryReadResult.isError) {
|
|
46092
|
-
logger_logger.trace `ASSIGN() <- PANIC`;
|
|
46196
|
+
logger_logger.trace `[${this.currentServiceId}] ASSIGN() <- PANIC`;
|
|
46093
46197
|
return PvmExecution.Panic;
|
|
46094
46198
|
}
|
|
46095
46199
|
if (maybeCoreIndex >= this.chainSpec.coresCount) {
|
|
@@ -46104,18 +46208,18 @@ class Assign {
|
|
|
46104
46208
|
const result = this.partialState.updateAuthorizationQueue(coreIndex, fixedSizeAuthQueue, assigners);
|
|
46105
46209
|
if (result.isOk) {
|
|
46106
46210
|
regs.set(assign_IN_OUT_REG, HostCallResult.OK);
|
|
46107
|
-
logger_logger.trace `ASSIGN(${coreIndex}, ${fixedSizeAuthQueue}) <- OK`;
|
|
46211
|
+
logger_logger.trace `[${this.currentServiceId}] ASSIGN(${coreIndex}, ${fixedSizeAuthQueue}) <- OK`;
|
|
46108
46212
|
return;
|
|
46109
46213
|
}
|
|
46110
46214
|
const e = result.error;
|
|
46111
46215
|
if (e === UpdatePrivilegesError.UnprivilegedService) {
|
|
46112
46216
|
regs.set(assign_IN_OUT_REG, HostCallResult.HUH);
|
|
46113
|
-
logger_logger.trace `ASSIGN(${coreIndex}, ${fixedSizeAuthQueue}) <- HUH`;
|
|
46217
|
+
logger_logger.trace `[${this.currentServiceId}] ASSIGN(${coreIndex}, ${fixedSizeAuthQueue}) <- HUH`;
|
|
46114
46218
|
return;
|
|
46115
46219
|
}
|
|
46116
46220
|
if (e === UpdatePrivilegesError.InvalidServiceId) {
|
|
46117
46221
|
regs.set(assign_IN_OUT_REG, HostCallResult.WHO);
|
|
46118
|
-
logger_logger.trace `ASSIGN(${coreIndex}, ${fixedSizeAuthQueue}) <- HUH`;
|
|
46222
|
+
logger_logger.trace `[${this.currentServiceId}] ASSIGN(${coreIndex}, ${fixedSizeAuthQueue}) <- HUH`;
|
|
46119
46223
|
return;
|
|
46120
46224
|
}
|
|
46121
46225
|
debug_assertNever(e);
|
|
@@ -46186,7 +46290,7 @@ class Bless {
|
|
|
46186
46290
|
decoder.resetTo(0);
|
|
46187
46291
|
const memoryReadResult = memory.loadInto(result, memIndex);
|
|
46188
46292
|
if (memoryReadResult.isError) {
|
|
46189
|
-
logger_logger.trace `BLESS(m: ${manager}, v: ${delegator}, r: ${registrar}) <- PANIC`;
|
|
46293
|
+
logger_logger.trace `[${this.currentServiceId}] BLESS(m: ${manager}, v: ${delegator}, r: ${registrar}) <- PANIC`;
|
|
46190
46294
|
return PvmExecution.Panic;
|
|
46191
46295
|
}
|
|
46192
46296
|
const { serviceId, gas } = decoder.object(serviceIdAndGasCodec);
|
|
@@ -46199,26 +46303,26 @@ class Bless {
|
|
|
46199
46303
|
const authorizersDecoder = decoder_Decoder.fromBlob(res);
|
|
46200
46304
|
const memoryReadResult = memory.loadInto(res, authorization);
|
|
46201
46305
|
if (memoryReadResult.isError) {
|
|
46202
|
-
logger_logger.trace `BLESS(m: ${manager}, v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- PANIC`;
|
|
46306
|
+
logger_logger.trace `[${this.currentServiceId}] BLESS(m: ${manager}, v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- PANIC`;
|
|
46203
46307
|
return PvmExecution.Panic;
|
|
46204
46308
|
}
|
|
46205
46309
|
// `a`
|
|
46206
46310
|
const authorizers = tryAsPerCore(authorizersDecoder.sequenceFixLen(descriptors_codec.u32.asOpaque(), this.chainSpec.coresCount), this.chainSpec);
|
|
46207
46311
|
const updateResult = this.partialState.updatePrivilegedServices(manager, authorizers, delegator, registrar, autoAccumulate);
|
|
46208
46312
|
if (updateResult.isOk) {
|
|
46209
|
-
logger_logger.trace `BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- OK`;
|
|
46313
|
+
logger_logger.trace `[${this.currentServiceId}] BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- OK`;
|
|
46210
46314
|
regs.set(bless_IN_OUT_REG, HostCallResult.OK);
|
|
46211
46315
|
return;
|
|
46212
46316
|
}
|
|
46213
46317
|
const e = updateResult.error;
|
|
46214
46318
|
// NOTE: `UpdatePrivilegesError.UnprivilegedService` won't happen in 0.7.1+
|
|
46215
46319
|
if (e === UpdatePrivilegesError.UnprivilegedService) {
|
|
46216
|
-
logger_logger.trace `BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- HUH`;
|
|
46320
|
+
logger_logger.trace `[${this.currentServiceId}] BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- HUH`;
|
|
46217
46321
|
regs.set(bless_IN_OUT_REG, HostCallResult.HUH);
|
|
46218
46322
|
return;
|
|
46219
46323
|
}
|
|
46220
46324
|
if (e === UpdatePrivilegesError.InvalidServiceId) {
|
|
46221
|
-
logger_logger.trace `BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- WHO`;
|
|
46325
|
+
logger_logger.trace `[${this.currentServiceId}] BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- WHO`;
|
|
46222
46326
|
regs.set(bless_IN_OUT_REG, HostCallResult.WHO);
|
|
46223
46327
|
return;
|
|
46224
46328
|
}
|
|
@@ -46248,7 +46352,7 @@ class GasHostCall {
|
|
|
46248
46352
|
}
|
|
46249
46353
|
execute(gas, regs) {
|
|
46250
46354
|
const gasValue = gas.get();
|
|
46251
|
-
logger_logger.trace `GAS <- ${gasValue}`;
|
|
46355
|
+
logger_logger.trace `[${this.currentServiceId}] GAS <- ${gasValue}`;
|
|
46252
46356
|
regs.set(7, numbers_tryAsU64(gasValue));
|
|
46253
46357
|
return Promise.resolve(undefined);
|
|
46254
46358
|
}
|
|
@@ -46280,7 +46384,7 @@ class Checkpoint {
|
|
|
46280
46384
|
async execute(gas, regs) {
|
|
46281
46385
|
await this.gasHostCall.execute(gas, regs);
|
|
46282
46386
|
this.partialState.checkpoint();
|
|
46283
|
-
logger_logger.trace `CHECKPOINT()`;
|
|
46387
|
+
logger_logger.trace `[${this.currentServiceId}] CHECKPOINT()`;
|
|
46284
46388
|
return;
|
|
46285
46389
|
}
|
|
46286
46390
|
}
|
|
@@ -46320,18 +46424,18 @@ class Designate {
|
|
|
46320
46424
|
const memoryReadResult = memory.loadInto(res, validatorsStart);
|
|
46321
46425
|
// error while reading the memory.
|
|
46322
46426
|
if (memoryReadResult.isError) {
|
|
46323
|
-
logger_logger.trace `DESIGNATE() <- PANIC`;
|
|
46427
|
+
logger_logger.trace `[${this.currentServiceId}] DESIGNATE() <- PANIC`;
|
|
46324
46428
|
return PvmExecution.Panic;
|
|
46325
46429
|
}
|
|
46326
46430
|
const decoder = decoder_Decoder.fromBlob(res);
|
|
46327
46431
|
const validatorsData = decoder.sequenceFixLen(ValidatorData.Codec, this.chainSpec.validatorsCount);
|
|
46328
46432
|
const result = this.partialState.updateValidatorsData(tryAsPerValidator(validatorsData, this.chainSpec));
|
|
46329
46433
|
if (result.isError) {
|
|
46330
|
-
logger_logger.trace `DESIGNATE([${validatorsData[0]}, ${validatorsData[1]}, ...]) <- HUH`;
|
|
46434
|
+
logger_logger.trace `[${this.currentServiceId}] DESIGNATE([${validatorsData[0]}, ${validatorsData[1]}, ...]) <- HUH`;
|
|
46331
46435
|
regs.set(designate_IN_OUT_REG, HostCallResult.HUH);
|
|
46332
46436
|
}
|
|
46333
46437
|
else {
|
|
46334
|
-
logger_logger.trace `DESIGNATE([${validatorsData[0]}, ${validatorsData[1]}, ...]) <- OK`;
|
|
46438
|
+
logger_logger.trace `[${this.currentServiceId}] DESIGNATE([${validatorsData[0]}, ${validatorsData[1]}, ...]) <- OK`;
|
|
46335
46439
|
regs.set(designate_IN_OUT_REG, HostCallResult.OK);
|
|
46336
46440
|
}
|
|
46337
46441
|
}
|
|
@@ -46372,29 +46476,29 @@ class Eject {
|
|
|
46372
46476
|
const previousCodeHash = bytes_Bytes.zero(hash_HASH_SIZE).asOpaque();
|
|
46373
46477
|
const memoryReadResult = memory.loadInto(previousCodeHash.raw, preimageHashStart);
|
|
46374
46478
|
if (memoryReadResult.isError) {
|
|
46375
|
-
logger_logger.trace `EJECT(${serviceId}) <- PANIC`;
|
|
46479
|
+
logger_logger.trace `[${this.currentServiceId}] EJECT(${serviceId}) <- PANIC`;
|
|
46376
46480
|
return PvmExecution.Panic;
|
|
46377
46481
|
}
|
|
46378
46482
|
// cannot eject self
|
|
46379
46483
|
if (serviceId === this.currentServiceId) {
|
|
46380
46484
|
regs.set(eject_IN_OUT_REG, HostCallResult.WHO);
|
|
46381
|
-
logger_logger.trace `EJECT(${serviceId}, ${previousCodeHash}) <- WHO`;
|
|
46485
|
+
logger_logger.trace `[${this.currentServiceId}] EJECT(${serviceId}, ${previousCodeHash}) <- WHO`;
|
|
46382
46486
|
return;
|
|
46383
46487
|
}
|
|
46384
46488
|
const result = this.partialState.eject(serviceId, previousCodeHash);
|
|
46385
46489
|
// All good!
|
|
46386
46490
|
if (result.isOk) {
|
|
46387
|
-
logger_logger.trace `EJECT(${serviceId}, ${previousCodeHash}) <- OK`;
|
|
46491
|
+
logger_logger.trace `[${this.currentServiceId}] EJECT(${serviceId}, ${previousCodeHash}) <- OK`;
|
|
46388
46492
|
regs.set(eject_IN_OUT_REG, HostCallResult.OK);
|
|
46389
46493
|
return;
|
|
46390
46494
|
}
|
|
46391
46495
|
const e = result.error;
|
|
46392
46496
|
if (e === EjectError.InvalidService) {
|
|
46393
|
-
logger_logger.trace `EJECT(${serviceId}, ${previousCodeHash}) <- WHO ${result_resultToString(result)}`;
|
|
46497
|
+
logger_logger.trace `[${this.currentServiceId}] EJECT(${serviceId}, ${previousCodeHash}) <- WHO ${result_resultToString(result)}`;
|
|
46394
46498
|
regs.set(eject_IN_OUT_REG, HostCallResult.WHO);
|
|
46395
46499
|
}
|
|
46396
46500
|
else if (e === EjectError.InvalidPreimage) {
|
|
46397
|
-
logger_logger.trace `EJECT(${serviceId}, ${previousCodeHash}) <- HUH ${result_resultToString(result)}`;
|
|
46501
|
+
logger_logger.trace `[${this.currentServiceId}] EJECT(${serviceId}, ${previousCodeHash}) <- HUH ${result_resultToString(result)}`;
|
|
46398
46502
|
regs.set(eject_IN_OUT_REG, HostCallResult.HUH);
|
|
46399
46503
|
}
|
|
46400
46504
|
else {
|
|
@@ -46413,9 +46517,9 @@ class Eject {
|
|
|
46413
46517
|
|
|
46414
46518
|
const forget_IN_OUT_REG = 7;
|
|
46415
46519
|
/**
|
|
46416
|
-
*
|
|
46520
|
+
* Delete preimage hash or mark as unavailable if it was available.
|
|
46417
46521
|
*
|
|
46418
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
46522
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/385d01385d01?v=0.7.2
|
|
46419
46523
|
*/
|
|
46420
46524
|
class Forget {
|
|
46421
46525
|
currentServiceId;
|
|
@@ -46436,11 +46540,11 @@ class Forget {
|
|
|
46436
46540
|
const memoryReadResult = memory.loadInto(hash.raw, hashStart);
|
|
46437
46541
|
// error while reading the memory.
|
|
46438
46542
|
if (memoryReadResult.isError) {
|
|
46439
|
-
logger_logger.trace `FORGET(${hash}, ${length}) <- PANIC`;
|
|
46543
|
+
logger_logger.trace `[${this.currentServiceId}] FORGET(${hash}, ${length}) <- PANIC`;
|
|
46440
46544
|
return PvmExecution.Panic;
|
|
46441
46545
|
}
|
|
46442
46546
|
const result = this.partialState.forgetPreimage(hash.asOpaque(), length);
|
|
46443
|
-
logger_logger.trace `FORGET(${hash}, ${length}) <- ${result_resultToString(result)}`;
|
|
46547
|
+
logger_logger.trace `[${this.currentServiceId}] FORGET(${hash}, ${length}) <- ${result_resultToString(result)}`;
|
|
46444
46548
|
if (result.isOk) {
|
|
46445
46549
|
regs.set(forget_IN_OUT_REG, HostCallResult.OK);
|
|
46446
46550
|
}
|
|
@@ -46497,11 +46601,11 @@ class New {
|
|
|
46497
46601
|
const memoryReadResult = memory.loadInto(codeHash.raw, codeHashStart);
|
|
46498
46602
|
// error while reading the memory.
|
|
46499
46603
|
if (memoryReadResult.isError) {
|
|
46500
|
-
logger_logger.trace `NEW(${codeHash}, ${codeLength}, ${gas}, ${allowance}, ${gratisStorage}, ${requestedServiceId}) <- PANIC`;
|
|
46604
|
+
logger_logger.trace `[${this.currentServiceId}] NEW(${codeHash}, ${codeLength}, ${gas}, ${allowance}, ${gratisStorage}, ${requestedServiceId}) <- PANIC`;
|
|
46501
46605
|
return PvmExecution.Panic;
|
|
46502
46606
|
}
|
|
46503
46607
|
const assignedId = this.partialState.newService(codeHash.asOpaque(), codeLength, gas, allowance, gratisStorage, requestedServiceId);
|
|
46504
|
-
logger_logger.trace `NEW(${codeHash}, ${codeLength}, ${gas}, ${allowance}, ${gratisStorage}, ${requestedServiceId}) <- ${result_resultToString(assignedId)}`;
|
|
46608
|
+
logger_logger.trace `[${this.currentServiceId}] NEW(${codeHash}, ${codeLength}, ${gas}, ${allowance}, ${gratisStorage}, ${requestedServiceId}) <- ${result_resultToString(assignedId)}`;
|
|
46505
46609
|
if (assignedId.isOk) {
|
|
46506
46610
|
regs.set(new_IN_OUT_REG, numbers_tryAsU64(assignedId.ok));
|
|
46507
46611
|
return;
|
|
@@ -46561,11 +46665,11 @@ class Provide {
|
|
|
46561
46665
|
const preimage = bytes_BytesBlob.blobFrom(safe_alloc_uint8array_safeAllocUint8Array(length));
|
|
46562
46666
|
const memoryReadResult = memory.loadInto(preimage.raw, preimageStart);
|
|
46563
46667
|
if (memoryReadResult.isError) {
|
|
46564
|
-
logger_logger.trace `PROVIDE(${serviceId}, ${preimage.toStringTruncated()}) <- PANIC`;
|
|
46668
|
+
logger_logger.trace `[${this.currentServiceId}] PROVIDE(${serviceId}, ${preimage.toStringTruncated()}) <- PANIC`;
|
|
46565
46669
|
return PvmExecution.Panic;
|
|
46566
46670
|
}
|
|
46567
46671
|
const result = this.partialState.providePreimage(serviceId, preimage);
|
|
46568
|
-
logger_logger.trace `PROVIDE(${serviceId}, ${preimage.toStringTruncated()}) <- ${result_resultToString(result)}`;
|
|
46672
|
+
logger_logger.trace `[${this.currentServiceId}] PROVIDE(${serviceId}, ${preimage.toStringTruncated()}) <- ${result_resultToString(result)}`;
|
|
46569
46673
|
if (result.isOk) {
|
|
46570
46674
|
regs.set(provide_IN_OUT_REG, HostCallResult.OK);
|
|
46571
46675
|
return;
|
|
@@ -46621,35 +46725,35 @@ class Query {
|
|
|
46621
46725
|
const memoryReadResult = memory.loadInto(hash.raw, hashStart);
|
|
46622
46726
|
// error while reading the memory.
|
|
46623
46727
|
if (memoryReadResult.isError) {
|
|
46624
|
-
logger_logger.trace `QUERY(${hash}, ${length}) <- PANIC`;
|
|
46728
|
+
logger_logger.trace `[${this.currentServiceId}] QUERY(${hash}, ${length}) <- PANIC`;
|
|
46625
46729
|
return PvmExecution.Panic;
|
|
46626
46730
|
}
|
|
46627
46731
|
const result = this.partialState.checkPreimageStatus(hash.asOpaque(), length);
|
|
46628
46732
|
const zero = numbers_tryAsU64(0n);
|
|
46629
46733
|
if (result === null) {
|
|
46630
|
-
logger_logger.trace `QUERY(${hash}, ${length}) <- NONE`;
|
|
46734
|
+
logger_logger.trace `[${this.currentServiceId}] QUERY(${hash}, ${length}) <- NONE`;
|
|
46631
46735
|
regs.set(IN_OUT_REG_1, HostCallResult.NONE);
|
|
46632
46736
|
regs.set(IN_OUT_REG_2, zero);
|
|
46633
46737
|
return;
|
|
46634
46738
|
}
|
|
46635
46739
|
switch (result.status) {
|
|
46636
46740
|
case PreimageStatusKind.Requested:
|
|
46637
|
-
logger_logger.trace `QUERY(${hash}, ${length}) <- REQUESTED`;
|
|
46741
|
+
logger_logger.trace `[${this.currentServiceId}] QUERY(${hash}, ${length}) <- REQUESTED`;
|
|
46638
46742
|
regs.set(IN_OUT_REG_1, zero);
|
|
46639
46743
|
regs.set(IN_OUT_REG_2, zero);
|
|
46640
46744
|
return;
|
|
46641
46745
|
case PreimageStatusKind.Available:
|
|
46642
|
-
logger_logger.trace `QUERY(${hash}, ${length}) <- AVAILABLE [${result.data}]`;
|
|
46746
|
+
logger_logger.trace `[${this.currentServiceId}] QUERY(${hash}, ${length}) <- AVAILABLE [${result.data}]`;
|
|
46643
46747
|
regs.set(IN_OUT_REG_1, numbers_tryAsU64((BigInt(result.data[0]) << UPPER_BITS_SHIFT) + 1n));
|
|
46644
46748
|
regs.set(IN_OUT_REG_2, zero);
|
|
46645
46749
|
return;
|
|
46646
46750
|
case PreimageStatusKind.Unavailable:
|
|
46647
|
-
logger_logger.trace `QUERY(${hash}, ${length}) <- UNAVAILABLE [${result.data.join(", ")}]`;
|
|
46751
|
+
logger_logger.trace `[${this.currentServiceId}] QUERY(${hash}, ${length}) <- UNAVAILABLE [${result.data.join(", ")}]`;
|
|
46648
46752
|
regs.set(IN_OUT_REG_1, numbers_tryAsU64((BigInt(result.data[0]) << UPPER_BITS_SHIFT) + 2n));
|
|
46649
46753
|
regs.set(IN_OUT_REG_2, numbers_tryAsU64(result.data[1]));
|
|
46650
46754
|
return;
|
|
46651
46755
|
case PreimageStatusKind.Reavailable:
|
|
46652
|
-
logger_logger.trace `QUERY(${hash}, ${length}) <- REAVAILABLE [${result.data.join(", ")}]`;
|
|
46756
|
+
logger_logger.trace `[${this.currentServiceId}] QUERY(${hash}, ${length}) <- REAVAILABLE [${result.data.join(", ")}]`;
|
|
46653
46757
|
regs.set(IN_OUT_REG_1, numbers_tryAsU64((BigInt(result.data[0]) << UPPER_BITS_SHIFT) + 3n));
|
|
46654
46758
|
regs.set(IN_OUT_REG_2, numbers_tryAsU64((BigInt(result.data[2]) << UPPER_BITS_SHIFT) + BigInt(result.data[1])));
|
|
46655
46759
|
return;
|
|
@@ -46690,11 +46794,11 @@ class Solicit {
|
|
|
46690
46794
|
const hash = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
46691
46795
|
const memoryReadResult = memory.loadInto(hash.raw, hashStart);
|
|
46692
46796
|
if (memoryReadResult.isError) {
|
|
46693
|
-
logger_logger.trace `SOLICIT(${hash}, ${length}) <- PANIC`;
|
|
46797
|
+
logger_logger.trace `[${this.currentServiceId}] SOLICIT(${hash}, ${length}) <- PANIC`;
|
|
46694
46798
|
return PvmExecution.Panic;
|
|
46695
46799
|
}
|
|
46696
46800
|
const result = this.partialState.requestPreimage(hash.asOpaque(), length);
|
|
46697
|
-
logger_logger.trace `SOLICIT(${hash}, ${length}) <- ${result_resultToString(result)}`;
|
|
46801
|
+
logger_logger.trace `[${this.currentServiceId}] SOLICIT(${hash}, ${length}) <- ${result_resultToString(result)}`;
|
|
46698
46802
|
if (result.isOk) {
|
|
46699
46803
|
regs.set(solicit_IN_OUT_REG, HostCallResult.OK);
|
|
46700
46804
|
return;
|
|
@@ -46752,7 +46856,7 @@ class Transfer {
|
|
|
46752
46856
|
*/
|
|
46753
46857
|
basicGasCost = Compatibility.isGreaterOrEqual(GpVersion.V0_7_2)
|
|
46754
46858
|
? gas_tryAsSmallGas(10)
|
|
46755
|
-
: (regs) =>
|
|
46859
|
+
: (regs) => gas_tryAsGas(10n + regs.get(TRANSFER_GAS_FEE_REG));
|
|
46756
46860
|
tracedRegisters = traceRegisters(transfer_IN_OUT_REG, AMOUNT_REG, TRANSFER_GAS_FEE_REG, MEMO_START_REG);
|
|
46757
46861
|
constructor(currentServiceId, partialState) {
|
|
46758
46862
|
this.currentServiceId = currentServiceId;
|
|
@@ -46771,16 +46875,16 @@ class Transfer {
|
|
|
46771
46875
|
const memoryReadResult = memory.loadInto(memo.raw, memoStart);
|
|
46772
46876
|
// page fault while reading the memory.
|
|
46773
46877
|
if (memoryReadResult.isError) {
|
|
46774
|
-
logger_logger.trace `TRANSFER(${destination}, ${amount}, ${transferGasFee}, ${memo}) <- PANIC`;
|
|
46878
|
+
logger_logger.trace `[${this.currentServiceId}] TRANSFER(${destination}, ${amount}, ${transferGasFee}, ${memo}) <- PANIC`;
|
|
46775
46879
|
return PvmExecution.Panic;
|
|
46776
46880
|
}
|
|
46777
46881
|
const transferResult = this.partialState.transfer(destination, amount, transferGasFee, memo);
|
|
46778
|
-
logger_logger.trace `TRANSFER(${destination}, ${amount}, ${transferGasFee}, ${memo}) <- ${result_resultToString(transferResult)}`;
|
|
46882
|
+
logger_logger.trace `[${this.currentServiceId}] TRANSFER(${destination}, ${amount}, ${transferGasFee}, ${memo}) <- ${result_resultToString(transferResult)}`;
|
|
46779
46883
|
// All good!
|
|
46780
46884
|
if (transferResult.isOk) {
|
|
46781
46885
|
if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_2)) {
|
|
46782
46886
|
// substracting value `t`
|
|
46783
|
-
const underflow = gas.sub(
|
|
46887
|
+
const underflow = gas.sub(gas_tryAsGas(transferGasFee));
|
|
46784
46888
|
if (underflow) {
|
|
46785
46889
|
return PvmExecution.OOG;
|
|
46786
46890
|
}
|
|
@@ -46841,11 +46945,11 @@ class Upgrade {
|
|
|
46841
46945
|
const codeHash = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
46842
46946
|
const memoryReadResult = memory.loadInto(codeHash.raw, codeHashStart);
|
|
46843
46947
|
if (memoryReadResult.isError) {
|
|
46844
|
-
logger_logger.trace `UPGRADE(${codeHash}, ${gas}, ${allowance}) <- PANIC`;
|
|
46948
|
+
logger_logger.trace `[${this.currentServiceId}] UPGRADE(${codeHash}, ${gas}, ${allowance}) <- PANIC`;
|
|
46845
46949
|
return PvmExecution.Panic;
|
|
46846
46950
|
}
|
|
46847
46951
|
this.partialState.upgradeService(codeHash.asOpaque(), gas, allowance);
|
|
46848
|
-
logger_logger.trace `UPGRADE(${codeHash}, ${gas}, ${allowance})`;
|
|
46952
|
+
logger_logger.trace `[${this.currentServiceId}] UPGRADE(${codeHash}, ${gas}, ${allowance})`;
|
|
46849
46953
|
regs.set(upgrade_IN_OUT_REG, HostCallResult.OK);
|
|
46850
46954
|
}
|
|
46851
46955
|
}
|
|
@@ -46879,11 +46983,11 @@ class Yield {
|
|
|
46879
46983
|
const hash = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
46880
46984
|
const memoryReadResult = memory.loadInto(hash.raw, hashStart);
|
|
46881
46985
|
if (memoryReadResult.isError) {
|
|
46882
|
-
logger_logger.trace `YIELD() <- PANIC`;
|
|
46986
|
+
logger_logger.trace `[${this.currentServiceId}] YIELD() <- PANIC`;
|
|
46883
46987
|
return PvmExecution.Panic;
|
|
46884
46988
|
}
|
|
46885
46989
|
this.partialState.yield(hash);
|
|
46886
|
-
logger_logger.trace `YIELD(${hash})`;
|
|
46990
|
+
logger_logger.trace `[${this.currentServiceId}] YIELD(${hash})`;
|
|
46887
46991
|
regs.set(yield_IN_OUT_REG, HostCallResult.OK);
|
|
46888
46992
|
}
|
|
46889
46993
|
}
|
|
@@ -46926,10 +47030,10 @@ class Fetch {
|
|
|
46926
47030
|
const chunk = value === null ? new Uint8Array() : value.raw.subarray(Number(offset), Number(offset + length));
|
|
46927
47031
|
const storeResult = memory.storeFrom(output, chunk);
|
|
46928
47032
|
if (storeResult.isError) {
|
|
46929
|
-
logger_logger.trace `FETCH(${kind}) <- PANIC`;
|
|
47033
|
+
logger_logger.trace `[${this.currentServiceId}] FETCH(${kind}) <- PANIC`;
|
|
46930
47034
|
return PvmExecution.Panic;
|
|
46931
47035
|
}
|
|
46932
|
-
logger_logger.trace `FETCH(${kind}) <- ${value?.toStringTruncated()}`;
|
|
47036
|
+
logger_logger.trace `[${this.currentServiceId}] FETCH(${kind}) <- ${value?.toStringTruncated()}`;
|
|
46933
47037
|
// write result
|
|
46934
47038
|
regs.set(fetch_IN_OUT_REG, value === null ? HostCallResult.NONE : valueLength);
|
|
46935
47039
|
}
|
|
@@ -47079,7 +47183,7 @@ class LogHostCall {
|
|
|
47079
47183
|
}
|
|
47080
47184
|
memory.loadInto(message, msgStart);
|
|
47081
47185
|
const level = clampU64ToU32(lvl);
|
|
47082
|
-
logger_logger.trace `LOG(${this.currentServiceId}, ${level < Levels.UNKNOWN ? Levels[level] : Levels[Levels.UNKNOWN]}(${lvl}), ${decoder.decode(target)}, ${decoder.decode(message)})`;
|
|
47186
|
+
logger_logger.trace `[${this.currentServiceId}] LOG(${this.currentServiceId}, ${level < Levels.UNKNOWN ? Levels[level] : Levels[Levels.UNKNOWN]}(${lvl}), ${decoder.decode(target)}, ${decoder.decode(message)})`;
|
|
47083
47187
|
return Promise.resolve(undefined);
|
|
47084
47188
|
}
|
|
47085
47189
|
}
|
|
@@ -47120,12 +47224,12 @@ class Lookup {
|
|
|
47120
47224
|
const preImageHash = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
47121
47225
|
const memoryReadResult = memory.loadInto(preImageHash.raw, hashAddress);
|
|
47122
47226
|
if (memoryReadResult.isError) {
|
|
47123
|
-
logger_logger.trace `LOOKUP(${serviceId}, ${preImageHash}) <- PANIC`;
|
|
47227
|
+
logger_logger.trace `[${this.currentServiceId}] LOOKUP(${serviceId}, ${preImageHash}) <- PANIC`;
|
|
47124
47228
|
return PvmExecution.Panic;
|
|
47125
47229
|
}
|
|
47126
47230
|
// v
|
|
47127
47231
|
const preImage = this.account.lookup(serviceId, preImageHash);
|
|
47128
|
-
logger_logger.trace `LOOKUP(${serviceId}, ${preImageHash}) <- ${preImage?.toStringTruncated() ?? "<missing>"}...`;
|
|
47232
|
+
logger_logger.trace `[${this.currentServiceId}] LOOKUP(${serviceId}, ${preImageHash}) <- ${preImage?.toStringTruncated() ?? "<missing>"}...`;
|
|
47129
47233
|
const preImageLength = preImage === null ? numbers_tryAsU64(0) : numbers_tryAsU64(preImage.raw.length);
|
|
47130
47234
|
const preimageBlobOffset = regs.get(10);
|
|
47131
47235
|
const lengthToWrite = regs.get(11);
|
|
@@ -47222,20 +47326,20 @@ class Read {
|
|
|
47222
47326
|
const chunk = value === null ? safe_alloc_uint8array_safeAllocUint8Array(0) : value.raw.subarray(Number(offset), Number(offset + blobLength));
|
|
47223
47327
|
const memoryWriteResult = memory.storeFrom(destinationAddress, chunk);
|
|
47224
47328
|
if (memoryWriteResult.isError) {
|
|
47225
|
-
logger_logger.trace `READ(${serviceId}, ${rawKey}) <- PANIC`;
|
|
47329
|
+
logger_logger.trace `[${this.currentServiceId}] READ(${serviceId}, ${rawKey}) <- PANIC`;
|
|
47226
47330
|
return PvmExecution.Panic;
|
|
47227
47331
|
}
|
|
47228
47332
|
if (value === null) {
|
|
47229
|
-
logger_logger.trace `READ(${serviceId}, ${rawKey}) <- NONE`;
|
|
47333
|
+
logger_logger.trace `[${this.currentServiceId}] READ(${serviceId}, ${rawKey}) <- NONE`;
|
|
47230
47334
|
regs.set(read_IN_OUT_REG, HostCallResult.NONE);
|
|
47231
47335
|
return;
|
|
47232
47336
|
}
|
|
47233
47337
|
if (chunk.length > 0) {
|
|
47234
|
-
logger_logger.trace `READ(${serviceId}, ${rawKey}) <- ${bytes_BytesBlob.blobFrom(chunk).toStringTruncated()}`;
|
|
47338
|
+
logger_logger.trace `[${this.currentServiceId}] READ(${serviceId}, ${rawKey}) <- ${bytes_BytesBlob.blobFrom(chunk).toStringTruncated()}`;
|
|
47235
47339
|
}
|
|
47236
47340
|
else {
|
|
47237
47341
|
// just a query for length of stored data
|
|
47238
|
-
logger_logger.trace `READ(${serviceId}, ${rawKey}) <- (${valueLength} ${valueLength === 1n ? "byte" : "bytes"})`;
|
|
47342
|
+
logger_logger.trace `[${this.currentServiceId}] READ(${serviceId}, ${rawKey}) <- (${valueLength} ${valueLength === 1n ? "byte" : "bytes"})`;
|
|
47239
47343
|
}
|
|
47240
47344
|
regs.set(read_IN_OUT_REG, valueLength);
|
|
47241
47345
|
}
|
|
@@ -47279,7 +47383,7 @@ class Write {
|
|
|
47279
47383
|
const rawStorageKey = safe_alloc_uint8array_safeAllocUint8Array(storageKeyLengthClamped);
|
|
47280
47384
|
const keyLoadingResult = memory.loadInto(rawStorageKey, storageKeyStartAddress);
|
|
47281
47385
|
if (keyLoadingResult.isError) {
|
|
47282
|
-
logger_logger.trace `WRITE() <- PANIC`;
|
|
47386
|
+
logger_logger.trace `[${this.currentServiceId}] WRITE() <- PANIC`;
|
|
47283
47387
|
return PvmExecution.Panic;
|
|
47284
47388
|
}
|
|
47285
47389
|
// k
|
|
@@ -47289,14 +47393,14 @@ class Write {
|
|
|
47289
47393
|
const valueLoadingResult = memory.loadInto(value, valueStart);
|
|
47290
47394
|
// Note [MaSo] this is ok to return bcs if valueLength is 0, then this panic won't happen
|
|
47291
47395
|
if (valueLoadingResult.isError) {
|
|
47292
|
-
logger_logger.trace `WRITE(${storageKey}) <- PANIC`;
|
|
47396
|
+
logger_logger.trace `[${this.currentServiceId}] WRITE(${storageKey}) <- PANIC`;
|
|
47293
47397
|
return PvmExecution.Panic;
|
|
47294
47398
|
}
|
|
47295
47399
|
/** https://graypaper.fluffylabs.dev/#/9a08063/33af0133b201?v=0.6.6 */
|
|
47296
47400
|
const maybeValue = valueLength === 0n ? null : bytes_BytesBlob.blobFrom(value);
|
|
47297
47401
|
// a
|
|
47298
47402
|
const result = this.account.write(storageKey, maybeValue);
|
|
47299
|
-
logger_logger.trace `WRITE(${storageKey}, ${maybeValue?.toStringTruncated() ?? "remove"}) <- ${result_resultToString(result)}`;
|
|
47403
|
+
logger_logger.trace `[${this.currentServiceId}] WRITE(${storageKey}, ${maybeValue?.toStringTruncated() ?? "remove"}) <- ${result_resultToString(result)}`;
|
|
47300
47404
|
if (result.isError) {
|
|
47301
47405
|
regs.set(write_IN_OUT_REG, HostCallResult.FULL);
|
|
47302
47406
|
return;
|
|
@@ -47525,7 +47629,7 @@ class Accumulate {
|
|
|
47525
47629
|
serviceId,
|
|
47526
47630
|
argsLength: numbers_tryAsU32(transfers.length + operands.length),
|
|
47527
47631
|
});
|
|
47528
|
-
const result = await executor.run(invocationArgs,
|
|
47632
|
+
const result = await executor.run(invocationArgs, gas_tryAsGas(gas));
|
|
47529
47633
|
const [newState, checkpoint] = partialState.getStateUpdates();
|
|
47530
47634
|
/**
|
|
47531
47635
|
* PVM invocation returned and error so we return the checkpoint
|
|
@@ -47726,19 +47830,19 @@ class Accumulate {
|
|
|
47726
47830
|
for (let serviceIndex = 0; serviceIndex < serviceIdsLength; serviceIndex += 1) {
|
|
47727
47831
|
const serviceId = serviceIds[serviceIndex];
|
|
47728
47832
|
const checkpoint = AccumulationStateUpdate.copyFrom(inputStateUpdate);
|
|
47729
|
-
const promise = this.accumulateSingleService(serviceId, accumulateData.getTransfers(serviceId), accumulateData.getOperands(serviceId), accumulateData.getGasLimit(serviceId), slot, entropy, AccumulationStateUpdate.copyFrom(inputStateUpdate)).then(({ consumedGas, stateUpdate }) =>
|
|
47730
|
-
|
|
47731
|
-
|
|
47732
|
-
|
|
47833
|
+
const promise = this.accumulateSingleService(serviceId, accumulateData.getTransfers(serviceId), accumulateData.getOperands(serviceId), accumulateData.getGasLimit(serviceId), slot, entropy, AccumulationStateUpdate.copyFrom(inputStateUpdate)).then(({ consumedGas, stateUpdate }) => {
|
|
47834
|
+
const resultEntry = [
|
|
47835
|
+
serviceId,
|
|
47836
|
+
{
|
|
47837
|
+
consumedGas,
|
|
47838
|
+
stateUpdate: stateUpdate === null ? checkpoint : stateUpdate,
|
|
47839
|
+
},
|
|
47840
|
+
];
|
|
47841
|
+
return resultEntry;
|
|
47842
|
+
});
|
|
47733
47843
|
resultPromises[serviceIndex] = promise;
|
|
47734
47844
|
}
|
|
47735
|
-
return Promise.all(resultPromises).then((results) =>
|
|
47736
|
-
const map = new Map();
|
|
47737
|
-
for (let serviceIndex = 0; serviceIndex < serviceIdsLength; serviceIndex += 1) {
|
|
47738
|
-
map.set(serviceIds[serviceIndex], results[serviceIndex]);
|
|
47739
|
-
}
|
|
47740
|
-
return map;
|
|
47741
|
-
});
|
|
47845
|
+
return Promise.all(resultPromises).then((results) => new Map(results));
|
|
47742
47846
|
}
|
|
47743
47847
|
/**
|
|
47744
47848
|
* A method that updates `recentlyAccumulated`, `accumulationQueue` and `timeslot` in state
|
|
@@ -47827,9 +47931,10 @@ class Accumulate {
|
|
|
47827
47931
|
const _gasCost = gasCost;
|
|
47828
47932
|
assertEmpty(rest);
|
|
47829
47933
|
const accumulated = accumulatableReports.subview(0, accumulatedReports);
|
|
47830
|
-
const { yieldedRoot, services, transfers
|
|
47934
|
+
const { yieldedRoot, services, transfers, validatorsData, privilegedServices, authorizationQueues, ...stateUpdateRest } = state;
|
|
47831
47935
|
assertEmpty(stateUpdateRest);
|
|
47832
|
-
// yielded root
|
|
47936
|
+
// transfers and yielded root are retrieved after each pvm invocation so we can ignore it here
|
|
47937
|
+
const _transfers = transfers;
|
|
47833
47938
|
const _yieldedRoot = yieldedRoot;
|
|
47834
47939
|
if (this.hasDuplicatedServiceIdCreated(services.created)) {
|
|
47835
47940
|
accumulate_logger.trace `Duplicated Service creation detected. Block is invalid.`;
|
|
@@ -47928,7 +48033,7 @@ class DeferredTransfers {
|
|
|
47928
48033
|
partiallyUpdatedState.updateServiceInfo(serviceId, newInfo);
|
|
47929
48034
|
const partialState = new AccumulateExternalities(this.chainSpec, this.blake2b, partiallyUpdatedState, serviceId, serviceId, timeslot);
|
|
47930
48035
|
const fetchExternalities = FetchExternalities.createForOnTransfer({ entropy, transfers }, this.chainSpec);
|
|
47931
|
-
let consumedGas =
|
|
48036
|
+
let consumedGas = gas_tryAsGas(0);
|
|
47932
48037
|
const hasTransfers = transfers.length > 0;
|
|
47933
48038
|
const isCodeCorrect = code !== null && code.length <= W_C;
|
|
47934
48039
|
if (!hasTransfers || !isCodeCorrect) {
|
|
@@ -47946,7 +48051,7 @@ class DeferredTransfers {
|
|
|
47946
48051
|
const executor = await PvmExecutor.createOnTransferExecutor(serviceId, code, { partialState, fetchExternalities }, this.pvm);
|
|
47947
48052
|
const args = encoder_Encoder.encodeObject(deferred_transfers_ARGS_CODEC, { timeslot, serviceId, transfersLength: numbers_tryAsU32(transfers.length) }, this.chainSpec);
|
|
47948
48053
|
const gas = transfers.reduce((acc, item) => acc + item.gas, 0n);
|
|
47949
|
-
consumedGas = (await executor.run(args,
|
|
48054
|
+
consumedGas = (await executor.run(args, gas_tryAsGas(gas))).consumedGas;
|
|
47950
48055
|
}
|
|
47951
48056
|
transferStatistics.set(serviceId, { count: numbers_tryAsU32(transfers.length), gasUsed: tryAsServiceGas(consumedGas) });
|
|
47952
48057
|
const [updatedState] = partialState.getStateUpdates();
|
|
@@ -52417,7 +52522,7 @@ function initializeExtensions(api) {
|
|
|
52417
52522
|
}
|
|
52418
52523
|
|
|
52419
52524
|
;// CONCATENATED MODULE: ./packages/jam/node/package.json
|
|
52420
|
-
const package_namespaceObject = {"rE":"0.4.
|
|
52525
|
+
const package_namespaceObject = {"rE":"0.4.1"};
|
|
52421
52526
|
;// CONCATENATED MODULE: ./packages/workers/block-generator/generator.ts
|
|
52422
52527
|
|
|
52423
52528
|
|
|
@@ -53051,7 +53156,7 @@ function readJsonBlock(file, chainSpec) {
|
|
|
53051
53156
|
var minimist = __nccwpck_require__(8595);
|
|
53052
53157
|
var minimist_default = /*#__PURE__*/__nccwpck_require__.n(minimist);
|
|
53053
53158
|
;// CONCATENATED MODULE: ./bin/jam/package.json
|
|
53054
|
-
const jam_package_namespaceObject = {"rE":"0.4.
|
|
53159
|
+
const jam_package_namespaceObject = {"rE":"0.4.1"};
|
|
53055
53160
|
;// CONCATENATED MODULE: ./bin/jam/args.ts
|
|
53056
53161
|
|
|
53057
53162
|
|