@ -48,9 +48,9 @@ func TestGeneration(t *testing.T) {
var helper = newHelper ( )
var helper = newHelper ( )
stRoot := helper . makeStorageTrie ( common . Hash { } , common . Hash { } , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , false )
stRoot := helper . makeStorageTrie ( common . Hash { } , common . Hash { } , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , false )
helper . addTrieAccount ( "acc-1" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-1" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-2" , & Account { Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-3" , & Account { Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
@ -82,16 +82,16 @@ func TestGenerateExistentState(t *testing.T) {
var helper = newHelper ( )
var helper = newHelper ( )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addTrieAccount ( "acc-1" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-1" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapAccount ( "acc-1" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapAccount ( "acc-1" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-1" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } )
helper . addSnapStorage ( "acc-1" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } )
helper . addTrieAccount ( "acc-2" , & Account { Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapAccount ( "acc-2" , & Account { Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
stRoot = helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
stRoot = helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addTrieAccount ( "acc-3" , & Account { Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapAccount ( "acc-3" , & Account { Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-3" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } )
helper . addSnapStorage ( "acc-3" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } )
root , snap := helper . CommitAndGenerate ( )
root , snap := helper . CommitAndGenerate ( )
@ -157,18 +157,18 @@ func newHelper() *testHelper {
}
}
}
}
func ( t * testHelper ) addTrieAccount ( acckey string , acc * Account ) {
func ( t * testHelper ) addTrieAccount ( acckey string , acc * Slim Account) {
val , _ := rlp . EncodeToBytes ( acc )
val , _ := rlp . EncodeToBytes ( acc )
t . accTrie . Update ( [ ] byte ( acckey ) , val )
t . accTrie . Update ( [ ] byte ( acckey ) , val )
}
}
func ( t * testHelper ) addSnapAccount ( acckey string , acc * Account ) {
func ( t * testHelper ) addSnapAccount ( acckey string , acc * Slim Account) {
val , _ := rlp . EncodeToBytes ( acc )
val , _ := rlp . EncodeToBytes ( acc )
key := hashData ( [ ] byte ( acckey ) )
key := hashData ( [ ] byte ( acckey ) )
rawdb . WriteAccountSnapshot ( t . diskdb , key , val )
rawdb . WriteAccountSnapshot ( t . diskdb , key , val )
}
}
func ( t * testHelper ) addAccount ( acckey string , acc * Account ) {
func ( t * testHelper ) addAccount ( acckey string , acc * Slim Account) {
t . addTrieAccount ( acckey , acc )
t . addTrieAccount ( acckey , acc )
t . addSnapAccount ( acckey , acc )
t . addSnapAccount ( acckey , acc )
}
}
@ -233,70 +233,70 @@ func (t *testHelper) CommitAndGenerate() (common.Hash, *diskLayer) {
func TestGenerateExistentStateWithWrongStorage ( t * testing . T ) {
func TestGenerateExistentStateWithWrongStorage ( t * testing . T ) {
helper := newHelper ( )
helper := newHelper ( )
// Account one, empty root but non-empty database
// Slim Account one, empty root but non-empty database
helper . addAccount ( "acc-1" , & Account { Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-1" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-1" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } )
helper . addSnapStorage ( "acc-1" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } )
// Account two, non empty root but empty database
// Slim Account two, non empty root but empty database
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-2" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-2" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-2" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
// Miss slots
// Miss slots
{
{
// Account three, non empty root but misses slots in the beginning
// Slim Account three, non empty root but misses slots in the beginning
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-3" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-3" , [ ] string { "key-2" , "key-3" } , [ ] string { "val-2" , "val-3" } )
helper . addSnapStorage ( "acc-3" , [ ] string { "key-2" , "key-3" } , [ ] string { "val-2" , "val-3" } )
// Account four, non empty root but misses slots in the middle
// Slim Account four, non empty root but misses slots in the middle
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-4" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-4" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-4" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-4" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-4" , [ ] string { "key-1" , "key-3" } , [ ] string { "val-1" , "val-3" } )
helper . addSnapStorage ( "acc-4" , [ ] string { "key-1" , "key-3" } , [ ] string { "val-1" , "val-3" } )
// Account five, non empty root but misses slots in the end
// Slim Account five, non empty root but misses slots in the end
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-5" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-5" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-5" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-5" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-5" , [ ] string { "key-1" , "key-2" } , [ ] string { "val-1" , "val-2" } )
helper . addSnapStorage ( "acc-5" , [ ] string { "key-1" , "key-2" } , [ ] string { "val-1" , "val-2" } )
}
}
// Wrong storage slots
// Wrong storage slots
{
{
// Account six, non empty root but wrong slots in the beginning
// Slim Account six, non empty root but wrong slots in the beginning
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-6" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-6" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-6" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-6" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-6" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "badval-1" , "val-2" , "val-3" } )
helper . addSnapStorage ( "acc-6" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "badval-1" , "val-2" , "val-3" } )
// Account seven, non empty root but wrong slots in the middle
// Slim Account seven, non empty root but wrong slots in the middle
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-7" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-7" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-7" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-7" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-7" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "badval-2" , "val-3" } )
helper . addSnapStorage ( "acc-7" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "badval-2" , "val-3" } )
// Account eight, non empty root but wrong slots in the end
// Slim Account eight, non empty root but wrong slots in the end
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-8" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-8" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-8" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-8" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-8" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "badval-3" } )
helper . addSnapStorage ( "acc-8" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "badval-3" } )
// Account 9, non empty root but rotated slots
// Slim Account 9, non empty root but rotated slots
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-9" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-9" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-9" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-9" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-9" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-3" , "val-2" } )
helper . addSnapStorage ( "acc-9" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-3" , "val-2" } )
}
}
// Extra storage slots
// Extra storage slots
{
{
// Account 10, non empty root but extra slots in the beginning
// Slim Account 10, non empty root but extra slots in the beginning
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-10" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-10" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-10" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-10" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-10" , [ ] string { "key-0" , "key-1" , "key-2" , "key-3" } , [ ] string { "val-0" , "val-1" , "val-2" , "val-3" } )
helper . addSnapStorage ( "acc-10" , [ ] string { "key-0" , "key-1" , "key-2" , "key-3" } , [ ] string { "val-0" , "val-1" , "val-2" , "val-3" } )
// Account 11, non empty root but extra slots in the middle
// Slim Account 11, non empty root but extra slots in the middle
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-11" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-11" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-11" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-11" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-11" , [ ] string { "key-1" , "key-2" , "key-2-1" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-2-1" , "val-3" } )
helper . addSnapStorage ( "acc-11" , [ ] string { "key-1" , "key-2" , "key-2-1" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-2-1" , "val-3" } )
// Account 12, non empty root but extra slots in the end
// Slim Account 12, non empty root but extra slots in the end
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-12" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-12" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-12" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-12" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-12" , [ ] string { "key-1" , "key-2" , "key-3" , "key-4" } , [ ] string { "val-1" , "val-2" , "val-3" , "val-4" } )
helper . addSnapStorage ( "acc-12" , [ ] string { "key-1" , "key-2" , "key-3" , "key-4" } , [ ] string { "val-1" , "val-2" , "val-3" , "val-4" } )
}
}
@ -336,25 +336,25 @@ func TestGenerateExistentStateWithWrongAccounts(t *testing.T) {
// Missing accounts, only in the trie
// Missing accounts, only in the trie
{
{
helper . addTrieAccount ( "acc-1" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // Beginning
helper . addTrieAccount ( "acc-1" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // Beginning
helper . addTrieAccount ( "acc-4" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // Middle
helper . addTrieAccount ( "acc-4" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // Middle
helper . addTrieAccount ( "acc-6" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // End
helper . addTrieAccount ( "acc-6" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // End
}
}
// Wrong accounts
// Wrong accounts
{
{
helper . addTrieAccount ( "acc-2" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapAccount ( "acc-2" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : common . Hex2Bytes ( "0x1234" ) } )
helper . addSnapAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : common . Hex2Bytes ( "0x1234" ) } )
helper . addTrieAccount ( "acc-3" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapAccount ( "acc-3" , & Account { Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
}
}
// Extra accounts, only in the snap
// Extra accounts, only in the snap
{
{
helper . addSnapAccount ( "acc-0" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // before the beginning
helper . addSnapAccount ( "acc-0" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // before the beginning
helper . addSnapAccount ( "acc-5" , & Account { Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : common . Hex2Bytes ( "0x1234" ) } ) // Middle
helper . addSnapAccount ( "acc-5" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : common . Hex2Bytes ( "0x1234" ) } ) // Middle
helper . addSnapAccount ( "acc-7" , & Account { Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // after the end
helper . addSnapAccount ( "acc-7" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // after the end
}
}
root , snap := helper . CommitAndGenerate ( )
root , snap := helper . CommitAndGenerate ( )
@ -383,9 +383,9 @@ func TestGenerateCorruptAccountTrie(t *testing.T) {
// without any storage slots to keep the test smaller.
// without any storage slots to keep the test smaller.
helper := newHelper ( )
helper := newHelper ( )
helper . addTrieAccount ( "acc-1" , & Account { Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0xc7a30f39aff471c95d8a837497ad0e49b65be475cc0953540f80cfcdbdcd9074
helper . addTrieAccount ( "acc-1" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0xc7a30f39aff471c95d8a837497ad0e49b65be475cc0953540f80cfcdbdcd9074
helper . addTrieAccount ( "acc-2" , & Account { Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
helper . addTrieAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
helper . addTrieAccount ( "acc-3" , & Account { Balance : big . NewInt ( 3 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x19ead688e907b0fab07176120dceec244a72aff2f0aa51e8b827584e378772f4
helper . addTrieAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 3 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x19ead688e907b0fab07176120dceec244a72aff2f0aa51e8b827584e378772f4
root := helper . Commit ( ) // Root: 0xa04693ea110a31037fb5ee814308a6f1d76bdab0b11676bdf4541d2de55ba978
root := helper . Commit ( ) // Root: 0xa04693ea110a31037fb5ee814308a6f1d76bdab0b11676bdf4541d2de55ba978
@ -418,10 +418,10 @@ func TestGenerateMissingStorageTrie(t *testing.T) {
helper := newHelper ( )
helper := newHelper ( )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true ) // 0xddefcd9376dd029653ef384bd2f0a126bb755fe84fdcc9e7cf421ba454f2bc67
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true ) // 0xddefcd9376dd029653ef384bd2f0a126bb755fe84fdcc9e7cf421ba454f2bc67
helper . addTrieAccount ( "acc-1" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
helper . addTrieAccount ( "acc-1" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
helper . addTrieAccount ( "acc-2" , & Account { Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
helper . addTrieAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
stRoot = helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
stRoot = helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addTrieAccount ( "acc-3" , & Account { Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x50815097425d000edfc8b3a4a13e175fc2bdcfee8bdfbf2d1ff61041d3c235b2
helper . addTrieAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x50815097425d000edfc8b3a4a13e175fc2bdcfee8bdfbf2d1ff61041d3c235b2
root := helper . Commit ( )
root := helper . Commit ( )
@ -452,10 +452,10 @@ func TestGenerateCorruptStorageTrie(t *testing.T) {
helper := newHelper ( )
helper := newHelper ( )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true ) // 0xddefcd9376dd029653ef384bd2f0a126bb755fe84fdcc9e7cf421ba454f2bc67
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true ) // 0xddefcd9376dd029653ef384bd2f0a126bb755fe84fdcc9e7cf421ba454f2bc67
helper . addTrieAccount ( "acc-1" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
helper . addTrieAccount ( "acc-1" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
helper . addTrieAccount ( "acc-2" , & Account { Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
helper . addTrieAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
stRoot = helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
stRoot = helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addTrieAccount ( "acc-3" , & Account { Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x50815097425d000edfc8b3a4a13e175fc2bdcfee8bdfbf2d1ff61041d3c235b2
helper . addTrieAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } ) // 0x50815097425d000edfc8b3a4a13e175fc2bdcfee8bdfbf2d1ff61041d3c235b2
root := helper . Commit ( )
root := helper . Commit ( )
@ -481,13 +481,13 @@ func TestGenerateCorruptStorageTrie(t *testing.T) {
func TestGenerateWithExtraAccounts ( t * testing . T ) {
func TestGenerateWithExtraAccounts ( t * testing . T ) {
helper := newHelper ( )
helper := newHelper ( )
{
{
// Account one in the trie
// Slim Account one in the trie
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) ,
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) ,
[ ] string { "key-1" , "key-2" , "key-3" , "key-4" , "key-5" } ,
[ ] string { "key-1" , "key-2" , "key-3" , "key-4" , "key-5" } ,
[ ] string { "val-1" , "val-2" , "val-3" , "val-4" , "val-5" } ,
[ ] string { "val-1" , "val-2" , "val-3" , "val-4" , "val-5" } ,
true ,
true ,
)
)
acc := & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) }
acc := & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) }
val , _ := rlp . EncodeToBytes ( acc )
val , _ := rlp . EncodeToBytes ( acc )
helper . accTrie . Update ( [ ] byte ( "acc-1" ) , val ) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
helper . accTrie . Update ( [ ] byte ( "acc-1" ) , val ) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
@ -501,13 +501,13 @@ func TestGenerateWithExtraAccounts(t *testing.T) {
rawdb . WriteStorageSnapshot ( helper . diskdb , key , hashData ( [ ] byte ( "key-5" ) ) , [ ] byte ( "val-5" ) )
rawdb . WriteStorageSnapshot ( helper . diskdb , key , hashData ( [ ] byte ( "key-5" ) ) , [ ] byte ( "val-5" ) )
}
}
{
{
// Account two exists only in the snapshot
// Slim Account two exists only in the snapshot
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-2" ) ) ,
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-2" ) ) ,
[ ] string { "key-1" , "key-2" , "key-3" , "key-4" , "key-5" } ,
[ ] string { "key-1" , "key-2" , "key-3" , "key-4" , "key-5" } ,
[ ] string { "val-1" , "val-2" , "val-3" , "val-4" , "val-5" } ,
[ ] string { "val-1" , "val-2" , "val-3" , "val-4" , "val-5" } ,
true ,
true ,
)
)
acc := & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) }
acc := & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) }
val , _ := rlp . EncodeToBytes ( acc )
val , _ := rlp . EncodeToBytes ( acc )
key := hashData ( [ ] byte ( "acc-2" ) )
key := hashData ( [ ] byte ( "acc-2" ) )
rawdb . WriteAccountSnapshot ( helper . diskdb , key , val )
rawdb . WriteAccountSnapshot ( helper . diskdb , key , val )
@ -545,13 +545,13 @@ func TestGenerateWithExtraAccounts(t *testing.T) {
func TestGenerateWithManyExtraAccounts ( t * testing . T ) {
func TestGenerateWithManyExtraAccounts ( t * testing . T ) {
helper := newHelper ( )
helper := newHelper ( )
{
{
// Account one in the trie
// Slim Account one in the trie
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) ,
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) ,
[ ] string { "key-1" , "key-2" , "key-3" } ,
[ ] string { "key-1" , "key-2" , "key-3" } ,
[ ] string { "val-1" , "val-2" , "val-3" } ,
[ ] string { "val-1" , "val-2" , "val-3" } ,
true ,
true ,
)
)
acc := & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) }
acc := & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) }
val , _ := rlp . EncodeToBytes ( acc )
val , _ := rlp . EncodeToBytes ( acc )
helper . accTrie . Update ( [ ] byte ( "acc-1" ) , val ) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
helper . accTrie . Update ( [ ] byte ( "acc-1" ) , val ) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
@ -565,7 +565,7 @@ func TestGenerateWithManyExtraAccounts(t *testing.T) {
{
{
// 100 accounts exist only in snapshot
// 100 accounts exist only in snapshot
for i := 0 ; i < 1000 ; i ++ {
for i := 0 ; i < 1000 ; i ++ {
acc := & Account { Balance : big . NewInt ( int64 ( i ) ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) }
acc := & Slim Account{ Balance : big . NewInt ( int64 ( i ) ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) }
val , _ := rlp . EncodeToBytes ( acc )
val , _ := rlp . EncodeToBytes ( acc )
key := hashData ( [ ] byte ( fmt . Sprintf ( "acc-%d" , i ) ) )
key := hashData ( [ ] byte ( fmt . Sprintf ( "acc-%d" , i ) ) )
rawdb . WriteAccountSnapshot ( helper . diskdb , key , val )
rawdb . WriteAccountSnapshot ( helper . diskdb , key , val )
@ -599,7 +599,7 @@ func TestGenerateWithExtraBeforeAndAfter(t *testing.T) {
accountCheckRange = 3
accountCheckRange = 3
helper := newHelper ( )
helper := newHelper ( )
{
{
acc := & Account { Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) }
acc := & Slim Account{ Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) }
val , _ := rlp . EncodeToBytes ( acc )
val , _ := rlp . EncodeToBytes ( acc )
helper . accTrie . Update ( common . HexToHash ( "0x03" ) . Bytes ( ) , val )
helper . accTrie . Update ( common . HexToHash ( "0x03" ) . Bytes ( ) , val )
helper . accTrie . Update ( common . HexToHash ( "0x07" ) . Bytes ( ) , val )
helper . accTrie . Update ( common . HexToHash ( "0x07" ) . Bytes ( ) , val )
@ -633,7 +633,7 @@ func TestGenerateWithMalformedSnapdata(t *testing.T) {
accountCheckRange = 3
accountCheckRange = 3
helper := newHelper ( )
helper := newHelper ( )
{
{
acc := & Account { Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) }
acc := & Slim Account{ Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) }
val , _ := rlp . EncodeToBytes ( acc )
val , _ := rlp . EncodeToBytes ( acc )
helper . accTrie . Update ( common . HexToHash ( "0x03" ) . Bytes ( ) , val )
helper . accTrie . Update ( common . HexToHash ( "0x03" ) . Bytes ( ) , val )
@ -672,7 +672,7 @@ func TestGenerateFromEmptySnap(t *testing.T) {
for i := 0 ; i < 400 ; i ++ {
for i := 0 ; i < 400 ; i ++ {
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( fmt . Sprintf ( "acc-%d" , i ) ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( fmt . Sprintf ( "acc-%d" , i ) ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addTrieAccount ( fmt . Sprintf ( "acc-%d" , i ) ,
helper . addTrieAccount ( fmt . Sprintf ( "acc-%d" , i ) ,
& Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
& Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
}
}
root , snap := helper . CommitAndGenerate ( )
root , snap := helper . CommitAndGenerate ( )
t . Logf ( "Root: %#x\n" , root ) // Root: 0x6f7af6d2e1a1bf2b84a3beb3f8b64388465fbc1e274ca5d5d3fc787ca78f59e4
t . Logf ( "Root: %#x\n" , root ) // Root: 0x6f7af6d2e1a1bf2b84a3beb3f8b64388465fbc1e274ca5d5d3fc787ca78f59e4
@ -709,7 +709,7 @@ func TestGenerateWithIncompleteStorage(t *testing.T) {
for i := 0 ; i < 8 ; i ++ {
for i := 0 ; i < 8 ; i ++ {
accKey := fmt . Sprintf ( "acc-%d" , i )
accKey := fmt . Sprintf ( "acc-%d" , i )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( accKey ) ) , stKeys , stVals , true )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( accKey ) ) , stKeys , stVals , true )
helper . addAccount ( accKey , & Account { Balance : big . NewInt ( int64 ( i ) ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( accKey , & Slim Account{ Balance : big . NewInt ( int64 ( i ) ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
var moddedKeys [ ] string
var moddedKeys [ ] string
var moddedVals [ ] string
var moddedVals [ ] string
for ii := 0 ; ii < 8 ; ii ++ {
for ii := 0 ; ii < 8 ; ii ++ {
@ -801,11 +801,11 @@ func TestGenerateCompleteSnapshotWithDanglingStorage(t *testing.T) {
var helper = newHelper ( )
var helper = newHelper ( )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-1" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-1" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-2" , & Account { Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addAccount ( "acc-3" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addSnapStorage ( "acc-1" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } )
helper . addSnapStorage ( "acc-1" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } )
helper . addSnapStorage ( "acc-3" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } )
helper . addSnapStorage ( "acc-3" , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } )
@ -836,11 +836,11 @@ func TestGenerateBrokenSnapshotWithDanglingStorage(t *testing.T) {
var helper = newHelper ( )
var helper = newHelper ( )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
stRoot := helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-1" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addTrieAccount ( "acc-1" , & Account { Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-1" , & Slim Account{ Balance : big . NewInt ( 1 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-2" , & Account { Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-2" , & Slim Account{ Balance : big . NewInt ( 2 ) , Root : types . EmptyRootHash . Bytes ( ) , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . makeStorageTrie ( common . Hash { } , hashData ( [ ] byte ( "acc-3" ) ) , [ ] string { "key-1" , "key-2" , "key-3" } , [ ] string { "val-1" , "val-2" , "val-3" } , true )
helper . addTrieAccount ( "acc-3" , & Account { Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
helper . addTrieAccount ( "acc-3" , & Slim Account{ Balance : big . NewInt ( 3 ) , Root : stRoot , CodeHash : types . EmptyCodeHash . Bytes ( ) } )
populateDangling ( helper . diskdb )
populateDangling ( helper . diskdb )