@mainsail/consensus 0.0.1-evm.5 → 0.0.1-evm.51
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/distribution/aggregator.d.ts +3 -4
- package/distribution/aggregator.d.ts.map +1 -1
- package/distribution/aggregator.js +11 -9
- package/distribution/aggregator.js.map +1 -1
- package/distribution/bootstrapper.d.ts +1 -1
- package/distribution/bootstrapper.d.ts.map +1 -1
- package/distribution/bootstrapper.js +15 -16
- package/distribution/bootstrapper.js.map +1 -1
- package/distribution/commit-state.d.ts +2 -3
- package/distribution/commit-state.d.ts.map +1 -1
- package/distribution/commit-state.js +21 -41
- package/distribution/commit-state.js.map +1 -1
- package/distribution/consensus.d.ts +10 -9
- package/distribution/consensus.d.ts.map +1 -1
- package/distribution/consensus.js +274 -224
- package/distribution/consensus.js.map +1 -1
- package/distribution/index.d.ts +1 -5
- package/distribution/index.d.ts.map +1 -1
- package/distribution/index.js +1 -30
- package/distribution/index.js.map +1 -1
- package/distribution/processors/abstract-processor.d.ts +5 -5
- package/distribution/processors/abstract-processor.d.ts.map +1 -1
- package/distribution/processors/abstract-processor.js +11 -7
- package/distribution/processors/abstract-processor.js.map +1 -1
- package/distribution/processors/commit-processor.d.ts +1 -2
- package/distribution/processors/commit-processor.d.ts.map +1 -1
- package/distribution/processors/commit-processor.js +29 -46
- package/distribution/processors/commit-processor.js.map +1 -1
- package/distribution/processors/index.d.ts +1 -2
- package/distribution/processors/index.d.ts.map +1 -1
- package/distribution/processors/index.js +1 -2
- package/distribution/processors/index.js.map +1 -1
- package/distribution/processors/message-processor.d.ts +13 -0
- package/distribution/processors/message-processor.d.ts.map +1 -0
- package/distribution/processors/message-processor.js +117 -0
- package/distribution/processors/message-processor.js.map +1 -0
- package/distribution/processors/proposal-processor.d.ts +3 -2
- package/distribution/processors/proposal-processor.d.ts.map +1 -1
- package/distribution/processors/proposal-processor.js +46 -41
- package/distribution/processors/proposal-processor.js.map +1 -1
- package/distribution/round-state-repository.d.ts +2 -2
- package/distribution/round-state-repository.d.ts.map +1 -1
- package/distribution/round-state-repository.js +13 -23
- package/distribution/round-state-repository.js.map +1 -1
- package/distribution/round-state.d.ts +14 -10
- package/distribution/round-state.d.ts.map +1 -1
- package/distribution/round-state.js +173 -153
- package/distribution/round-state.js.map +1 -1
- package/distribution/scheduler.d.ts +1 -1
- package/distribution/scheduler.d.ts.map +1 -1
- package/distribution/scheduler.js +49 -65
- package/distribution/scheduler.js.map +1 -1
- package/distribution/service-provider.d.ts +6 -0
- package/distribution/service-provider.d.ts.map +1 -0
- package/distribution/service-provider.js +42 -0
- package/distribution/service-provider.js.map +1 -0
- package/package.json +14 -11
- package/distribution/processors/precommit-processor.d.ts +0 -12
- package/distribution/processors/precommit-processor.d.ts.map +0 -1
- package/distribution/processors/precommit-processor.js +0 -77
- package/distribution/processors/precommit-processor.js.map +0 -1
- package/distribution/processors/prevote-processor.d.ts +0 -12
- package/distribution/processors/prevote-processor.d.ts.map +0 -1
- package/distribution/processors/prevote-processor.js +0 -77
- package/distribution/processors/prevote-processor.js.map +0 -1
|
@@ -7,37 +7,37 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
12
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14
|
-
};
|
|
15
|
-
var _ProposalProcessor_instances, _ProposalProcessor_hasValidProposer, _ProposalProcessor_hasValidSignature;
|
|
10
|
+
import { Enums, Identifiers } from "@mainsail/constants";
|
|
16
11
|
import { inject, injectable, tagged } from "@mainsail/container";
|
|
17
|
-
import { Contracts, Identifiers } from "@mainsail/contracts";
|
|
18
12
|
import { AbstractProcessor } from "./abstract-processor.js";
|
|
19
13
|
let ProposalProcessor = class ProposalProcessor extends AbstractProcessor {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
proposalSerializer;
|
|
15
|
+
messageSerializer;
|
|
16
|
+
consensusSignature;
|
|
17
|
+
configuration;
|
|
18
|
+
aggregator;
|
|
19
|
+
proposerCalculator;
|
|
20
|
+
validatorSet;
|
|
21
|
+
roundStateRepo;
|
|
22
|
+
broadcaster;
|
|
23
|
+
logger;
|
|
24
24
|
async process(proposal, broadcast = true) {
|
|
25
25
|
return this.commitLock.runNonExclusive(async () => {
|
|
26
|
-
if (!this.
|
|
27
|
-
return
|
|
26
|
+
if (!this.hasValidBlockNumberOrRound({ blockNumber: proposal.blockHeader.number, round: proposal.round })) {
|
|
27
|
+
return Enums.Consensus.ProcessorResult.Skipped;
|
|
28
28
|
}
|
|
29
29
|
if (!this.isRoundInBounds(proposal)) {
|
|
30
|
-
return
|
|
30
|
+
return Enums.Consensus.ProcessorResult.Invalid;
|
|
31
31
|
}
|
|
32
|
-
if (!
|
|
33
|
-
return
|
|
32
|
+
if (!this.#hasValidProposer(proposal)) {
|
|
33
|
+
return Enums.Consensus.ProcessorResult.Invalid;
|
|
34
34
|
}
|
|
35
|
-
if (!(await
|
|
36
|
-
return
|
|
35
|
+
if (!(await this.#hasValidSignature(proposal))) {
|
|
36
|
+
return Enums.Consensus.ProcessorResult.Invalid;
|
|
37
37
|
}
|
|
38
|
-
const roundState = this.roundStateRepo.getRoundState(proposal.
|
|
38
|
+
const roundState = this.roundStateRepo.getRoundState(proposal.blockHeader.number, proposal.round);
|
|
39
39
|
if (roundState.hasProposal()) {
|
|
40
|
-
return
|
|
40
|
+
return Enums.Consensus.ProcessorResult.Skipped;
|
|
41
41
|
}
|
|
42
42
|
roundState.addProposal(proposal);
|
|
43
43
|
if (broadcast) {
|
|
@@ -47,7 +47,7 @@ let ProposalProcessor = class ProposalProcessor extends AbstractProcessor {
|
|
|
47
47
|
setTimeout(() => {
|
|
48
48
|
void this.getConsensus().handle(roundState);
|
|
49
49
|
}, 0);
|
|
50
|
-
return
|
|
50
|
+
return Enums.Consensus.ProcessorResult.Accepted;
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
async hasValidLockProof(proposal) {
|
|
@@ -55,35 +55,40 @@ let ProposalProcessor = class ProposalProcessor extends AbstractProcessor {
|
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
57
|
if (proposal.validRound >= proposal.round) {
|
|
58
|
-
this.logger.debug(`Received proposal ${proposal.
|
|
58
|
+
this.logger.debug(`Received proposal ${proposal.blockHeader.number}/${proposal.round} has validRound ${proposal.validRound} >= round ${proposal.round}`, "consensus");
|
|
59
59
|
return false;
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.logger.debug(`Received proposal ${proposal.height}/${proposal.round} with missing lock proof`);
|
|
61
|
+
if (!proposal.lockProof) {
|
|
62
|
+
this.logger.debug(`Received proposal ${proposal.blockHeader.number}/${proposal.round} with missing lock proof`, "consensus");
|
|
64
63
|
return true;
|
|
65
64
|
}
|
|
66
|
-
const data = await this.messageSerializer.
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
const data = await this.messageSerializer.serializeMessageForSignature({
|
|
66
|
+
blockHash: proposal.blockHeader.hash,
|
|
67
|
+
blockNumber: proposal.blockHeader.number,
|
|
69
68
|
round: proposal.validRound,
|
|
70
|
-
type:
|
|
69
|
+
type: Enums.Crypto.MessageType.Prevote,
|
|
70
|
+
}, {
|
|
71
|
+
genesisBlockHash: this.stateStore.getGenesisCommit().block.hash,
|
|
72
|
+
previousBlockHash: this.stateStore.getLastBlock().hash,
|
|
71
73
|
});
|
|
72
|
-
const {
|
|
73
|
-
const verified = await this.aggregator.verify(lockProof, data,
|
|
74
|
+
const { roundValidators } = this.configuration.getMilestone(proposal.blockHeader.number);
|
|
75
|
+
const verified = await this.aggregator.verify(proposal.lockProof, data, roundValidators);
|
|
74
76
|
if (!verified) {
|
|
75
|
-
this.logger.debug(`Received proposal ${proposal.
|
|
77
|
+
this.logger.debug(`Received proposal ${proposal.blockHeader.number}/${proposal.round} with invalid lock proof`, "consensus");
|
|
76
78
|
}
|
|
77
79
|
return verified;
|
|
78
80
|
}
|
|
81
|
+
#hasValidProposer(proposal) {
|
|
82
|
+
return proposal.validatorIndex === this.proposerCalculator.getValidatorIndex(proposal.round);
|
|
83
|
+
}
|
|
84
|
+
async #hasValidSignature(proposal) {
|
|
85
|
+
return this.consensusSignature.verify(Buffer.from(proposal.signature, "hex"), await this.proposalSerializer.serializeProposalUnsigned(proposal.toSerializableData()), Buffer.from(this.validatorSet.getValidator(proposal.validatorIndex).blsPublicKey, "hex"));
|
|
86
|
+
}
|
|
79
87
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
_ProposalProcessor_hasValidSignature = async function _ProposalProcessor_hasValidSignature(proposal) {
|
|
85
|
-
return this.consensusSignature.verify(Buffer.from(proposal.signature, "hex"), await this.messageSerializer.serializeProposal(proposal.toSerializableData(), { includeSignature: false }), Buffer.from(this.validatorSet.getValidator(proposal.validatorIndex).blsPublicKey, "hex"));
|
|
86
|
-
};
|
|
88
|
+
__decorate([
|
|
89
|
+
inject(Identifiers.Cryptography.Proposal.Serializer),
|
|
90
|
+
__metadata("design:type", Object)
|
|
91
|
+
], ProposalProcessor.prototype, "proposalSerializer", void 0);
|
|
87
92
|
__decorate([
|
|
88
93
|
inject(Identifiers.Cryptography.Message.Serializer),
|
|
89
94
|
__metadata("design:type", Object)
|
|
@@ -102,9 +107,9 @@ __decorate([
|
|
|
102
107
|
__metadata("design:type", Object)
|
|
103
108
|
], ProposalProcessor.prototype, "aggregator", void 0);
|
|
104
109
|
__decorate([
|
|
105
|
-
inject(Identifiers.
|
|
110
|
+
inject(Identifiers.BlockchainUtils.ProposerCalculator),
|
|
106
111
|
__metadata("design:type", Object)
|
|
107
|
-
], ProposalProcessor.prototype, "
|
|
112
|
+
], ProposalProcessor.prototype, "proposerCalculator", void 0);
|
|
108
113
|
__decorate([
|
|
109
114
|
inject(Identifiers.ValidatorSet.Service),
|
|
110
115
|
__metadata("design:type", Object)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposal-processor.js","sourceRoot":"","sources":["../../source/processors/proposal-processor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proposal-processor.js","sourceRoot":"","sources":["../../source/processors/proposal-processor.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGrD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,iBAAiB;IAEtC,kBAAkB,CAAuC;IAGzD,iBAAiB,CAAsC;IAIvD,kBAAkB,CAAiC;IAGnD,aAAa,CAAkC;IAG/C,UAAU,CAAkC;IAG5C,kBAAkB,CAAgD;IAGlE,YAAY,CAAkC;IAG9C,cAAc,CAA4C;IAG1D,WAAW,CAA6B;IAGxC,MAAM,CAA2B;IAElD,KAAK,CAAC,OAAO,CACZ,QAAmC,EACnC,YAAqB,IAAI;QAEzB,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,KAAK,IAAI,EAAE;YACjD,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;gBAC3G,OAAO,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC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AkB,CAAC;;6DAC4B;AAGlE;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC;;uDACsB;AAG9C;IADhB,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,oBAAoB,CAAC;;yDACwB;AAG1D;IADhB,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC;;sDACqB;AAGxC;IADhB,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;;iDACS;AA9BtC,iBAAiB;IAD7B,UAAU,EAAE;GACA,iBAAiB,CAoI7B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Contracts } from "@mainsail/contracts";
|
|
1
|
+
import type { Contracts } from "@mainsail/contracts";
|
|
2
2
|
export declare class RoundStateRepository implements Contracts.Consensus.RoundStateRepository {
|
|
3
3
|
#private;
|
|
4
4
|
private readonly app;
|
|
5
|
-
getRoundState(
|
|
5
|
+
getRoundState(blockNumber: number, round: number): Contracts.Consensus.RoundState;
|
|
6
6
|
getRoundStates(): Contracts.Consensus.RoundState[];
|
|
7
7
|
clear(): void;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round-state-repository.d.ts","sourceRoot":"","sources":["../source/round-state-repository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"round-state-repository.d.ts","sourceRoot":"","sources":["../source/round-state-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAMrD,qBACa,oBAAqB,YAAW,SAAS,CAAC,SAAS,CAAC,oBAAoB;;IAEpF,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgC;IAI7C,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,UAAU;IAUjF,cAAc,IAAI,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE;IAIlD,KAAK,IAAI,IAAI;CAOpB"}
|
|
@@ -7,38 +7,28 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
12
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14
|
-
};
|
|
15
|
-
var _RoundStateRepository_instances, _RoundStateRepository_roundStates, _RoundStateRepository_createRoundState;
|
|
10
|
+
import { Identifiers } from "@mainsail/constants";
|
|
16
11
|
import { inject, injectable } from "@mainsail/container";
|
|
17
|
-
import { Contracts, Identifiers } from "@mainsail/contracts";
|
|
18
12
|
import { RoundState } from "./round-state.js";
|
|
19
13
|
let RoundStateRepository = class RoundStateRepository {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!__classPrivateFieldGet(this, _RoundStateRepository_roundStates, "f").has(key)) {
|
|
27
|
-
__classPrivateFieldGet(this, _RoundStateRepository_roundStates, "f").set(key, __classPrivateFieldGet(this, _RoundStateRepository_instances, "m", _RoundStateRepository_createRoundState).call(this, height, round));
|
|
14
|
+
app;
|
|
15
|
+
#roundStates = new Map();
|
|
16
|
+
getRoundState(blockNumber, round) {
|
|
17
|
+
const key = `${blockNumber}-${round}`;
|
|
18
|
+
if (!this.#roundStates.has(key)) {
|
|
19
|
+
this.#roundStates.set(key, this.#createRoundState(blockNumber, round));
|
|
28
20
|
}
|
|
29
|
-
return
|
|
21
|
+
return this.#roundStates.get(key);
|
|
30
22
|
}
|
|
31
23
|
getRoundStates() {
|
|
32
|
-
return [...
|
|
24
|
+
return [...this.#roundStates.values()];
|
|
33
25
|
}
|
|
34
26
|
clear() {
|
|
35
|
-
|
|
27
|
+
this.#roundStates.clear();
|
|
28
|
+
}
|
|
29
|
+
#createRoundState(blockNumber, round) {
|
|
30
|
+
return this.app.resolve(RoundState).configure(blockNumber, round);
|
|
36
31
|
}
|
|
37
|
-
};
|
|
38
|
-
_RoundStateRepository_roundStates = new WeakMap();
|
|
39
|
-
_RoundStateRepository_instances = new WeakSet();
|
|
40
|
-
_RoundStateRepository_createRoundState = function _RoundStateRepository_createRoundState(height, round) {
|
|
41
|
-
return this.app.resolve(RoundState).configure(height, round);
|
|
42
32
|
};
|
|
43
33
|
__decorate([
|
|
44
34
|
inject(Identifiers.Application.Instance),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round-state-repository.js","sourceRoot":"","sources":["../source/round-state-repository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"round-state-repository.js","sourceRoot":"","sources":["../source/round-state-repository.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEvC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAEf,GAAG,CAAgC;IAEpD,YAAY,GAAG,IAAI,GAAG,EAA0C,CAAC;IAE1D,aAAa,CAAC,WAAmB,EAAE,KAAa;QACtD,MAAM,GAAG,GAAG,GAAG,WAAW,IAAI,KAAK,EAAE,CAAC;QAEtC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;IACpC,CAAC;IAEM,cAAc;QACpB,OAAO,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED,iBAAiB,CAAC,WAAmB,EAAE,KAAa;QACnD,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;CACD,CAAA;AAzBiB;IADhB,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC;;iDACW;AAFxC,oBAAoB;IADhC,UAAU,EAAE;GACA,oBAAoB,CA2BhC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Contracts } from "@mainsail/contracts";
|
|
1
|
+
import type { Contracts } from "@mainsail/contracts";
|
|
2
2
|
export declare class RoundState implements Contracts.Consensus.RoundState {
|
|
3
3
|
#private;
|
|
4
4
|
private readonly aggregator;
|
|
5
5
|
private readonly configuration;
|
|
6
6
|
private readonly validatorSet;
|
|
7
|
-
private readonly
|
|
7
|
+
private readonly proposerCalculator;
|
|
8
8
|
private readonly commitSerializer;
|
|
9
9
|
private readonly logger;
|
|
10
|
-
get
|
|
10
|
+
get blockNumber(): number;
|
|
11
11
|
get round(): number;
|
|
12
12
|
get persist(): boolean;
|
|
13
13
|
get validators(): string[];
|
|
14
14
|
get proposer(): Contracts.State.ValidatorWallet;
|
|
15
|
-
configure(
|
|
15
|
+
configure(blockNumber: number, round: number): RoundState;
|
|
16
16
|
getValidator(consensusPublicKey: string): Contracts.State.ValidatorWallet;
|
|
17
17
|
hasProposal(): boolean;
|
|
18
18
|
addProposal(proposal: Contracts.Crypto.Proposal): void;
|
|
@@ -25,19 +25,23 @@ export declare class RoundState implements Contracts.Consensus.RoundState {
|
|
|
25
25
|
getAccountUpdates(): Array<Contracts.Evm.AccountUpdate>;
|
|
26
26
|
setAccountUpdates(accounts: Array<Contracts.Evm.AccountUpdate>): void;
|
|
27
27
|
hasPrevote(validatorIndex: number): boolean;
|
|
28
|
-
addPrevote(prevote: Contracts.Crypto.
|
|
28
|
+
addPrevote(prevote: Contracts.Crypto.Message): void;
|
|
29
29
|
hasPrecommit(validatorIndex: number): boolean;
|
|
30
|
-
addPrecommit(precommit: Contracts.Crypto.
|
|
30
|
+
addPrecommit(precommit: Contracts.Crypto.Message): void;
|
|
31
|
+
hasMessage(message: Contracts.Crypto.Message): boolean;
|
|
32
|
+
getMessage(validatorIndex: number, type: Contracts.Crypto.MessageType): Contracts.Crypto.Message | undefined;
|
|
33
|
+
addMessage(message: Contracts.Crypto.Message): void;
|
|
31
34
|
hasMajorityPrevotes(): boolean;
|
|
32
35
|
hasMajorityPrevotesAny(): boolean;
|
|
33
36
|
hasMajorityPrevotesNull(): boolean;
|
|
34
37
|
hasMajorityPrecommits(): boolean;
|
|
35
38
|
hasMajorityPrecommitsAny(): boolean;
|
|
36
39
|
hasMinorityPrevotesOrPrecommits(): boolean;
|
|
37
|
-
getPrevote(validatorIndex: number): Contracts.Crypto.
|
|
38
|
-
getPrevotes(): Contracts.Crypto.
|
|
39
|
-
getPrecommit(validatorIndex: number): Contracts.Crypto.
|
|
40
|
-
|
|
40
|
+
getPrevote(validatorIndex: number): Contracts.Crypto.Message | undefined;
|
|
41
|
+
getPrevotes(): Contracts.Crypto.Message[];
|
|
42
|
+
getPrecommit(validatorIndex: number): Contracts.Crypto.Message | undefined;
|
|
43
|
+
getMessages(): Contracts.Crypto.Message[];
|
|
44
|
+
getPrecommits(): Contracts.Crypto.Message[];
|
|
41
45
|
getValidatorsSignedPrevote(): readonly boolean[];
|
|
42
46
|
getValidatorsSignedPrecommit(): readonly boolean[];
|
|
43
47
|
aggregatePrevotes(): Promise<Contracts.Crypto.AggregatedSignature>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round-state.d.ts","sourceRoot":"","sources":["../source/round-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"round-state.d.ts","sourceRoot":"","sources":["../source/round-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAOrD,qBACa,UAAW,YAAW,SAAS,CAAC,SAAS,CAAC,UAAU;;IAEhE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkC;IAG7D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAkC;IAGhE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAkC;IAG/D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAgD;IAGnF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAqC;IAGtE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;IAkBlD,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED,IAAW,UAAU,IAAI,MAAM,EAAE,CAEhC;IAED,IAAW,QAAQ,IAAI,SAAS,CAAC,KAAK,CAAC,eAAe,CAErD;IAEM,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAmBzD,YAAY,CAAC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,eAAe;IAMzE,WAAW,IAAI,OAAO;IAItB,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI;IAQtD,WAAW,IAAI,SAAS,CAAC,MAAM,CAAC,QAAQ,GAAG,SAAS;IAIpD,QAAQ,IAAI,SAAS,CAAC,MAAM,CAAC,KAAK;IAQ5B,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;IA6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