Skip to content

Commit 1688caa

Browse files
kyzia551sendra
authored andcommitted
Add extra checks
1 parent 975c9fc commit 1688caa

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

lib/adi-deploy

Submodule adi-deploy updated 84 files

src/contracts/libraries/Errors.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,6 @@ library Errors {
109109
string public constant ONLY_BY_PAYLOADS_MANAGER = '99'; // only payloads manager can call this function
110110
string public constant ONLY_BY_PAYLOADS_MANAGER_OR_GUARDIAN = '100'; // only payloads manager or guardian can call this function
111111
string public constant FUNCTION_NOT_SUPPORTED = '101'; // function not supported
112+
string public constant FORBIDDEN_TO_SUBMIT_NON_EXISTENT_ROOTS = '102'; // forbidden to submit non existent account roots
113+
string public constant FORBIDDEN_TO_SUBMIT_NON_EXISTENT_SLOTS = '103'; // forbidden to submit non existent storage slots
112114
}

src/contracts/voting/DataWarehouse.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ contract DataWarehouse is IDataWarehouse {
5757
accountStateProofRLP.toRlpItem().toList()
5858
);
5959

60+
require(accountData.exists, Errors.FORBIDDEN_TO_SUBMIT_NON_EXISTENT_ROOTS);
61+
6062
_storageRoots[account][blockHash] = accountData.storageRoot;
6163

6264
emit StorageRootProcessed(msg.sender, account, blockHash);
@@ -99,6 +101,7 @@ contract DataWarehouse is IDataWarehouse {
99101
slot,
100102
storageProof
101103
);
104+
require(storageSlot.exists, Errors.FORBIDDEN_TO_SUBMIT_NON_EXISTENT_SLOTS);
102105

103106
_slotsRegistered[account][blockHash][slot] = storageSlot.value;
104107

src/contracts/voting/libs/MerklePatriciaProofVerifier.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ library MerklePatriciaProofVerifier {
155155
} else {
156156
nodeHashHash = node[nibble].rlpBytesKeccak256();
157157
}
158+
159+
// sanity check
160+
if (i == stack.length - 1) {
161+
// need to process the child now
162+
revert();
163+
}
158164
} else {
159165
// we have consumed the entire mptKey, so we need to look at what's contained in this node.
160166

0 commit comments

Comments
 (0)