@typeberry/jam 0.1.1-4a6ffa9 → 0.1.1-e48de40
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/block-generator/index.js +103 -94
- package/block-generator/index.js.map +1 -1
- package/importer/index.js +185 -176
- package/importer/index.js.map +1 -1
- package/index.js +342 -333
- package/index.js.map +1 -1
- package/jam-network/index.js +169 -162
- package/jam-network/index.js.map +1 -1
- package/package.json +1 -1
package/importer/index.js
CHANGED
|
@@ -13401,6 +13401,23 @@ function parseLevel(lvl) {
|
|
|
13401
13401
|
;// CONCATENATED MODULE: ./packages/core/logger/console.ts
|
|
13402
13402
|
// biome-ignore-all lint/suspicious/noConsole: logger
|
|
13403
13403
|
|
|
13404
|
+
function print(level, levelAndName, strings, data) {
|
|
13405
|
+
if (level < levelAndName[0]) {
|
|
13406
|
+
return;
|
|
13407
|
+
}
|
|
13408
|
+
const lvlText = Level[level].padEnd(5);
|
|
13409
|
+
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
13410
|
+
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
13411
|
+
if (level === Level.WARN) {
|
|
13412
|
+
console.warn(msg);
|
|
13413
|
+
}
|
|
13414
|
+
else if (level === Level.ERROR) {
|
|
13415
|
+
console.error(msg);
|
|
13416
|
+
}
|
|
13417
|
+
else {
|
|
13418
|
+
console.info(msg);
|
|
13419
|
+
}
|
|
13420
|
+
}
|
|
13404
13421
|
/** An optimized logger that ignores `TRACE`, `DEBUG` and `LOG` messages.
|
|
13405
13422
|
*
|
|
13406
13423
|
* Use the `create` method to instantiate the right instance of a more specialized logger.
|
|
@@ -13431,109 +13448,91 @@ class ConsoleTransport {
|
|
|
13431
13448
|
constructor(options) {
|
|
13432
13449
|
this.options = options;
|
|
13433
13450
|
}
|
|
13434
|
-
insane(
|
|
13451
|
+
insane(_levelAndName, _strings, _data) {
|
|
13435
13452
|
/* no-op */
|
|
13436
13453
|
}
|
|
13437
|
-
trace(
|
|
13454
|
+
trace(_levelAndName, _strings, _data) {
|
|
13438
13455
|
/* no-op */
|
|
13439
13456
|
}
|
|
13440
|
-
log(
|
|
13457
|
+
log(_levelAndName, _strings, _data) {
|
|
13441
13458
|
/* no-op */
|
|
13442
13459
|
}
|
|
13443
|
-
info(
|
|
13460
|
+
info(_levelAndName, _strings, _data) {
|
|
13444
13461
|
/* no-op */
|
|
13445
13462
|
}
|
|
13446
|
-
warn(
|
|
13447
|
-
|
|
13463
|
+
warn(levelAndName, strings, data) {
|
|
13464
|
+
print(Level.WARN, levelAndName, strings, data);
|
|
13448
13465
|
}
|
|
13449
|
-
error(
|
|
13450
|
-
|
|
13451
|
-
}
|
|
13452
|
-
push(level, moduleName, val) {
|
|
13453
|
-
const shortModule = moduleName.replace(this.options.workingDir, "");
|
|
13454
|
-
const configuredLevel = findLevel(this.options, moduleName);
|
|
13455
|
-
const lvlText = Level[level].padEnd(5);
|
|
13456
|
-
if (level < configuredLevel) {
|
|
13457
|
-
return;
|
|
13458
|
-
}
|
|
13459
|
-
const msg = `${lvlText} [${shortModule}] ${val}`;
|
|
13460
|
-
if (level === Level.WARN) {
|
|
13461
|
-
console.warn(msg);
|
|
13462
|
-
}
|
|
13463
|
-
else if (level === Level.ERROR) {
|
|
13464
|
-
console.error(msg);
|
|
13465
|
-
}
|
|
13466
|
-
else {
|
|
13467
|
-
console.info(msg);
|
|
13468
|
-
}
|
|
13466
|
+
error(levelAndName, strings, data) {
|
|
13467
|
+
print(Level.ERROR, levelAndName, strings, data);
|
|
13469
13468
|
}
|
|
13470
13469
|
}
|
|
13471
13470
|
/**
|
|
13472
13471
|
* Insane version of console logger - supports insane level.
|
|
13473
13472
|
*/
|
|
13474
13473
|
class InsaneConsoleLogger extends ConsoleTransport {
|
|
13475
|
-
insane(
|
|
13476
|
-
|
|
13474
|
+
insane(levelAndName, strings, data) {
|
|
13475
|
+
print(Level.INSANE, levelAndName, strings, data);
|
|
13477
13476
|
}
|
|
13478
|
-
trace(
|
|
13479
|
-
|
|
13477
|
+
trace(levelAndName, strings, data) {
|
|
13478
|
+
print(Level.TRACE, levelAndName, strings, data);
|
|
13480
13479
|
}
|
|
13481
|
-
log(
|
|
13482
|
-
|
|
13480
|
+
log(levelAndName, strings, data) {
|
|
13481
|
+
print(Level.LOG, levelAndName, strings, data);
|
|
13483
13482
|
}
|
|
13484
|
-
info(
|
|
13485
|
-
|
|
13483
|
+
info(levelAndName, strings, data) {
|
|
13484
|
+
print(Level.INFO, levelAndName, strings, data);
|
|
13486
13485
|
}
|
|
13487
13486
|
}
|
|
13488
13487
|
/**
|
|
13489
13488
|
* A basic version of console logger - printing everything.
|
|
13490
13489
|
*/
|
|
13491
13490
|
class TraceConsoleTransport extends ConsoleTransport {
|
|
13492
|
-
insane(
|
|
13491
|
+
insane(_levelAndName, _strings, _data) {
|
|
13493
13492
|
/* no-op */
|
|
13494
13493
|
}
|
|
13495
|
-
trace(
|
|
13496
|
-
|
|
13494
|
+
trace(levelAndName, strings, data) {
|
|
13495
|
+
print(Level.TRACE, levelAndName, strings, data);
|
|
13497
13496
|
}
|
|
13498
|
-
log(
|
|
13499
|
-
|
|
13497
|
+
log(levelAndName, strings, data) {
|
|
13498
|
+
print(Level.LOG, levelAndName, strings, data);
|
|
13500
13499
|
}
|
|
13501
|
-
info(
|
|
13502
|
-
|
|
13500
|
+
info(levelAndName, strings, data) {
|
|
13501
|
+
print(Level.INFO, levelAndName, strings, data);
|
|
13503
13502
|
}
|
|
13504
13503
|
}
|
|
13505
13504
|
/**
|
|
13506
13505
|
* An optimized version of the logger - completely ignores `TRACE` level calls.
|
|
13507
13506
|
*/
|
|
13508
13507
|
class LogConsoleTransport extends ConsoleTransport {
|
|
13509
|
-
insane(
|
|
13508
|
+
insane(_levelAndName, _strings, _data) {
|
|
13510
13509
|
/* no-op */
|
|
13511
13510
|
}
|
|
13512
|
-
trace(
|
|
13511
|
+
trace(_levelAndName, _strings, _data) {
|
|
13513
13512
|
/* no-op */
|
|
13514
13513
|
}
|
|
13515
|
-
log(
|
|
13516
|
-
|
|
13514
|
+
log(levelAndName, strings, data) {
|
|
13515
|
+
print(Level.LOG, levelAndName, strings, data);
|
|
13517
13516
|
}
|
|
13518
|
-
info(
|
|
13519
|
-
|
|
13517
|
+
info(levelAndName, strings, data) {
|
|
13518
|
+
print(Level.INFO, levelAndName, strings, data);
|
|
13520
13519
|
}
|
|
13521
13520
|
}
|
|
13522
13521
|
/**
|
|
13523
13522
|
* An optimized version of the logger - completely ignores `TRACE` & `DEBUG` level calls.
|
|
13524
13523
|
*/
|
|
13525
13524
|
class InfoConsoleTransport extends ConsoleTransport {
|
|
13526
|
-
insane(
|
|
13525
|
+
insane(_levelAndName, _strings, _data) {
|
|
13527
13526
|
/* no-op */
|
|
13528
13527
|
}
|
|
13529
|
-
trace(
|
|
13528
|
+
trace(_levelAndName, _strings, _data) {
|
|
13530
13529
|
/* no-op */
|
|
13531
13530
|
}
|
|
13532
|
-
log(
|
|
13531
|
+
log(_levelAndName, _strings, _data) {
|
|
13533
13532
|
/* no-op */
|
|
13534
13533
|
}
|
|
13535
|
-
info(
|
|
13536
|
-
|
|
13534
|
+
info(levelAndName, strings, data) {
|
|
13535
|
+
print(Level.INFO, levelAndName, strings, data);
|
|
13537
13536
|
}
|
|
13538
13537
|
}
|
|
13539
13538
|
|
|
@@ -13570,11 +13569,6 @@ class Logger {
|
|
|
13570
13569
|
const module = moduleName ?? fName;
|
|
13571
13570
|
return new Logger(module.padStart(8, " "), GLOBAL_CONFIG);
|
|
13572
13571
|
}
|
|
13573
|
-
/**
|
|
13574
|
-
* Return currently configured level for given module. */
|
|
13575
|
-
static getLevel(moduleName) {
|
|
13576
|
-
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
13577
|
-
}
|
|
13578
13572
|
/**
|
|
13579
13573
|
* Global configuration of all loggers.
|
|
13580
13574
|
*
|
|
@@ -13605,33 +13599,46 @@ class Logger {
|
|
|
13605
13599
|
const options = parseLoggerOptions(input, defaultLevel, workingDir);
|
|
13606
13600
|
Logger.configureAllFromOptions(options);
|
|
13607
13601
|
}
|
|
13602
|
+
cachedLevelAndName;
|
|
13608
13603
|
constructor(moduleName, config) {
|
|
13609
13604
|
this.moduleName = moduleName;
|
|
13610
13605
|
this.config = config;
|
|
13611
13606
|
}
|
|
13607
|
+
/** Return currently configured level for given module. */
|
|
13608
|
+
getLevel() {
|
|
13609
|
+
return this.getLevelAndName()[0];
|
|
13610
|
+
}
|
|
13611
|
+
getLevelAndName() {
|
|
13612
|
+
if (this.cachedLevelAndName === undefined) {
|
|
13613
|
+
const level = findLevel(this.config.options, this.moduleName);
|
|
13614
|
+
const shortName = this.moduleName.replace(this.config.options.workingDir, "");
|
|
13615
|
+
this.cachedLevelAndName = [level, shortName];
|
|
13616
|
+
}
|
|
13617
|
+
return this.cachedLevelAndName;
|
|
13618
|
+
}
|
|
13612
13619
|
/** Log a message with `INSANE` level. */
|
|
13613
|
-
insane(
|
|
13614
|
-
this.config.transport.insane(this.
|
|
13620
|
+
insane(strings, ...data) {
|
|
13621
|
+
this.config.transport.insane(this.getLevelAndName(), strings, data);
|
|
13615
13622
|
}
|
|
13616
13623
|
/** Log a message with `TRACE` level. */
|
|
13617
|
-
trace(
|
|
13618
|
-
this.config.transport.trace(this.
|
|
13624
|
+
trace(strings, ...data) {
|
|
13625
|
+
this.config.transport.trace(this.getLevelAndName(), strings, data);
|
|
13619
13626
|
}
|
|
13620
13627
|
/** Log a message with `DEBUG`/`LOG` level. */
|
|
13621
|
-
log(
|
|
13622
|
-
this.config.transport.log(this.
|
|
13628
|
+
log(strings, ...data) {
|
|
13629
|
+
this.config.transport.log(this.getLevelAndName(), strings, data);
|
|
13623
13630
|
}
|
|
13624
13631
|
/** Log a message with `INFO` level. */
|
|
13625
|
-
info(
|
|
13626
|
-
this.config.transport.info(this.
|
|
13632
|
+
info(strings, ...data) {
|
|
13633
|
+
this.config.transport.info(this.getLevelAndName(), strings, data);
|
|
13627
13634
|
}
|
|
13628
13635
|
/** Log a message with `WARN` level. */
|
|
13629
|
-
warn(
|
|
13630
|
-
this.config.transport.warn(this.
|
|
13636
|
+
warn(strings, ...data) {
|
|
13637
|
+
this.config.transport.warn(this.getLevelAndName(), strings, data);
|
|
13631
13638
|
}
|
|
13632
13639
|
/** Log a message with `ERROR` level. */
|
|
13633
|
-
error(
|
|
13634
|
-
this.config.transport.error(this.
|
|
13640
|
+
error(strings, ...data) {
|
|
13641
|
+
this.config.transport.error(this.getLevelAndName(), strings, data);
|
|
13635
13642
|
}
|
|
13636
13643
|
}
|
|
13637
13644
|
|
|
@@ -13746,7 +13753,7 @@ class LmdbStates {
|
|
|
13746
13753
|
await Promise.all([valuesWrite, statesWrite]);
|
|
13747
13754
|
}
|
|
13748
13755
|
catch (e) {
|
|
13749
|
-
logger.error
|
|
13756
|
+
logger.error `${e}`;
|
|
13750
13757
|
return result_Result.error(StateUpdateError.Commit);
|
|
13751
13758
|
}
|
|
13752
13759
|
return result_Result.ok(result_OK);
|
|
@@ -13854,7 +13861,7 @@ class TypedPort {
|
|
|
13854
13861
|
this.dispatchPortMessage(msg);
|
|
13855
13862
|
}
|
|
13856
13863
|
catch (e) {
|
|
13857
|
-
port_logger.error
|
|
13864
|
+
port_logger.error `[${this.constructor.name}] Failed to dispatch a message: ${e}: ${msg}`;
|
|
13858
13865
|
throw e;
|
|
13859
13866
|
}
|
|
13860
13867
|
});
|
|
@@ -13928,7 +13935,7 @@ class TypedPort {
|
|
|
13928
13935
|
this.port.postMessage(msg, transferList);
|
|
13929
13936
|
}
|
|
13930
13937
|
catch (e) {
|
|
13931
|
-
port_logger.error
|
|
13938
|
+
port_logger.error `[${this.constructor.name}] Failed to post a message: ${e}: ${msg}`;
|
|
13932
13939
|
throw e;
|
|
13933
13940
|
}
|
|
13934
13941
|
}
|
|
@@ -13959,7 +13966,7 @@ class TypedPort {
|
|
|
13959
13966
|
cleanup(reason) {
|
|
13960
13967
|
// resolve all pending requests with an error.
|
|
13961
13968
|
const responseListeners = this.responseListeners.eventNames();
|
|
13962
|
-
for (const ev
|
|
13969
|
+
for (const ev of responseListeners) {
|
|
13963
13970
|
this.responseListeners.emit(ev, new Error(`port is ${reason}`));
|
|
13964
13971
|
}
|
|
13965
13972
|
}
|
|
@@ -14008,7 +14015,7 @@ class channel_MessageChannelStateMachine {
|
|
|
14008
14015
|
this.dispatchSignal(name, data);
|
|
14009
14016
|
}
|
|
14010
14017
|
catch (e) {
|
|
14011
|
-
channel_logger.error
|
|
14018
|
+
channel_logger.error `[${this.constructor.name}] Unable to dispatch signal (${name}): ${e}. ${this.stateInfo(remoteState)}`;
|
|
14012
14019
|
throw e;
|
|
14013
14020
|
}
|
|
14014
14021
|
});
|
|
@@ -14017,7 +14024,7 @@ class channel_MessageChannelStateMachine {
|
|
|
14017
14024
|
await this.dispatchRequest(name, data, msg);
|
|
14018
14025
|
}
|
|
14019
14026
|
catch (e) {
|
|
14020
|
-
channel_logger.error
|
|
14027
|
+
channel_logger.error `[${this.constructor.name}] Unable to dispatch request (${name}): ${e}. ${this.stateInfo(remoteState)}`;
|
|
14021
14028
|
throw e;
|
|
14022
14029
|
}
|
|
14023
14030
|
});
|
|
@@ -14103,7 +14110,7 @@ class channel_MessageChannelStateMachine {
|
|
|
14103
14110
|
this.machine.transition(res.transitionTo.state, res.transitionTo.data);
|
|
14104
14111
|
}
|
|
14105
14112
|
if (didStateChangeInMeantime) {
|
|
14106
|
-
channel_logger.warn
|
|
14113
|
+
channel_logger.warn `Ignoring obsolete response for an old request: "${name}"`;
|
|
14107
14114
|
return;
|
|
14108
14115
|
}
|
|
14109
14116
|
return this.port.respond(prevState.stateName, msg, res.response);
|
|
@@ -14119,7 +14126,7 @@ class channel_MessageChannelStateMachine {
|
|
|
14119
14126
|
}
|
|
14120
14127
|
}
|
|
14121
14128
|
transitionTo() {
|
|
14122
|
-
channel_logger.trace
|
|
14129
|
+
channel_logger.trace `[${this.machine.name}] transitioned to ${this.currentState()}`;
|
|
14123
14130
|
return this;
|
|
14124
14131
|
}
|
|
14125
14132
|
/**
|
|
@@ -14139,7 +14146,7 @@ class channel_MessageChannelStateMachine {
|
|
|
14139
14146
|
await promise;
|
|
14140
14147
|
}
|
|
14141
14148
|
catch (e) {
|
|
14142
|
-
channel_logger.error
|
|
14149
|
+
channel_logger.error `${e}`;
|
|
14143
14150
|
}
|
|
14144
14151
|
return new channel_MessageChannelStateMachine(machine, port);
|
|
14145
14152
|
}
|
|
@@ -14342,7 +14349,7 @@ class State {
|
|
|
14342
14349
|
* actions.
|
|
14343
14350
|
*/
|
|
14344
14351
|
onActivation(data) {
|
|
14345
|
-
state_logger.trace
|
|
14352
|
+
state_logger.trace `[${this.constructor.name}] Changing state to: ${this}`;
|
|
14346
14353
|
this.data = data;
|
|
14347
14354
|
}
|
|
14348
14355
|
/**
|
|
@@ -16053,12 +16060,14 @@ class WriteablePage extends MemoryPage {
|
|
|
16053
16060
|
|
|
16054
16061
|
|
|
16055
16062
|
|
|
16063
|
+
|
|
16064
|
+
|
|
16056
16065
|
var AccessType;
|
|
16057
16066
|
(function (AccessType) {
|
|
16058
16067
|
AccessType[AccessType["READ"] = 0] = "READ";
|
|
16059
16068
|
AccessType[AccessType["WRITE"] = 1] = "WRITE";
|
|
16060
16069
|
})(AccessType || (AccessType = {}));
|
|
16061
|
-
|
|
16070
|
+
const memory_logger = Logger.new(import.meta.filename, "pvm:mem");
|
|
16062
16071
|
class Memory {
|
|
16063
16072
|
sbrkIndex;
|
|
16064
16073
|
virtualSbrkIndex;
|
|
@@ -16089,7 +16098,7 @@ class Memory {
|
|
|
16089
16098
|
if (bytes.length === 0) {
|
|
16090
16099
|
return result_Result.ok(result_OK);
|
|
16091
16100
|
}
|
|
16092
|
-
|
|
16101
|
+
memory_logger.insane `MEM[${address}] <- ${bytes_BytesBlob.blobFrom(bytes)}`;
|
|
16093
16102
|
const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
|
|
16094
16103
|
if (pagesResult.isError) {
|
|
16095
16104
|
return result_Result.error(pagesResult.error);
|
|
@@ -16156,7 +16165,7 @@ class Memory {
|
|
|
16156
16165
|
currentPosition += bytesToRead;
|
|
16157
16166
|
bytesLeft -= bytesToRead;
|
|
16158
16167
|
}
|
|
16159
|
-
|
|
16168
|
+
memory_logger.insane `MEM[${startAddress}] => ${bytes_BytesBlob.blobFrom(result)}`;
|
|
16160
16169
|
return result_Result.ok(result_OK);
|
|
16161
16170
|
}
|
|
16162
16171
|
sbrk(length) {
|
|
@@ -18086,7 +18095,7 @@ class ProgramDecoder {
|
|
|
18086
18095
|
return result_Result.ok(new ProgramDecoder(program));
|
|
18087
18096
|
}
|
|
18088
18097
|
catch (e) {
|
|
18089
|
-
program_decoder_logger.error
|
|
18098
|
+
program_decoder_logger.error `Invalid program: ${e}`;
|
|
18090
18099
|
return result_Result.error(ProgramDecoderError.InvalidProgramError);
|
|
18091
18100
|
}
|
|
18092
18101
|
}
|
|
@@ -18252,7 +18261,7 @@ class Interpreter {
|
|
|
18252
18261
|
const argsType = instructionArgumentTypeMap[currentInstruction] ?? ArgumentType.NO_ARGUMENTS;
|
|
18253
18262
|
const argsResult = this.argsDecodingResults[argsType];
|
|
18254
18263
|
this.argsDecoder.fillArgs(this.pc, argsResult);
|
|
18255
|
-
interpreter_logger.insane
|
|
18264
|
+
interpreter_logger.insane `[PC: ${this.pc}] ${Instruction[currentInstruction]}`;
|
|
18256
18265
|
if (!isValidInstruction) {
|
|
18257
18266
|
this.instructionResult.status = pvm_interpreter_result_Result.PANIC;
|
|
18258
18267
|
}
|
|
@@ -18324,7 +18333,7 @@ class Interpreter {
|
|
|
18324
18333
|
this.status = status_Status.HOST;
|
|
18325
18334
|
break;
|
|
18326
18335
|
}
|
|
18327
|
-
interpreter_logger.insane
|
|
18336
|
+
interpreter_logger.insane `[PC: ${this.pc}] Status: ${pvm_interpreter_result_Result[this.instructionResult.status]}`;
|
|
18328
18337
|
return this.status;
|
|
18329
18338
|
}
|
|
18330
18339
|
this.pc = this.instructionResult.nextPc;
|
|
@@ -18571,7 +18580,7 @@ class host_calls_manager_HostCallsManager {
|
|
|
18571
18580
|
return `r${idx}=${value} (0x${value.toString(16)})`;
|
|
18572
18581
|
})
|
|
18573
18582
|
.join(", ");
|
|
18574
|
-
host_calls_manager_logger.insane
|
|
18583
|
+
host_calls_manager_logger.insane `[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`;
|
|
18575
18584
|
}
|
|
18576
18585
|
}
|
|
18577
18586
|
class NoopMissing {
|
|
@@ -20954,7 +20963,7 @@ class AccumulateExternalities {
|
|
|
20954
20963
|
/** https://graypaper.fluffylabs.dev/#/7e6ff6a/362802362d02?v=0.6.7 */
|
|
20955
20964
|
const validatorsManager = this.updatedState.getPrivilegedServices().validatorsManager;
|
|
20956
20965
|
if (validatorsManager !== this.currentServiceId) {
|
|
20957
|
-
accumulate_externalities_logger.trace
|
|
20966
|
+
accumulate_externalities_logger.trace `Current service id (${this.currentServiceId}) is not a validators manager. (expected: ${validatorsManager}) and cannot update validators data. Ignoring`;
|
|
20958
20967
|
return result_Result.error(UnprivilegedError);
|
|
20959
20968
|
}
|
|
20960
20969
|
this.updatedState.stateUpdate.validatorsData = validatorsData;
|
|
@@ -20969,11 +20978,11 @@ class AccumulateExternalities {
|
|
|
20969
20978
|
// NOTE `coreIndex` is already verified in the HC, so this is infallible.
|
|
20970
20979
|
const currentAuthManager = this.updatedState.getPrivilegedServices().authManager[coreIndex];
|
|
20971
20980
|
if (currentAuthManager !== this.currentServiceId) {
|
|
20972
|
-
accumulate_externalities_logger.trace
|
|
20981
|
+
accumulate_externalities_logger.trace `Current service id (${this.currentServiceId}) is not an auth manager of core ${coreIndex} (expected: ${currentAuthManager}) and cannot update authorization queue. Ignoring`;
|
|
20973
20982
|
return result_Result.error(UpdatePrivilegesError.UnprivilegedService);
|
|
20974
20983
|
}
|
|
20975
20984
|
if (authManager === null && Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
|
|
20976
|
-
accumulate_externalities_logger.trace
|
|
20985
|
+
accumulate_externalities_logger.trace `The new auth manager is not a valid service id. Ignoring`;
|
|
20977
20986
|
return result_Result.error(UpdatePrivilegesError.InvalidServiceId);
|
|
20978
20987
|
}
|
|
20979
20988
|
this.updatedState.stateUpdate.authorizationQueues.set(coreIndex, authQueue);
|
|
@@ -21854,7 +21863,7 @@ class Assign {
|
|
|
21854
21863
|
const memoryReadResult = memory.loadInto(res, authorizationQueueStart);
|
|
21855
21864
|
// error while reading the memory.
|
|
21856
21865
|
if (memoryReadResult.isError) {
|
|
21857
|
-
logger_logger.trace
|
|
21866
|
+
logger_logger.trace `ASSIGN() <- PANIC`;
|
|
21858
21867
|
return PvmExecution.Panic;
|
|
21859
21868
|
}
|
|
21860
21869
|
if (maybeCoreIndex >= this.chainSpec.coresCount) {
|
|
@@ -21869,18 +21878,18 @@ class Assign {
|
|
|
21869
21878
|
const result = this.partialState.updateAuthorizationQueue(coreIndex, fixedSizeAuthQueue, authManager);
|
|
21870
21879
|
if (result.isOk) {
|
|
21871
21880
|
regs.set(IN_OUT_REG, HostCallResult.OK);
|
|
21872
|
-
logger_logger.trace
|
|
21881
|
+
logger_logger.trace `ASSIGN(${coreIndex}, ${fixedSizeAuthQueue}) <- OK`;
|
|
21873
21882
|
return;
|
|
21874
21883
|
}
|
|
21875
21884
|
const e = result.error;
|
|
21876
21885
|
if (e === UpdatePrivilegesError.UnprivilegedService) {
|
|
21877
21886
|
regs.set(IN_OUT_REG, HostCallResult.HUH);
|
|
21878
|
-
logger_logger.trace
|
|
21887
|
+
logger_logger.trace `ASSIGN(${coreIndex}, ${fixedSizeAuthQueue}) <- HUH`;
|
|
21879
21888
|
return;
|
|
21880
21889
|
}
|
|
21881
21890
|
if (e === UpdatePrivilegesError.InvalidServiceId) {
|
|
21882
21891
|
regs.set(IN_OUT_REG, HostCallResult.WHO);
|
|
21883
|
-
logger_logger.trace
|
|
21892
|
+
logger_logger.trace `ASSIGN(${coreIndex}, ${fixedSizeAuthQueue}) <- HUH`;
|
|
21884
21893
|
return;
|
|
21885
21894
|
}
|
|
21886
21895
|
debug_assertNever(e);
|
|
@@ -21946,7 +21955,7 @@ class Bless {
|
|
|
21946
21955
|
decoder.resetTo(0);
|
|
21947
21956
|
const memoryReadResult = memory.loadInto(result, memIndex);
|
|
21948
21957
|
if (memoryReadResult.isError) {
|
|
21949
|
-
logger_logger.trace
|
|
21958
|
+
logger_logger.trace `BLESS(${manager}, ${validator}) <- PANIC`;
|
|
21950
21959
|
return PvmExecution.Panic;
|
|
21951
21960
|
}
|
|
21952
21961
|
const { serviceId, gas } = decoder.object(serviceIdAndGasCodec);
|
|
@@ -21959,24 +21968,24 @@ class Bless {
|
|
|
21959
21968
|
const authorizersDecoder = decoder_Decoder.fromBlob(res);
|
|
21960
21969
|
const memoryReadResult = memory.loadInto(res, authorization);
|
|
21961
21970
|
if (memoryReadResult.isError) {
|
|
21962
|
-
logger_logger.trace
|
|
21971
|
+
logger_logger.trace `BLESS(${manager}, ${validator}, ${autoAccumulateEntries}) <- PANIC`;
|
|
21963
21972
|
return PvmExecution.Panic;
|
|
21964
21973
|
}
|
|
21965
21974
|
const authorizers = tryAsPerCore(authorizersDecoder.sequenceFixLen(descriptors_codec.u32.asOpaque(), this.chainSpec.coresCount), this.chainSpec);
|
|
21966
21975
|
const updateResult = this.partialState.updatePrivilegedServices(manager, authorizers, validator, autoAccumulateEntries);
|
|
21967
21976
|
if (updateResult.isOk) {
|
|
21968
|
-
logger_logger.trace
|
|
21977
|
+
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${validator}, ${autoAccumulateEntries}) <- OK`;
|
|
21969
21978
|
regs.set(bless_IN_OUT_REG, HostCallResult.OK);
|
|
21970
21979
|
return;
|
|
21971
21980
|
}
|
|
21972
21981
|
const e = updateResult.error;
|
|
21973
21982
|
if (e === UpdatePrivilegesError.UnprivilegedService) {
|
|
21974
|
-
logger_logger.trace
|
|
21983
|
+
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${validator}, ${autoAccumulateEntries}) <- HUH`;
|
|
21975
21984
|
regs.set(bless_IN_OUT_REG, HostCallResult.HUH);
|
|
21976
21985
|
return;
|
|
21977
21986
|
}
|
|
21978
21987
|
if (e === UpdatePrivilegesError.InvalidServiceId) {
|
|
21979
|
-
logger_logger.trace
|
|
21988
|
+
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${validator}, ${autoAccumulateEntries}) <- WHO`;
|
|
21980
21989
|
regs.set(bless_IN_OUT_REG, HostCallResult.WHO);
|
|
21981
21990
|
return;
|
|
21982
21991
|
}
|
|
@@ -22006,7 +22015,7 @@ class GasHostCall {
|
|
|
22006
22015
|
}
|
|
22007
22016
|
execute(gas, regs) {
|
|
22008
22017
|
const gasValue = gas.get();
|
|
22009
|
-
logger_logger.trace
|
|
22018
|
+
logger_logger.trace `GAS <- ${gasValue}`;
|
|
22010
22019
|
regs.set(7, numbers_tryAsU64(gasValue));
|
|
22011
22020
|
return Promise.resolve(undefined);
|
|
22012
22021
|
}
|
|
@@ -22038,7 +22047,7 @@ class Checkpoint {
|
|
|
22038
22047
|
async execute(gas, regs) {
|
|
22039
22048
|
await this.gasHostCall.execute(gas, regs);
|
|
22040
22049
|
this.partialState.checkpoint();
|
|
22041
|
-
logger_logger.trace
|
|
22050
|
+
logger_logger.trace `CHECKPOINT()`;
|
|
22042
22051
|
return;
|
|
22043
22052
|
}
|
|
22044
22053
|
}
|
|
@@ -22077,18 +22086,18 @@ class Designate {
|
|
|
22077
22086
|
const memoryReadResult = memory.loadInto(res, validatorsStart);
|
|
22078
22087
|
// error while reading the memory.
|
|
22079
22088
|
if (memoryReadResult.isError) {
|
|
22080
|
-
logger_logger.trace
|
|
22089
|
+
logger_logger.trace `DESIGNATE() <- PANIC`;
|
|
22081
22090
|
return PvmExecution.Panic;
|
|
22082
22091
|
}
|
|
22083
22092
|
const decoder = decoder_Decoder.fromBlob(res);
|
|
22084
22093
|
const validatorsData = decoder.sequenceFixLen(ValidatorData.Codec, this.chainSpec.validatorsCount);
|
|
22085
22094
|
const result = this.partialState.updateValidatorsData(tryAsPerValidator(validatorsData, this.chainSpec));
|
|
22086
22095
|
if (result.isError) {
|
|
22087
|
-
logger_logger.trace
|
|
22096
|
+
logger_logger.trace `DESIGNATE([${validatorsData[0]}, ${validatorsData[1]}, ...]) <- HUH`;
|
|
22088
22097
|
regs.set(designate_IN_OUT_REG, HostCallResult.HUH);
|
|
22089
22098
|
}
|
|
22090
22099
|
else {
|
|
22091
|
-
logger_logger.trace
|
|
22100
|
+
logger_logger.trace `DESIGNATE([${validatorsData[0]}, ${validatorsData[1]}, ...]) <- OK`;
|
|
22092
22101
|
regs.set(designate_IN_OUT_REG, HostCallResult.OK);
|
|
22093
22102
|
}
|
|
22094
22103
|
}
|
|
@@ -22129,17 +22138,17 @@ class Eject {
|
|
|
22129
22138
|
const previousCodeHash = bytes_Bytes.zero(hash_HASH_SIZE).asOpaque();
|
|
22130
22139
|
const memoryReadResult = memory.loadInto(previousCodeHash.raw, preimageHashStart);
|
|
22131
22140
|
if (memoryReadResult.isError) {
|
|
22132
|
-
logger_logger.trace
|
|
22141
|
+
logger_logger.trace `EJECT(${serviceId}) <- PANIC`;
|
|
22133
22142
|
return PvmExecution.Panic;
|
|
22134
22143
|
}
|
|
22135
22144
|
// cannot eject self
|
|
22136
22145
|
if (serviceId === this.currentServiceId) {
|
|
22137
22146
|
regs.set(eject_IN_OUT_REG, HostCallResult.WHO);
|
|
22138
|
-
logger_logger.trace
|
|
22147
|
+
logger_logger.trace `EJECT(${serviceId}, ${previousCodeHash}) <- WHO`;
|
|
22139
22148
|
return;
|
|
22140
22149
|
}
|
|
22141
22150
|
const result = this.partialState.eject(serviceId, previousCodeHash);
|
|
22142
|
-
logger_logger.trace
|
|
22151
|
+
logger_logger.trace `EJECT(${serviceId}, ${previousCodeHash}) <- ${resultToString(result)}`;
|
|
22143
22152
|
// All good!
|
|
22144
22153
|
if (result.isOk) {
|
|
22145
22154
|
regs.set(eject_IN_OUT_REG, HostCallResult.OK);
|
|
@@ -22191,11 +22200,11 @@ class Forget {
|
|
|
22191
22200
|
const memoryReadResult = memory.loadInto(hash.raw, hashStart);
|
|
22192
22201
|
// error while reading the memory.
|
|
22193
22202
|
if (memoryReadResult.isError) {
|
|
22194
|
-
logger_logger.trace
|
|
22203
|
+
logger_logger.trace `FORGET(${hash}, ${length}) <- PANIC`;
|
|
22195
22204
|
return PvmExecution.Panic;
|
|
22196
22205
|
}
|
|
22197
22206
|
const result = this.partialState.forgetPreimage(hash.asOpaque(), length);
|
|
22198
|
-
logger_logger.trace
|
|
22207
|
+
logger_logger.trace `FORGET(${hash}, ${length}) <- ${resultToString(result)}`;
|
|
22199
22208
|
if (result.isOk) {
|
|
22200
22209
|
regs.set(forget_IN_OUT_REG, HostCallResult.OK);
|
|
22201
22210
|
}
|
|
@@ -22248,11 +22257,11 @@ class New {
|
|
|
22248
22257
|
const memoryReadResult = memory.loadInto(codeHash.raw, codeHashStart);
|
|
22249
22258
|
// error while reading the memory.
|
|
22250
22259
|
if (memoryReadResult.isError) {
|
|
22251
|
-
logger_logger.trace
|
|
22260
|
+
logger_logger.trace `NEW(${codeHash}, ${codeLength}, ${gas}, ${allowance}, ${gratisStorage}) <- PANIC`;
|
|
22252
22261
|
return PvmExecution.Panic;
|
|
22253
22262
|
}
|
|
22254
22263
|
const assignedId = this.partialState.newService(codeHash.asOpaque(), codeLength, gas, allowance, gratisStorage);
|
|
22255
|
-
logger_logger.trace
|
|
22264
|
+
logger_logger.trace `NEW(${codeHash}, ${codeLength}, ${gas}, ${allowance}, ${gratisStorage}) <- ${resultToString(assignedId)}`;
|
|
22256
22265
|
if (assignedId.isOk) {
|
|
22257
22266
|
regs.set(new_IN_OUT_REG, numbers_tryAsU64(assignedId.ok));
|
|
22258
22267
|
return;
|
|
@@ -22307,11 +22316,11 @@ class Provide {
|
|
|
22307
22316
|
const preimage = bytes_BytesBlob.blobFrom(new Uint8Array(length));
|
|
22308
22317
|
const memoryReadResult = memory.loadInto(preimage.raw, preimageStart);
|
|
22309
22318
|
if (memoryReadResult.isError) {
|
|
22310
|
-
logger_logger.trace
|
|
22319
|
+
logger_logger.trace `PROVIDE(${serviceId}, ${preimage.toStringTruncated()}) <- PANIC`;
|
|
22311
22320
|
return PvmExecution.Panic;
|
|
22312
22321
|
}
|
|
22313
22322
|
const result = this.partialState.providePreimage(serviceId, preimage);
|
|
22314
|
-
logger_logger.trace
|
|
22323
|
+
logger_logger.trace `PROVIDE(${serviceId}, ${preimage.toStringTruncated()}) <- ${resultToString(result)}`;
|
|
22315
22324
|
if (result.isOk) {
|
|
22316
22325
|
regs.set(provide_IN_OUT_REG, HostCallResult.OK);
|
|
22317
22326
|
return;
|
|
@@ -22365,11 +22374,11 @@ class Query {
|
|
|
22365
22374
|
const memoryReadResult = memory.loadInto(hash.raw, hashStart);
|
|
22366
22375
|
// error while reading the memory.
|
|
22367
22376
|
if (memoryReadResult.isError) {
|
|
22368
|
-
logger_logger.trace
|
|
22377
|
+
logger_logger.trace `QUERY(${hash}, ${length}) <- PANIC`;
|
|
22369
22378
|
return PvmExecution.Panic;
|
|
22370
22379
|
}
|
|
22371
22380
|
const result = this.partialState.checkPreimageStatus(hash.asOpaque(), length);
|
|
22372
|
-
logger_logger.trace
|
|
22381
|
+
logger_logger.trace `QUERY(${hash}, ${length}) <- ${result}`;
|
|
22373
22382
|
const zero = numbers_tryAsU64(0n);
|
|
22374
22383
|
if (result === null) {
|
|
22375
22384
|
regs.set(IN_OUT_REG_1, HostCallResult.NONE);
|
|
@@ -22430,11 +22439,11 @@ class Solicit {
|
|
|
22430
22439
|
const hash = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
22431
22440
|
const memoryReadResult = memory.loadInto(hash.raw, hashStart);
|
|
22432
22441
|
if (memoryReadResult.isError) {
|
|
22433
|
-
logger_logger.trace
|
|
22442
|
+
logger_logger.trace `SOLICIT(${hash}, ${length}) <- PANIC`;
|
|
22434
22443
|
return PvmExecution.Panic;
|
|
22435
22444
|
}
|
|
22436
22445
|
const result = this.partialState.requestPreimage(hash.asOpaque(), length);
|
|
22437
|
-
logger_logger.trace
|
|
22446
|
+
logger_logger.trace `SOLICIT(${hash}, ${length}) <- ${resultToString(result)}`;
|
|
22438
22447
|
if (result.isOk) {
|
|
22439
22448
|
regs.set(solicit_IN_OUT_REG, HostCallResult.OK);
|
|
22440
22449
|
return;
|
|
@@ -22506,11 +22515,11 @@ class Transfer {
|
|
|
22506
22515
|
const memoryReadResult = memory.loadInto(memo.raw, memoStart);
|
|
22507
22516
|
// page fault while reading the memory.
|
|
22508
22517
|
if (memoryReadResult.isError) {
|
|
22509
|
-
logger_logger.trace
|
|
22518
|
+
logger_logger.trace `TRANSFER(${destination}, ${amount}, ${onTransferGas}, ${memo}) <- PANIC`;
|
|
22510
22519
|
return PvmExecution.Panic;
|
|
22511
22520
|
}
|
|
22512
22521
|
const transferResult = this.partialState.transfer(destination, amount, onTransferGas, memo);
|
|
22513
|
-
logger_logger.trace
|
|
22522
|
+
logger_logger.trace `TRANSFER(${destination}, ${amount}, ${onTransferGas}, ${memo}) <- ${resultToString(transferResult)}`;
|
|
22514
22523
|
// All good!
|
|
22515
22524
|
if (transferResult.isOk) {
|
|
22516
22525
|
regs.set(transfer_IN_OUT_REG, HostCallResult.OK);
|
|
@@ -22569,11 +22578,11 @@ class Upgrade {
|
|
|
22569
22578
|
const codeHash = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
22570
22579
|
const memoryReadResult = memory.loadInto(codeHash.raw, codeHashStart);
|
|
22571
22580
|
if (memoryReadResult.isError) {
|
|
22572
|
-
logger_logger.trace
|
|
22581
|
+
logger_logger.trace `UPGRADE(${codeHash}, ${gas}, ${allowance}) <- PANIC`;
|
|
22573
22582
|
return PvmExecution.Panic;
|
|
22574
22583
|
}
|
|
22575
22584
|
this.partialState.upgradeService(codeHash.asOpaque(), gas, allowance);
|
|
22576
|
-
logger_logger.trace
|
|
22585
|
+
logger_logger.trace `UPGRADE(${codeHash}, ${gas}, ${allowance})`;
|
|
22577
22586
|
regs.set(upgrade_IN_OUT_REG, HostCallResult.OK);
|
|
22578
22587
|
}
|
|
22579
22588
|
}
|
|
@@ -22607,11 +22616,11 @@ class Yield {
|
|
|
22607
22616
|
const hash = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
22608
22617
|
const memoryReadResult = memory.loadInto(hash.raw, hashStart);
|
|
22609
22618
|
if (memoryReadResult.isError) {
|
|
22610
|
-
logger_logger.trace
|
|
22619
|
+
logger_logger.trace `YIELD() <- PANIC`;
|
|
22611
22620
|
return PvmExecution.Panic;
|
|
22612
22621
|
}
|
|
22613
22622
|
this.partialState.yield(hash);
|
|
22614
|
-
logger_logger.trace
|
|
22623
|
+
logger_logger.trace `YIELD(${hash})`;
|
|
22615
22624
|
regs.set(yield_IN_OUT_REG, HostCallResult.OK);
|
|
22616
22625
|
}
|
|
22617
22626
|
}
|
|
@@ -22653,10 +22662,10 @@ class Fetch {
|
|
|
22653
22662
|
const chunk = value === null ? new Uint8Array() : value.raw.subarray(Number(offset), Number(offset + length));
|
|
22654
22663
|
const storeResult = memory.storeFrom(output, chunk);
|
|
22655
22664
|
if (storeResult.isError) {
|
|
22656
|
-
logger_logger.trace
|
|
22665
|
+
logger_logger.trace `FETCH(${kind}) <- PANIC`;
|
|
22657
22666
|
return PvmExecution.Panic;
|
|
22658
22667
|
}
|
|
22659
|
-
logger_logger.trace
|
|
22668
|
+
logger_logger.trace `FETCH(${kind}) <- ${value?.toStringTruncated()}`;
|
|
22660
22669
|
// write result
|
|
22661
22670
|
regs.set(fetch_IN_OUT_REG, value === null ? HostCallResult.NONE : valueLength);
|
|
22662
22671
|
}
|
|
@@ -22815,10 +22824,10 @@ class Info {
|
|
|
22815
22824
|
const chunk = encodedInfo.raw.subarray(Number(offset), Number(offset + length));
|
|
22816
22825
|
const writeResult = memory.storeFrom(outputStart, chunk);
|
|
22817
22826
|
if (writeResult.isError) {
|
|
22818
|
-
logger_logger.trace
|
|
22827
|
+
logger_logger.trace `INFO(${serviceId}) <- PANIC`;
|
|
22819
22828
|
return PvmExecution.Panic;
|
|
22820
22829
|
}
|
|
22821
|
-
logger_logger.trace
|
|
22830
|
+
logger_logger.trace `INFO(${serviceId}) <- ${bytes_BytesBlob.blobFrom(chunk)}`;
|
|
22822
22831
|
if (accountInfo === null) {
|
|
22823
22832
|
regs.set(info_IN_OUT_REG, HostCallResult.NONE);
|
|
22824
22833
|
return;
|
|
@@ -22879,7 +22888,7 @@ class LogHostCall {
|
|
|
22879
22888
|
memory.loadInto(target, targetStart);
|
|
22880
22889
|
}
|
|
22881
22890
|
memory.loadInto(message, msgStart);
|
|
22882
|
-
logger_logger.trace
|
|
22891
|
+
logger_logger.trace `SERVICE [${this.currentServiceId}] [${lvl}] ${decoder.decode(target)} ${decoder.decode(message)}`;
|
|
22883
22892
|
return Promise.resolve(undefined);
|
|
22884
22893
|
}
|
|
22885
22894
|
}
|
|
@@ -22919,12 +22928,12 @@ class Lookup {
|
|
|
22919
22928
|
const preImageHash = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
22920
22929
|
const memoryReadResult = memory.loadInto(preImageHash.raw, hashAddress);
|
|
22921
22930
|
if (memoryReadResult.isError) {
|
|
22922
|
-
logger_logger.trace
|
|
22931
|
+
logger_logger.trace `LOOKUP(${serviceId}, ${preImageHash}) <- PANIC`;
|
|
22923
22932
|
return PvmExecution.Panic;
|
|
22924
22933
|
}
|
|
22925
22934
|
// v
|
|
22926
22935
|
const preImage = this.account.lookup(serviceId, preImageHash);
|
|
22927
|
-
logger_logger.trace
|
|
22936
|
+
logger_logger.trace `LOOKUP(${serviceId}, ${preImageHash}) <- ${preImage?.toStringTruncated()}...`;
|
|
22928
22937
|
const preImageLength = preImage === null ? numbers_tryAsU64(0) : numbers_tryAsU64(preImage.raw.length);
|
|
22929
22938
|
const preimageBlobOffset = regs.get(10);
|
|
22930
22939
|
const lengthToWrite = regs.get(11);
|
|
@@ -22986,7 +22995,7 @@ class Read {
|
|
|
22986
22995
|
const rawKey = bytes_BytesBlob.blobFrom(new Uint8Array(storageKeyLengthClamped));
|
|
22987
22996
|
const memoryReadResult = memory.loadInto(rawKey.raw, storageKeyStartAddress);
|
|
22988
22997
|
if (memoryReadResult.isError) {
|
|
22989
|
-
logger_logger.trace
|
|
22998
|
+
logger_logger.trace `READ(${serviceId}, ${rawKey}) <- PANIC`;
|
|
22990
22999
|
return PvmExecution.Panic;
|
|
22991
23000
|
}
|
|
22992
23001
|
// v
|
|
@@ -23004,15 +23013,15 @@ class Read {
|
|
|
23004
23013
|
const chunk = value === null ? new Uint8Array(0) : value.raw.subarray(Number(offset), Number(offset + blobLength));
|
|
23005
23014
|
const memoryWriteResult = memory.storeFrom(destinationAddress, chunk);
|
|
23006
23015
|
if (memoryWriteResult.isError) {
|
|
23007
|
-
logger_logger.trace
|
|
23016
|
+
logger_logger.trace `READ(${serviceId}, ${rawKey}) <- PANIC`;
|
|
23008
23017
|
return PvmExecution.Panic;
|
|
23009
23018
|
}
|
|
23010
23019
|
if (value === null) {
|
|
23011
|
-
logger_logger.trace
|
|
23020
|
+
logger_logger.trace `READ(${serviceId}, ${rawKey}) <- NONE`;
|
|
23012
23021
|
regs.set(read_IN_OUT_REG, HostCallResult.NONE);
|
|
23013
23022
|
return;
|
|
23014
23023
|
}
|
|
23015
|
-
logger_logger.trace
|
|
23024
|
+
logger_logger.trace `READ(${serviceId}, ${rawKey}) <- ${bytes_BytesBlob.blobFrom(chunk).toStringTruncated()}`;
|
|
23016
23025
|
regs.set(read_IN_OUT_REG, valueLength);
|
|
23017
23026
|
}
|
|
23018
23027
|
}
|
|
@@ -23055,7 +23064,7 @@ class Write {
|
|
|
23055
23064
|
const rawStorageKey = new Uint8Array(storageKeyLengthClamped);
|
|
23056
23065
|
const keyLoadingResult = memory.loadInto(rawStorageKey, storageKeyStartAddress);
|
|
23057
23066
|
if (keyLoadingResult.isError) {
|
|
23058
|
-
logger_logger.trace
|
|
23067
|
+
logger_logger.trace `WRITE() <- PANIC`;
|
|
23059
23068
|
return PvmExecution.Panic;
|
|
23060
23069
|
}
|
|
23061
23070
|
// k
|
|
@@ -23065,14 +23074,14 @@ class Write {
|
|
|
23065
23074
|
const valueLoadingResult = memory.loadInto(value, valueStart);
|
|
23066
23075
|
// Note [MaSo] this is ok to return bcs if valueLength is 0, then this panic won't happen
|
|
23067
23076
|
if (valueLoadingResult.isError) {
|
|
23068
|
-
logger_logger.trace
|
|
23077
|
+
logger_logger.trace `WRITE(${storageKey}) <- PANIC`;
|
|
23069
23078
|
return PvmExecution.Panic;
|
|
23070
23079
|
}
|
|
23071
23080
|
/** https://graypaper.fluffylabs.dev/#/9a08063/33af0133b201?v=0.6.6 */
|
|
23072
23081
|
const maybeValue = valueLength === 0n ? null : bytes_BytesBlob.blobFrom(value);
|
|
23073
23082
|
// a
|
|
23074
23083
|
const result = this.account.write(storageKey, maybeValue);
|
|
23075
|
-
logger_logger.trace
|
|
23084
|
+
logger_logger.trace `WRITE(${storageKey}, ${maybeValue?.toStringTruncated()}) <- ${resultToString(result)}`;
|
|
23076
23085
|
if (result.isError) {
|
|
23077
23086
|
regs.set(write_IN_OUT_REG, HostCallResult.FULL);
|
|
23078
23087
|
return;
|
|
@@ -23264,18 +23273,18 @@ class Accumulate {
|
|
|
23264
23273
|
async pvmAccumulateInvocation(slot, serviceId, operands, gas, entropy, inputStateUpdate) {
|
|
23265
23274
|
const service = this.state.getService(serviceId);
|
|
23266
23275
|
if (service === null) {
|
|
23267
|
-
accumulate_logger.log
|
|
23276
|
+
accumulate_logger.log `Service with id ${serviceId} not found.`;
|
|
23268
23277
|
return result_Result.error(PvmInvocationError.NoService);
|
|
23269
23278
|
}
|
|
23270
23279
|
const codeHash = service.getInfo().codeHash;
|
|
23271
23280
|
// TODO [ToDr] Should we check that the preimage is still available?
|
|
23272
23281
|
const code = service.getPreimage(codeHash.asOpaque());
|
|
23273
23282
|
if (code === null) {
|
|
23274
|
-
accumulate_logger.log
|
|
23283
|
+
accumulate_logger.log `Code with hash ${codeHash} not found for service ${serviceId}.`;
|
|
23275
23284
|
return result_Result.error(PvmInvocationError.NoPreimage);
|
|
23276
23285
|
}
|
|
23277
23286
|
if (code.length > W_C) {
|
|
23278
|
-
accumulate_logger.log
|
|
23287
|
+
accumulate_logger.log `Code with hash ${codeHash} is too long for service ${serviceId}.`;
|
|
23279
23288
|
return result_Result.error(PvmInvocationError.PreimageTooLong);
|
|
23280
23289
|
}
|
|
23281
23290
|
const nextServiceId = generateNextServiceId({ serviceId, entropy, timeslot: slot }, this.chainSpec);
|
|
@@ -23297,10 +23306,10 @@ class Accumulate {
|
|
|
23297
23306
|
if (result.hasStatus()) {
|
|
23298
23307
|
const status = result.status;
|
|
23299
23308
|
if (status === status_Status.OOG || status === status_Status.PANIC) {
|
|
23300
|
-
accumulate_logger.trace
|
|
23309
|
+
accumulate_logger.trace `[${serviceId}] accumulate finished with ${status_Status[status]} reverting to checkpoint.`;
|
|
23301
23310
|
return result_Result.ok({ stateUpdate: checkpoint, consumedGas: common_tryAsServiceGas(result.consumedGas) });
|
|
23302
23311
|
}
|
|
23303
|
-
accumulate_logger.trace
|
|
23312
|
+
accumulate_logger.trace `[${serviceId}] accumulate finished with ${status_Status[status]}`;
|
|
23304
23313
|
}
|
|
23305
23314
|
/**
|
|
23306
23315
|
* PVM invocation returned a hash so we override whatever `yield` host call
|
|
@@ -23325,14 +23334,14 @@ class Accumulate {
|
|
|
23325
23334
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/18d70118d701?v=0.6.7
|
|
23326
23335
|
*/
|
|
23327
23336
|
async accumulateSingleService(serviceId, operands, gasCost, slot, entropy, inputStateUpdate) {
|
|
23328
|
-
accumulate_logger.log
|
|
23337
|
+
accumulate_logger.log `Accumulating service ${serviceId}, items: ${operands.length} at slot: ${slot}.`;
|
|
23329
23338
|
const result = await this.pvmAccumulateInvocation(slot, serviceId, operands, gasCost, entropy, inputStateUpdate);
|
|
23330
23339
|
if (result.isError) {
|
|
23331
23340
|
// https://graypaper.fluffylabs.dev/#/7e6ff6a/2fb6012fb601?v=0.6.7
|
|
23332
|
-
accumulate_logger.log
|
|
23341
|
+
accumulate_logger.log `Accumulation failed for ${serviceId}.`;
|
|
23333
23342
|
return { stateUpdate: null, consumedGas: 0n };
|
|
23334
23343
|
}
|
|
23335
|
-
accumulate_logger.log
|
|
23344
|
+
accumulate_logger.log `Accumulation successful for ${serviceId}. Consumed: ${result.ok.consumedGas}`;
|
|
23336
23345
|
return result.ok;
|
|
23337
23346
|
}
|
|
23338
23347
|
/**
|
|
@@ -23394,7 +23403,7 @@ class Accumulate {
|
|
|
23394
23403
|
if (Compatibility.is(GpVersion.V0_7_0) && serviceId === currentManager) {
|
|
23395
23404
|
const newV = currentState.privilegedServices?.validatorsManager;
|
|
23396
23405
|
if (currentState.privilegedServices !== null && newV !== undefined && serviceIds.includes(newV)) {
|
|
23397
|
-
accumulate_logger.info
|
|
23406
|
+
accumulate_logger.info `Entering completely incorrect code that probably reverts validatorsManager change. This is valid in 0.7.0 only and incorrect in 0.7.1+`;
|
|
23398
23407
|
// Since serviceIds already contains newV, this service gets accumulated twice.
|
|
23399
23408
|
// To avoid double-counting, we skip stats and gas cost tracking here.
|
|
23400
23409
|
// We need this accumulation to get the correct `validatorsManager`
|
|
@@ -23577,13 +23586,13 @@ class DeferredTransfers {
|
|
|
23577
23586
|
const isCodeCorrect = code !== null && code.length <= W_C;
|
|
23578
23587
|
if (!hasTransfers || !isCodeCorrect) {
|
|
23579
23588
|
if (code === null) {
|
|
23580
|
-
deferred_transfers_logger.trace
|
|
23589
|
+
deferred_transfers_logger.trace `Skipping ON_TRANSFER execution for service ${serviceId} because code is null`;
|
|
23581
23590
|
}
|
|
23582
23591
|
else if (!hasTransfers) {
|
|
23583
|
-
deferred_transfers_logger.trace
|
|
23592
|
+
deferred_transfers_logger.trace `Skipping ON_TRANSFER execution for service ${serviceId} because there are no transfers`;
|
|
23584
23593
|
}
|
|
23585
23594
|
else {
|
|
23586
|
-
deferred_transfers_logger.trace
|
|
23595
|
+
deferred_transfers_logger.trace `Skipping ON_TRANSFER execution for service ${serviceId} because code is too long`;
|
|
23587
23596
|
}
|
|
23588
23597
|
}
|
|
23589
23598
|
else {
|
|
@@ -24211,7 +24220,7 @@ function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate
|
|
|
24211
24220
|
headerChain.isAncestor(context.lookupAnchorSlot, context.lookupAnchor, context.anchor);
|
|
24212
24221
|
if (!isInChain) {
|
|
24213
24222
|
if (process.env.SKIP_LOOKUP_ANCHOR_CHECK !== undefined) {
|
|
24214
|
-
verify_contextual_logger.warn
|
|
24223
|
+
verify_contextual_logger.warn `Lookup anchor check for ${context.lookupAnchor} would fail, but override is active.`;
|
|
24215
24224
|
}
|
|
24216
24225
|
else {
|
|
24217
24226
|
return result_Result.error(ReportsError.SegmentRootLookupInvalid, `Lookup anchor is not found in chain. Hash: ${context.lookupAnchor} (slot: ${context.lookupAnchorSlot})`);
|
|
@@ -25098,7 +25107,7 @@ class OnChain {
|
|
|
25098
25107
|
reports: availableReports,
|
|
25099
25108
|
entropy: entropy[0],
|
|
25100
25109
|
});
|
|
25101
|
-
chain_stf_logger.log
|
|
25110
|
+
chain_stf_logger.log `${timerAccumulate()}`;
|
|
25102
25111
|
if (accumulateResult.isError) {
|
|
25103
25112
|
return stfError(StfErrorKind.Accumulate, accumulateResult);
|
|
25104
25113
|
}
|
|
@@ -25229,7 +25238,7 @@ class Importer {
|
|
|
25229
25238
|
this.stf = new OnChain(spec, state, blocks, hasher);
|
|
25230
25239
|
this.state = state;
|
|
25231
25240
|
this.currentHash = currentBestHeaderHash;
|
|
25232
|
-
logger.info
|
|
25241
|
+
logger.info `😎 Best time slot: ${state.timeslot} (header hash: ${currentBestHeaderHash})`;
|
|
25233
25242
|
}
|
|
25234
25243
|
async importBlock(block, omitSealVerification) {
|
|
25235
25244
|
const timer = measure("importBlock");
|
|
@@ -25237,20 +25246,20 @@ class Importer {
|
|
|
25237
25246
|
const maybeBestHeader = await this.importBlockInternal(block, omitSealVerification);
|
|
25238
25247
|
if (maybeBestHeader.isOk) {
|
|
25239
25248
|
const bestHeader = maybeBestHeader.ok;
|
|
25240
|
-
this.logger.info
|
|
25241
|
-
this.logger.log
|
|
25249
|
+
this.logger.info `🧊 Best block: #${timeSlot} (${bestHeader.hash})`;
|
|
25250
|
+
this.logger.log `${timer()}`;
|
|
25242
25251
|
return maybeBestHeader;
|
|
25243
25252
|
}
|
|
25244
|
-
this.logger.log
|
|
25245
|
-
this.logger.log
|
|
25253
|
+
this.logger.log `❌ Rejected block #${timeSlot}: ${resultToString(maybeBestHeader)}`;
|
|
25254
|
+
this.logger.log `${timer()}`;
|
|
25246
25255
|
return maybeBestHeader;
|
|
25247
25256
|
}
|
|
25248
25257
|
async importBlockInternal(block, omitSealVerification = false) {
|
|
25249
25258
|
const logger = this.logger;
|
|
25250
|
-
logger.log
|
|
25259
|
+
logger.log `🧱 Attempting to import a new block`;
|
|
25251
25260
|
const timerVerify = measure("import:verify");
|
|
25252
25261
|
const hash = await this.verifier.verifyBlock(block);
|
|
25253
|
-
logger.log
|
|
25262
|
+
logger.log `${timerVerify()}`;
|
|
25254
25263
|
if (hash.isError) {
|
|
25255
25264
|
return importerError(ImporterErrorKind.Verifier, hash);
|
|
25256
25265
|
}
|
|
@@ -25270,10 +25279,10 @@ class Importer {
|
|
|
25270
25279
|
}
|
|
25271
25280
|
const timeSlot = block.header.view().timeSlotIndex.materialize();
|
|
25272
25281
|
const headerHash = hash.ok;
|
|
25273
|
-
logger.log
|
|
25282
|
+
logger.log `🧱 Verified block: Got hash ${headerHash} for block at slot ${timeSlot}.`;
|
|
25274
25283
|
const timerStf = measure("import:stf");
|
|
25275
25284
|
const res = await this.stf.transition(block, headerHash, omitSealVerification);
|
|
25276
|
-
logger.log
|
|
25285
|
+
logger.log `${timerStf()}`;
|
|
25277
25286
|
if (res.isError) {
|
|
25278
25287
|
return importerError(ImporterErrorKind.Stf, res);
|
|
25279
25288
|
}
|
|
@@ -25282,7 +25291,7 @@ class Importer {
|
|
|
25282
25291
|
const timerState = measure("import:state");
|
|
25283
25292
|
const updateResult = await this.states.updateAndSetState(headerHash, this.state, update);
|
|
25284
25293
|
if (updateResult.isError) {
|
|
25285
|
-
logger.error
|
|
25294
|
+
logger.error `🧱 Unable to update state: ${resultToString(updateResult)}`;
|
|
25286
25295
|
return importerError(ImporterErrorKind.Update, updateResult);
|
|
25287
25296
|
}
|
|
25288
25297
|
const newState = this.states.getState(headerHash);
|
|
@@ -25293,17 +25302,17 @@ class Importer {
|
|
|
25293
25302
|
// the state of a parent block to support forks and create a fresh STF.
|
|
25294
25303
|
this.state.updateBackend(newState.backend);
|
|
25295
25304
|
this.currentHash = headerHash;
|
|
25296
|
-
logger.log
|
|
25305
|
+
logger.log `${timerState()}`;
|
|
25297
25306
|
// insert new state and the block to DB.
|
|
25298
25307
|
const timerDb = measure("import:db");
|
|
25299
25308
|
const writeBlocks = this.blocks.insertBlock(new WithHash(headerHash, block));
|
|
25300
25309
|
// Computation of the state root may happen asynchronously,
|
|
25301
25310
|
// but we still need to wait for it before next block can be imported
|
|
25302
25311
|
const stateRoot = await this.states.getStateRoot(newState);
|
|
25303
|
-
logger.log
|
|
25312
|
+
logger.log `🧱 Storing post-state-root for ${headerHash}: ${stateRoot}.`;
|
|
25304
25313
|
const writeStateRoot = this.blocks.setPostStateRoot(headerHash, stateRoot);
|
|
25305
25314
|
await Promise.all([writeBlocks, writeStateRoot]);
|
|
25306
|
-
logger.log
|
|
25315
|
+
logger.log `${timerDb()}`;
|
|
25307
25316
|
// finally update the best block
|
|
25308
25317
|
await this.blocks.setBestHeaderHash(headerHash);
|
|
25309
25318
|
return result_Result.ok(new WithHash(headerHash, block.header.view()));
|
|
@@ -25405,7 +25414,7 @@ async function spawnWorkerGeneric(bootstrapPath, logger, mainReadyName, mainRead
|
|
|
25405
25414
|
const worker = new Worker(bootstrapPath);
|
|
25406
25415
|
const machine = stateMachineMain(`main->${mainReadyName}`, mainReadyName, mainReadyState);
|
|
25407
25416
|
const channel = await MessageChannelStateMachine.createAndTransferChannel(machine, worker);
|
|
25408
|
-
logger.trace
|
|
25417
|
+
logger.trace `[${machine.name}] Worker spawned ${channel.currentState()}`;
|
|
25409
25418
|
return channel;
|
|
25410
25419
|
}
|
|
25411
25420
|
|
|
@@ -25518,7 +25527,7 @@ class MainReady extends State {
|
|
|
25518
25527
|
if (res instanceof Uint8Array) {
|
|
25519
25528
|
return bytes_Bytes.fromBlob(res, hash_HASH_SIZE).asOpaque();
|
|
25520
25529
|
}
|
|
25521
|
-
state_machine_logger.error
|
|
25530
|
+
state_machine_logger.error `Invalid response for getBestStateRootHash. Expected Uint8Array, got: ${res}`;
|
|
25522
25531
|
return bytes_Bytes.zero(hash_HASH_SIZE).asOpaque();
|
|
25523
25532
|
}
|
|
25524
25533
|
finish(channel) {
|
|
@@ -25566,7 +25575,7 @@ class ImporterReady extends State {
|
|
|
25566
25575
|
}
|
|
25567
25576
|
async getStateEntries(hash) {
|
|
25568
25577
|
if (this.importer === null) {
|
|
25569
|
-
state_machine_logger.error
|
|
25578
|
+
state_machine_logger.error `${this.constructor.name} importer not initialized yet!`;
|
|
25570
25579
|
await new Promise((resolve) => {
|
|
25571
25580
|
this.onImporter.once(resolve);
|
|
25572
25581
|
});
|
|
@@ -25580,7 +25589,7 @@ class ImporterReady extends State {
|
|
|
25580
25589
|
response: encoded.raw,
|
|
25581
25590
|
};
|
|
25582
25591
|
}
|
|
25583
|
-
state_machine_logger.error
|
|
25592
|
+
state_machine_logger.error `${this.constructor.name} got invalid request type: ${JSON.stringify(hash)}.`;
|
|
25584
25593
|
return {
|
|
25585
25594
|
response: null,
|
|
25586
25595
|
};
|
|
@@ -25600,7 +25609,7 @@ class ImporterReady extends State {
|
|
|
25600
25609
|
}
|
|
25601
25610
|
async importBlock(block) {
|
|
25602
25611
|
if (this.importer === null) {
|
|
25603
|
-
state_machine_logger.error
|
|
25612
|
+
state_machine_logger.error `${this.constructor.name} importer not initialized yet!`;
|
|
25604
25613
|
await new Promise((resolve) => {
|
|
25605
25614
|
this.onImporter.once(resolve);
|
|
25606
25615
|
});
|
|
@@ -25620,8 +25629,8 @@ class ImporterReady extends State {
|
|
|
25620
25629
|
}
|
|
25621
25630
|
}
|
|
25622
25631
|
catch (e) {
|
|
25623
|
-
state_machine_logger.error
|
|
25624
|
-
state_machine_logger.error
|
|
25632
|
+
state_machine_logger.error `Failed to import block: ${e}`;
|
|
25633
|
+
state_machine_logger.error `${e instanceof Error ? e.stack : ""}`;
|
|
25625
25634
|
response = result_Result.error(`${e}`);
|
|
25626
25635
|
}
|
|
25627
25636
|
const encoded = encoder_Encoder.encodeObject(importBlockResultCodec, response);
|
|
@@ -25629,7 +25638,7 @@ class ImporterReady extends State {
|
|
|
25629
25638
|
response: encoded.raw,
|
|
25630
25639
|
};
|
|
25631
25640
|
}
|
|
25632
|
-
state_machine_logger.error
|
|
25641
|
+
state_machine_logger.error `${this.constructor.name} got invalid request type: ${JSON.stringify(block)}.`;
|
|
25633
25642
|
return {
|
|
25634
25643
|
response: null,
|
|
25635
25644
|
};
|
|
@@ -25641,7 +25650,7 @@ class ImporterReady extends State {
|
|
|
25641
25650
|
this.onBlock.emit(blockView);
|
|
25642
25651
|
}
|
|
25643
25652
|
else {
|
|
25644
|
-
state_machine_logger.error
|
|
25653
|
+
state_machine_logger.error `${this.constructor.name} got invalid signal type: ${JSON.stringify(block)}.`;
|
|
25645
25654
|
}
|
|
25646
25655
|
}
|
|
25647
25656
|
async endWork() {
|
|
@@ -25668,7 +25677,7 @@ if (!external_node_worker_threads_namespaceObject.isMainThread) {
|
|
|
25668
25677
|
Logger.configureAll(process.env.JAM_LOG ?? "", Level.LOG);
|
|
25669
25678
|
const machine = importerStateMachine();
|
|
25670
25679
|
const channel = channel_MessageChannelStateMachine.receiveChannel(machine, external_node_worker_threads_namespaceObject.parentPort);
|
|
25671
|
-
channel.then((channel) => main(channel)).catch((e) => importer_logger.error
|
|
25680
|
+
channel.then((channel) => main(channel)).catch((e) => importer_logger.error `${e}`);
|
|
25672
25681
|
}
|
|
25673
25682
|
const keccakHasher = KeccakHasher.create();
|
|
25674
25683
|
async function createImporter(config) {
|
|
@@ -25690,7 +25699,7 @@ async function createImporter(config) {
|
|
|
25690
25699
|
*/
|
|
25691
25700
|
async function main(channel) {
|
|
25692
25701
|
const wasmPromise = initAll();
|
|
25693
|
-
importer_logger.info
|
|
25702
|
+
importer_logger.info `📥 Importer starting ${channel.currentState()}`;
|
|
25694
25703
|
// Await the configuration object
|
|
25695
25704
|
const ready = await channel.waitForState("ready(importer)");
|
|
25696
25705
|
let closeDb = async () => { };
|
|
@@ -25702,7 +25711,7 @@ async function main(channel) {
|
|
|
25702
25711
|
};
|
|
25703
25712
|
// TODO [ToDr] this is shit, since we have circular dependency.
|
|
25704
25713
|
worker.setImporter(importer);
|
|
25705
|
-
importer_logger.info
|
|
25714
|
+
importer_logger.info `📥 Importer waiting for blocks.`;
|
|
25706
25715
|
worker.onBlock.on(async (block) => {
|
|
25707
25716
|
const res = await importer.importBlock(block, config.omitSealVerification);
|
|
25708
25717
|
if (res.isOk) {
|
|
@@ -25711,7 +25720,7 @@ async function main(channel) {
|
|
|
25711
25720
|
});
|
|
25712
25721
|
await wasmPromise;
|
|
25713
25722
|
});
|
|
25714
|
-
importer_logger.info
|
|
25723
|
+
importer_logger.info `📥 Importer finished. Closing channel.`;
|
|
25715
25724
|
// close the database
|
|
25716
25725
|
await closeDb();
|
|
25717
25726
|
// Close the comms to gracefuly close the app.
|