@ -45,7 +45,7 @@ public class VerkleEntryFactory {
trieKeyAdapter = new TrieKeyBatchAdapter ( hasher ) ;
}
public void generateAccountKeys ForRemoval ( final Address address ) {
public void generateAccountKeyForRemoval ( final Address address ) {
keysForRemoval . add ( trieKeyAdapter . basicDataKey ( address ) ) ;
}
@ -58,8 +58,7 @@ public class VerkleEntryFactory {
}
}
public void generateStorageKeysForRemoval (
final Address address , final StorageSlotKey storageKey ) {
public void generateStorageKeyForRemoval ( final Address address , final StorageSlotKey storageKey ) {
keysForRemoval . add ( trieKeyAdapter . storageKey ( address , storageKey . getSlotKey ( ) . orElseThrow ( ) ) ) ;
}
@ -69,32 +68,39 @@ public class VerkleEntryFactory {
Bytes32 basicDataValue ;
if ( ( basicDataValue = nonStorageKeyValuesForUpdate . get ( basicDataKey ) ) = = null ) {
basicDataValue = Bytes32 . ZERO ;
} else {
basicDataValue = SuffixTreeEncoder . eraseVersion ( basicDataValue ) ;
basicDataValue = SuffixTreeEncoder . eraseNonce ( basicDataValue ) ;
basicDataValue = SuffixTreeEncoder . eraseBalance ( basicDataValue ) ;
}
basicDataValue = SuffixTreeEncoder . addVersionIntoValue ( basicDataValue , Bytes32 . ZERO ) ;
basicDataValue = SuffixTreeEncoder . addNonceIntoValue ( basicDataValue , UInt256 . valueOf ( nonce ) ) ;
basicDataValue = SuffixTreeEncoder . addBalanceIntoValue ( basicDataValue , balance ) ;
basicDataValue = SuffixTreeEncoder . setVersionInValue ( basicDataValue , Bytes . of ( 0 ) ) ;
basicDataValue = SuffixTreeEncoder . setNonceInValue ( basicDataValue , Bytes . ofUnsignedLong ( nonce ) ) ;
basicDataValue =
SuffixTreeEncoder . setBalanceInValue (
basicDataValue ,
// balance size is exactly 16 bytes
balance . slice ( 16 ) ) ;
nonStorageKeyValuesForUpdate . put ( basicDataKey , basicDataValue ) ;
}
public void generateCodeHashKeyValueForUpdate ( final Address address , final Hash codeHash ) {
nonStorageKeyValuesForUpdate . put ( trieKeyAdapter . codeHashKey ( address ) , codeHash ) ;
}
public void generateCodeKeyValuesForUpdate (
final Address address , final Bytes code , final Hash codeHash ) {
Bytes32 basicDataKey = trieKeyAdapter . basicDataKey ( address ) ;
Bytes32 basicDataValue ;
if ( ( basicDataValue = nonStorageKeyValuesForUpdate . get ( basicDataKey ) ) = = null ) {
basicDataValue = Bytes32 . ZERO ;
} else {
basicDataValue = SuffixTreeEncoder . eraseCodeSize ( basicDataValue ) ;
}
basicDataValue =
SuffixTreeEncoder . addCodeSizeIntoValue ( basicDataValue , UInt256 . valueOf ( code . size ( ) ) ) ;
SuffixTreeEncoder . setCodeSizeInValue (
basicDataValue ,
// code size is exactly 3 bytes
Bytes . ofUnsignedInt ( code . size ( ) ) . slice ( 1 ) ) ;
nonStorageKeyValuesForUpdate . put ( basicDataKey , basicDataValue ) ;
nonStorageKeyValuesForUpdate . put ( trieKeyAdapter . codeHashKey ( address ) , codeHash ) ;
generateCodeHashKeyValueForUpdate ( address , codeHash ) ;
List < UInt256 > codeChunks = trieKeyAdapter . chunkifyCode ( code ) ;
for ( int i = 0 ; i < codeChunks . size ( ) ; i + + ) {
nonStorageKeyValuesForUpdate . put (