You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each time MutableRepository.addStorageBytes() its called, it triggers an unnecessary Trie.find() operation by doing MutableTrie.getValueLength(). This may cause performance issues, or at least it's not the most performant option, this is because (as the comment says) we have test code in production.
@OverridepublicsynchronizedvoidaddStorageBytes(RskAddressaddr, DataWordkey, byte[] value) {
// This should not happen in production because contracts are created before storage cells are added to them.// But it happens in Repository tests, that create only storage row cells.if (!isExist(addr)) {
createAccount(addr);
setupContract(addr);
}
byte[] triekey = trieKeyMapper.getAccountStorageKey(addr, key);
// Special case: if the value is an empty vector, we pass "null" which commands the trie to remove the item.// Note that if the call comes from addStorageRow(), this method will already have replaced 0 by null, so the// conversion here only applies if this is called directly. If suppose this only occurs in tests, but it can// also occur in precompiled contracts that store data directly using this method.if (value == null || value.length == 0) {
mutableTrie.put(triekey, null);
} else {
mutableTrie.put(triekey, value);
}
}
same happens in MutableRepository.saveCode()
@OverridepublicsynchronizedvoidsaveCode(RskAddressaddr, byte[] code) {
byte[] key = trieKeyMapper.getCodeKey(addr);
mutableTrie.put(key, code);
// THIS IS TEST CODE IN PRODUCTIONif (code != null && code.length != 0 && !isExist(addr)) {
createAccount(addr);
}
}
We should try to refactor it and move test code into tests.
The text was updated successfully, but these errors were encountered:
Each time MutableRepository.addStorageBytes() its called, it triggers an unnecessary
Trie.find()
operation by doingMutableTrie.getValueLength()
. This may cause performance issues, or at least it's not the most performant option, this is because (as the comment says) we have test code in production.same happens in
MutableRepository.saveCode()
We should try to refactor it and move test code into tests.
The text was updated successfully, but these errors were encountered: