@silvana-one/upgradable 0.1.0
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 +70 -0
- package/dist/node/index.cjs +625 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.js +4 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/upgradable.d.ts +294 -0
- package/dist/node/upgradable.js +54 -0
- package/dist/node/upgradable.js.map +1 -0
- package/dist/node/upgrade.d.ts +186 -0
- package/dist/node/upgrade.js +223 -0
- package/dist/node/upgrade.js.map +1 -0
- package/dist/node/validators.d.ts +1126 -0
- package/dist/node/validators.js +383 -0
- package/dist/node/validators.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/tsconfig.web.tsbuildinfo +1 -0
- package/dist/web/index.d.ts +3 -0
- package/dist/web/index.js +4 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/upgradable.d.ts +294 -0
- package/dist/web/upgradable.js +54 -0
- package/dist/web/upgradable.js.map +1 -0
- package/dist/web/upgrade.d.ts +186 -0
- package/dist/web/upgrade.js +223 -0
- package/dist/web/upgrade.js.map +1 -0
- package/dist/web/validators.d.ts +1126 -0
- package/dist/web/validators.js +383 -0
- package/dist/web/validators.js.map +1 -0
- package/package.json +60 -0
- package/src/index.ts +3 -0
- package/src/upgradable.ts +115 -0
- package/src/upgrade.ts +294 -0
- package/src/validators.ts +497 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { SmartContract, State, VerificationKey, Field, UInt32 } from "o1js";
|
|
2
|
+
import { IndexedMapSerialized, Storage } from "@silvana-one/storage";
|
|
3
|
+
import { UpgradeAuthorityBase, VerificationKeyUpgradeData, UpgradeAuthorityAnswer } from "./upgradable.js";
|
|
4
|
+
import { UpgradeAuthorityDatabase, ValidatorsState, UpgradeDatabaseState, ValidatorsVotingProof, UpgradeDatabaseStatePacked } from "./validators.js";
|
|
5
|
+
export { VerificationKeyUpgradeAuthority, UpgradeAuthorityDatabase, ValidatorsListEvent, ValidatorsListData, };
|
|
6
|
+
/**
|
|
7
|
+
* Interface representing the data for a list of validators.
|
|
8
|
+
*/
|
|
9
|
+
interface ValidatorsListData {
|
|
10
|
+
validators: {
|
|
11
|
+
publicKey: string;
|
|
12
|
+
authorizedToVote: boolean;
|
|
13
|
+
}[];
|
|
14
|
+
validatorsCount: number;
|
|
15
|
+
root: string;
|
|
16
|
+
map: IndexedMapSerialized;
|
|
17
|
+
}
|
|
18
|
+
declare const ValidatorsListEvent_base: (new (value: {
|
|
19
|
+
validators: ValidatorsState;
|
|
20
|
+
storage: Storage;
|
|
21
|
+
}) => {
|
|
22
|
+
validators: ValidatorsState;
|
|
23
|
+
storage: Storage;
|
|
24
|
+
}) & {
|
|
25
|
+
_isStruct: true;
|
|
26
|
+
} & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
|
|
27
|
+
validators: ValidatorsState;
|
|
28
|
+
storage: Storage;
|
|
29
|
+
}, {
|
|
30
|
+
validators: {
|
|
31
|
+
chainId: bigint;
|
|
32
|
+
root: bigint;
|
|
33
|
+
count: bigint;
|
|
34
|
+
};
|
|
35
|
+
storage: {
|
|
36
|
+
url: bigint[];
|
|
37
|
+
};
|
|
38
|
+
}>, "fromFields"> & {
|
|
39
|
+
fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
|
|
40
|
+
validators: ValidatorsState;
|
|
41
|
+
storage: Storage;
|
|
42
|
+
};
|
|
43
|
+
} & {
|
|
44
|
+
fromValue: (value: {
|
|
45
|
+
validators: ValidatorsState | {
|
|
46
|
+
chainId: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
|
|
47
|
+
root: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
|
|
48
|
+
count: bigint | UInt32;
|
|
49
|
+
};
|
|
50
|
+
storage: Storage | {
|
|
51
|
+
url: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[] | bigint[];
|
|
52
|
+
};
|
|
53
|
+
}) => {
|
|
54
|
+
validators: ValidatorsState;
|
|
55
|
+
storage: Storage;
|
|
56
|
+
};
|
|
57
|
+
toInput: (x: {
|
|
58
|
+
validators: ValidatorsState;
|
|
59
|
+
storage: Storage;
|
|
60
|
+
}) => {
|
|
61
|
+
fields?: Field[] | undefined;
|
|
62
|
+
packed?: [Field, number][] | undefined;
|
|
63
|
+
};
|
|
64
|
+
toJSON: (x: {
|
|
65
|
+
validators: ValidatorsState;
|
|
66
|
+
storage: Storage;
|
|
67
|
+
}) => {
|
|
68
|
+
validators: {
|
|
69
|
+
chainId: string;
|
|
70
|
+
root: string;
|
|
71
|
+
count: string;
|
|
72
|
+
};
|
|
73
|
+
storage: {
|
|
74
|
+
url: string[];
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
fromJSON: (x: {
|
|
78
|
+
validators: {
|
|
79
|
+
chainId: string;
|
|
80
|
+
root: string;
|
|
81
|
+
count: string;
|
|
82
|
+
};
|
|
83
|
+
storage: {
|
|
84
|
+
url: string[];
|
|
85
|
+
};
|
|
86
|
+
}) => {
|
|
87
|
+
validators: ValidatorsState;
|
|
88
|
+
storage: Storage;
|
|
89
|
+
};
|
|
90
|
+
empty: () => {
|
|
91
|
+
validators: ValidatorsState;
|
|
92
|
+
storage: Storage;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Event emitted when the validators list is updated.
|
|
97
|
+
*/
|
|
98
|
+
declare class ValidatorsListEvent extends ValidatorsListEvent_base {
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* **VerificationKeyUpgradeAuthority** is a smart contract that provides a secure mechanism
|
|
102
|
+
* for upgrading the verification keys of other contracts without requiring redeployment.
|
|
103
|
+
* It manages a list of validators who can vote on upgrade proposals, ensuring that only
|
|
104
|
+
* authorized upgrades are applied.
|
|
105
|
+
*
|
|
106
|
+
* **Key Features:**
|
|
107
|
+
* - **Verification Key Management**: Allows for secure upgrades of verification keys for other contracts.
|
|
108
|
+
* - **Validators Governance**: Maintains a list of authorized validators who can vote on upgrade proposals.
|
|
109
|
+
* - **Secure Voting Mechanism**: Implements Zero-Knowledge proofs to validate votes from validators without revealing sensitive information.
|
|
110
|
+
* - **Upgrade Database Management**: Keeps track of upgrade proposals and their validity periods.
|
|
111
|
+
* - **Event Emissions**: Emits events when validators list or upgrade database is updated.
|
|
112
|
+
*/
|
|
113
|
+
declare class VerificationKeyUpgradeAuthority extends SmartContract implements UpgradeAuthorityBase {
|
|
114
|
+
/**
|
|
115
|
+
* The hash of the verification key.
|
|
116
|
+
* @type {State<Field>}
|
|
117
|
+
*/
|
|
118
|
+
verificationKeyHash: State<import("node_modules/o1js/dist/node/lib/provable/field.js").Field>;
|
|
119
|
+
/**
|
|
120
|
+
* The hash representing the current state of the validators list.
|
|
121
|
+
* @type {State<Field>}
|
|
122
|
+
*/
|
|
123
|
+
validators: State<import("node_modules/o1js/dist/node/lib/provable/field.js").Field>;
|
|
124
|
+
/**
|
|
125
|
+
* Packed state containing the upgrade database information.
|
|
126
|
+
* @type {State<UpgradeDatabaseStatePacked>}
|
|
127
|
+
*/
|
|
128
|
+
upgradeDatabasePacked: State<UpgradeDatabaseStatePacked>;
|
|
129
|
+
/**
|
|
130
|
+
* The events emitted by the VerificationKeyUpgradeAuthority contract.
|
|
131
|
+
*/
|
|
132
|
+
events: {
|
|
133
|
+
validatorsList: typeof ValidatorsListEvent;
|
|
134
|
+
updateDatabase: typeof UpgradeDatabaseState;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Deploys the contract and sets the initial state.
|
|
138
|
+
*/
|
|
139
|
+
deploy(): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Initializes the contract with validators and sets the verification key hash.
|
|
142
|
+
*
|
|
143
|
+
* @param {ValidatorsState} validators - The initial validators state.
|
|
144
|
+
* @param {Storage} storage - Off-chain storage information, e.g., IPFS hash.
|
|
145
|
+
* @param {Field} verificationKeyHash - The hash of the verification key.
|
|
146
|
+
*/
|
|
147
|
+
initialize(validators: ValidatorsState, storage: Storage, verificationKeyHash: Field): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Sets the validators list and emits an event.
|
|
150
|
+
*
|
|
151
|
+
* @param {ValidatorsState} validators - The validators state to set.
|
|
152
|
+
* @param {Storage} storage - The storage associated with the validators list.
|
|
153
|
+
*/
|
|
154
|
+
setValidatorsList(validators: ValidatorsState, storage: Storage): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Verifies the upgrade data provided by another contract.
|
|
157
|
+
*
|
|
158
|
+
* @param {VerificationKeyUpgradeData} data - The upgrade data to verify.
|
|
159
|
+
* @returns {Promise<UpgradeAuthorityAnswer>} - The answer indicating verification result.
|
|
160
|
+
*/
|
|
161
|
+
verifyUpgradeData(data: VerificationKeyUpgradeData): Promise<UpgradeAuthorityAnswer>;
|
|
162
|
+
/**
|
|
163
|
+
* Updates the upgrade database after validator consensus.
|
|
164
|
+
*
|
|
165
|
+
* @param {ValidatorsVotingProof} proof - The proof of validators voting.
|
|
166
|
+
* @param {VerificationKey} vk - The verification key to validate the proof.
|
|
167
|
+
*/
|
|
168
|
+
updateDatabase(proof: ValidatorsVotingProof, vk: VerificationKey, validators: ValidatorsState): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Updates the validators list based on validator votes.
|
|
171
|
+
*
|
|
172
|
+
* @param {ValidatorsState} validators - The new validators state.
|
|
173
|
+
* @param {Storage} storage - The storage associated with the validators list.
|
|
174
|
+
* @param {ValidatorsVotingProof} proof - The proof of validators voting.
|
|
175
|
+
* @param {VerificationKey} vk - The verification key to validate the proof.
|
|
176
|
+
*/
|
|
177
|
+
updateValidatorsList(validators: ValidatorsState, storage: Storage, proof: ValidatorsVotingProof, vk: VerificationKey): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Checks the validators' decision by verifying the provided proof.
|
|
180
|
+
*
|
|
181
|
+
* @param {ValidatorsVotingProof} proof - The proof to verify.
|
|
182
|
+
* @param {VerificationKey} vk - The verification key to validate the proof.
|
|
183
|
+
* @param {Field} decisionType - The type of decision being validated.
|
|
184
|
+
*/
|
|
185
|
+
checkValidatorsDecision(proof: ValidatorsVotingProof, vk: VerificationKey, decisionType: Field, validatorsState: ValidatorsState): Promise<void>;
|
|
186
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Bool, method, Permissions, Provable, SmartContract, State, state, VerificationKey, Field, Struct, UInt32, } from "o1js";
|
|
3
|
+
import { loadIndexedMerkleMap, createIpfsURL, Storage, } from "@silvana-one/storage";
|
|
4
|
+
import { VerificationKeyUpgradeData, UpgradeAuthorityAnswer, } from "./upgradable.js";
|
|
5
|
+
import { UpgradeAuthorityDatabase, ValidatorsState, UpgradeDatabaseState, ValidatorsVotingProof, ValidatorDecisionType, UpgradeDatabaseStatePacked, } from "./validators.js";
|
|
6
|
+
export { VerificationKeyUpgradeAuthority, UpgradeAuthorityDatabase, ValidatorsListEvent, };
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when the validators list is updated.
|
|
9
|
+
*/
|
|
10
|
+
class ValidatorsListEvent extends Struct({
|
|
11
|
+
validators: ValidatorsState,
|
|
12
|
+
storage: Storage,
|
|
13
|
+
}) {
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Error messages for the VerificationKeyUpgradeAuthority contract.
|
|
17
|
+
*/
|
|
18
|
+
const VerificationKeyUpgradeAuthorityErrors = {
|
|
19
|
+
WrongNewVerificationKeyHash: "Wrong new verification key hash",
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* **VerificationKeyUpgradeAuthority** is a smart contract that provides a secure mechanism
|
|
23
|
+
* for upgrading the verification keys of other contracts without requiring redeployment.
|
|
24
|
+
* It manages a list of validators who can vote on upgrade proposals, ensuring that only
|
|
25
|
+
* authorized upgrades are applied.
|
|
26
|
+
*
|
|
27
|
+
* **Key Features:**
|
|
28
|
+
* - **Verification Key Management**: Allows for secure upgrades of verification keys for other contracts.
|
|
29
|
+
* - **Validators Governance**: Maintains a list of authorized validators who can vote on upgrade proposals.
|
|
30
|
+
* - **Secure Voting Mechanism**: Implements Zero-Knowledge proofs to validate votes from validators without revealing sensitive information.
|
|
31
|
+
* - **Upgrade Database Management**: Keeps track of upgrade proposals and their validity periods.
|
|
32
|
+
* - **Event Emissions**: Emits events when validators list or upgrade database is updated.
|
|
33
|
+
*/
|
|
34
|
+
class VerificationKeyUpgradeAuthority extends SmartContract {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
37
|
+
/**
|
|
38
|
+
* The hash of the verification key.
|
|
39
|
+
* @type {State<Field>}
|
|
40
|
+
*/
|
|
41
|
+
this.verificationKeyHash = State();
|
|
42
|
+
/**
|
|
43
|
+
* The hash representing the current state of the validators list.
|
|
44
|
+
* @type {State<Field>}
|
|
45
|
+
*/
|
|
46
|
+
this.validators = State();
|
|
47
|
+
/**
|
|
48
|
+
* Packed state containing the upgrade database information.
|
|
49
|
+
* @type {State<UpgradeDatabaseStatePacked>}
|
|
50
|
+
*/
|
|
51
|
+
this.upgradeDatabasePacked = State();
|
|
52
|
+
/**
|
|
53
|
+
* The events emitted by the VerificationKeyUpgradeAuthority contract.
|
|
54
|
+
*/
|
|
55
|
+
this.events = {
|
|
56
|
+
validatorsList: ValidatorsListEvent,
|
|
57
|
+
updateDatabase: UpgradeDatabaseState,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Deploys the contract and sets the initial state.
|
|
62
|
+
*/
|
|
63
|
+
async deploy() {
|
|
64
|
+
await super.deploy();
|
|
65
|
+
this.upgradeDatabasePacked.set(UpgradeDatabaseState.empty().pack());
|
|
66
|
+
this.account.permissions.set({
|
|
67
|
+
...Permissions.default(),
|
|
68
|
+
setVerificationKey:
|
|
69
|
+
// The contract needs to be redeployed in the case of an upgrade.
|
|
70
|
+
Permissions.VerificationKey.impossibleDuringCurrentVersion(),
|
|
71
|
+
setPermissions: Permissions.impossible(),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Initializes the contract with validators and sets the verification key hash.
|
|
76
|
+
*
|
|
77
|
+
* @param {ValidatorsState} validators - The initial validators state.
|
|
78
|
+
* @param {Storage} storage - Off-chain storage information, e.g., IPFS hash.
|
|
79
|
+
* @param {Field} verificationKeyHash - The hash of the verification key.
|
|
80
|
+
*/
|
|
81
|
+
async initialize(validators, storage, verificationKeyHash) {
|
|
82
|
+
this.account.provedState.requireEquals(Bool(false));
|
|
83
|
+
await this.setValidatorsList(validators, storage);
|
|
84
|
+
this.verificationKeyHash.set(verificationKeyHash);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Sets the validators list and emits an event.
|
|
88
|
+
*
|
|
89
|
+
* @param {ValidatorsState} validators - The validators state to set.
|
|
90
|
+
* @param {Storage} storage - The storage associated with the validators list.
|
|
91
|
+
*/
|
|
92
|
+
async setValidatorsList(validators, storage) {
|
|
93
|
+
this.validators.set(validators.hash());
|
|
94
|
+
this.emitEvent("validatorsList", new ValidatorsListEvent({ validators, storage }));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Verifies the upgrade data provided by another contract.
|
|
98
|
+
*
|
|
99
|
+
* @param {VerificationKeyUpgradeData} data - The upgrade data to verify.
|
|
100
|
+
* @returns {Promise<UpgradeAuthorityAnswer>} - The answer indicating verification result.
|
|
101
|
+
*/
|
|
102
|
+
async verifyUpgradeData(data) {
|
|
103
|
+
const upgradeDatabase = UpgradeDatabaseState.unpack(this.upgradeDatabasePacked.getAndRequireEquals());
|
|
104
|
+
this.network.globalSlotSinceGenesis.requireBetween(upgradeDatabase.validFrom, UInt32.MAXINT());
|
|
105
|
+
const map = await Provable.witnessAsync(UpgradeAuthorityDatabase, async () => {
|
|
106
|
+
return await loadIndexedMerkleMap({
|
|
107
|
+
url: createIpfsURL({ hash: upgradeDatabase.storage.toString() }),
|
|
108
|
+
type: UpgradeAuthorityDatabase,
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
map.root.assertEquals(upgradeDatabase.root);
|
|
112
|
+
const key = data.hash();
|
|
113
|
+
const newVerificationKeyHash = map.get(key);
|
|
114
|
+
newVerificationKeyHash.assertEquals(data.newVerificationKeyHash, VerificationKeyUpgradeAuthorityErrors.WrongNewVerificationKeyHash);
|
|
115
|
+
return new UpgradeAuthorityAnswer({
|
|
116
|
+
// Should be public key of the next upgrade authority in case
|
|
117
|
+
// new version of o1js breaks the verification key of upgrade authority
|
|
118
|
+
nextUpgradeAuthority: upgradeDatabase.nextUpgradeAuthority,
|
|
119
|
+
isVerified: Bool(true),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Updates the upgrade database after validator consensus.
|
|
124
|
+
*
|
|
125
|
+
* @param {ValidatorsVotingProof} proof - The proof of validators voting.
|
|
126
|
+
* @param {VerificationKey} vk - The verification key to validate the proof.
|
|
127
|
+
*/
|
|
128
|
+
async updateDatabase(proof, vk, validators) {
|
|
129
|
+
const oldUpgradeDatabase = UpgradeDatabaseState.unpack(this.upgradeDatabasePacked.getAndRequireEquals());
|
|
130
|
+
const upgradeDatabase = proof.publicInput.decision.upgradeDatabase;
|
|
131
|
+
upgradeDatabase.version.assertGreaterThan(oldUpgradeDatabase.version);
|
|
132
|
+
await this.checkValidatorsDecision(proof, vk, ValidatorDecisionType["updateDatabase"], validators);
|
|
133
|
+
// This does not create a constraint on the storage,
|
|
134
|
+
// serves to prevent deployment errors.
|
|
135
|
+
// Can be replaced with Data Availability proof in the future.
|
|
136
|
+
// TODO: consider using Celestia DA for this.
|
|
137
|
+
const map = await Provable.witnessAsync(UpgradeAuthorityDatabase, async () => {
|
|
138
|
+
return await loadIndexedMerkleMap({
|
|
139
|
+
url: createIpfsURL({ hash: upgradeDatabase.storage.toString() }),
|
|
140
|
+
type: UpgradeAuthorityDatabase,
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
map.root.assertEquals(upgradeDatabase.root);
|
|
144
|
+
this.upgradeDatabasePacked.set(upgradeDatabase.pack());
|
|
145
|
+
this.emitEvent("updateDatabase", upgradeDatabase);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Updates the validators list based on validator votes.
|
|
149
|
+
*
|
|
150
|
+
* @param {ValidatorsState} validators - The new validators state.
|
|
151
|
+
* @param {Storage} storage - The storage associated with the validators list.
|
|
152
|
+
* @param {ValidatorsVotingProof} proof - The proof of validators voting.
|
|
153
|
+
* @param {VerificationKey} vk - The verification key to validate the proof.
|
|
154
|
+
*/
|
|
155
|
+
async updateValidatorsList(validators, storage, proof, vk) {
|
|
156
|
+
await this.checkValidatorsDecision(proof, vk, ValidatorDecisionType["updateValidatorsList"], validators);
|
|
157
|
+
await this.setValidatorsList(validators, storage);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Checks the validators' decision by verifying the provided proof.
|
|
161
|
+
*
|
|
162
|
+
* @param {ValidatorsVotingProof} proof - The proof to verify.
|
|
163
|
+
* @param {VerificationKey} vk - The verification key to validate the proof.
|
|
164
|
+
* @param {Field} decisionType - The type of decision being validated.
|
|
165
|
+
*/
|
|
166
|
+
async checkValidatorsDecision(proof, vk, decisionType, validatorsState) {
|
|
167
|
+
this.network.globalSlotSinceGenesis.requireBetween(UInt32.zero, proof.publicInput.decision.expiry);
|
|
168
|
+
vk.hash.assertEquals(this.verificationKeyHash.getAndRequireEquals());
|
|
169
|
+
proof.verify(vk);
|
|
170
|
+
proof.publicInput.decision.validators
|
|
171
|
+
.hash()
|
|
172
|
+
.assertEquals(this.validators.getAndRequireEquals());
|
|
173
|
+
proof.publicInput.decision.decisionType.assertEquals(decisionType);
|
|
174
|
+
proof.publicInput.decision.contractAddress.assertEquals(this.address);
|
|
175
|
+
validatorsState.hash().assertEquals(this.validators.getAndRequireEquals());
|
|
176
|
+
proof.publicOutput.yesVotes.mul(2).assertGreaterThan(validatorsState.count);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
__decorate([
|
|
180
|
+
state(Field),
|
|
181
|
+
__metadata("design:type", Object)
|
|
182
|
+
], VerificationKeyUpgradeAuthority.prototype, "verificationKeyHash", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
state(Field),
|
|
185
|
+
__metadata("design:type", Object)
|
|
186
|
+
], VerificationKeyUpgradeAuthority.prototype, "validators", void 0);
|
|
187
|
+
__decorate([
|
|
188
|
+
state(UpgradeDatabaseStatePacked),
|
|
189
|
+
__metadata("design:type", Object)
|
|
190
|
+
], VerificationKeyUpgradeAuthority.prototype, "upgradeDatabasePacked", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
method,
|
|
193
|
+
__metadata("design:type", Function),
|
|
194
|
+
__metadata("design:paramtypes", [ValidatorsState,
|
|
195
|
+
Storage,
|
|
196
|
+
Field]),
|
|
197
|
+
__metadata("design:returntype", Promise)
|
|
198
|
+
], VerificationKeyUpgradeAuthority.prototype, "initialize", null);
|
|
199
|
+
__decorate([
|
|
200
|
+
method.returns(UpgradeAuthorityAnswer),
|
|
201
|
+
__metadata("design:type", Function),
|
|
202
|
+
__metadata("design:paramtypes", [VerificationKeyUpgradeData]),
|
|
203
|
+
__metadata("design:returntype", Promise)
|
|
204
|
+
], VerificationKeyUpgradeAuthority.prototype, "verifyUpgradeData", null);
|
|
205
|
+
__decorate([
|
|
206
|
+
method,
|
|
207
|
+
__metadata("design:type", Function),
|
|
208
|
+
__metadata("design:paramtypes", [ValidatorsVotingProof,
|
|
209
|
+
VerificationKey,
|
|
210
|
+
ValidatorsState]),
|
|
211
|
+
__metadata("design:returntype", Promise)
|
|
212
|
+
], VerificationKeyUpgradeAuthority.prototype, "updateDatabase", null);
|
|
213
|
+
__decorate([
|
|
214
|
+
method // add proof of validators voting
|
|
215
|
+
,
|
|
216
|
+
__metadata("design:type", Function),
|
|
217
|
+
__metadata("design:paramtypes", [ValidatorsState,
|
|
218
|
+
Storage,
|
|
219
|
+
ValidatorsVotingProof,
|
|
220
|
+
VerificationKey]),
|
|
221
|
+
__metadata("design:returntype", Promise)
|
|
222
|
+
], VerificationKeyUpgradeAuthority.prototype, "updateValidatorsList", null);
|
|
223
|
+
//# sourceMappingURL=upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/upgrade.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,WAAW,EACX,QAAQ,EACR,aAAa,EACb,KAAK,EACL,KAAK,EACL,eAAe,EACf,KAAK,EACL,MAAM,EACN,MAAM,GACP,MAAM,MAAM,CAAC;AACd,OAAO,EACL,oBAAoB,EACpB,aAAa,EAEb,OAAO,GACR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,GAEpB,CAAC;AAeF;;GAEG;AACH,MAAM,mBAAoB,SAAQ,MAAM,CAAC;IACvC,UAAU,EAAE,eAAe;IAC3B,OAAO,EAAE,OAAO;CACjB,CAAC;CAAG;AAEL;;GAEG;AACH,MAAM,qCAAqC,GAAG;IAC5C,2BAA2B,EAAE,iCAAiC;CAC/D,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,+BACJ,SAAQ,aAAa;IADvB;;QAIE;;;WAGG;QACW,wBAAmB,GAAG,KAAK,EAAS,CAAC;QAEnD;;;WAGG;QACW,eAAU,GAAG,KAAK,EAAS,CAAC;QAE1C;;;WAGG;QAEH,0BAAqB,GAAG,KAAK,EAA8B,CAAC;QAE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