common.BytesToHash(path) => crypto.Keaccak256(hash) in builder; BytesToHash produces same hash for e.g. []byte{} and []byte{\x00} - prefix \x00 steps are inconsequential to the hash result
This commit is contained in:
		
							parent
							
								
									b5a9ea52e0
								
							
						
					
					
						commit
						5598d67872
					
				| @ -148,6 +148,7 @@ func (sdb *builder) collectDiffNodes(a, b trie.NodeIterator) (AccountsMap, error | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nodePathHash := crypto.Keccak256Hash(nodePath) | ||||
| 		switch ty { | ||||
| 		case Leaf: | ||||
| 			var account state.Account | ||||
| @ -166,11 +167,11 @@ func (sdb *builder) collectDiffNodes(a, b trie.NodeIterator) (AccountsMap, error | ||||
| 					LeafKey:   leafKey, | ||||
| 					Account:   &account, | ||||
| 				} | ||||
| 				diffAccounts[common.BytesToHash(encodedPath)] = aw | ||||
| 				diffAccounts[nodePathHash] = aw | ||||
| 			} | ||||
| 		case Extension, Branch: | ||||
| 			if sdb.config.IntermediateNodes { | ||||
| 				diffAccounts[common.BytesToHash(nodePath)] = accountWrapper{ | ||||
| 				diffAccounts[nodePathHash] = accountWrapper{ | ||||
| 					NodeType:  ty, | ||||
| 					Path:      nodePath, | ||||
| 					NodeValue: node, | ||||
|  | ||||
| @ -349,6 +349,13 @@ func TestBuilder(t *testing.T) { | ||||
| 				BlockNumber: block1.Number(), | ||||
| 				BlockHash:   block1.Hash(), | ||||
| 				CreatedAccounts: []statediff.AccountDiff{ | ||||
| 					{ | ||||
| 						Path:      []byte{'\x00'}, | ||||
| 						NodeType:  statediff.Leaf, | ||||
| 						LeafKey:   testhelpers.BankLeafKey, | ||||
| 						NodeValue: bankAccountAtBlock1LeafNode, | ||||
| 						Storage:   []statediff.StorageDiff{}, | ||||
| 					}, | ||||
| 					{ | ||||
| 						Path:      []byte{'\x05'}, | ||||
| 						NodeType:  statediff.Leaf, | ||||
| @ -364,16 +371,16 @@ func TestBuilder(t *testing.T) { | ||||
| 						Storage:   []statediff.StorageDiff{}, | ||||
| 					}, | ||||
| 				}, | ||||
| 				DeletedAccounts: emptyAccountMap, | ||||
| 				UpdatedAccounts: []statediff.AccountDiff{ | ||||
| 					{ | ||||
| 						Path:      []byte{'\x00'}, | ||||
| 				DeletedAccounts: []statediff.AccountDiff{ // This leaf appears to be deleted since it is turned into a branch node
 | ||||
| 					{ // It would instead show up in the UpdateAccounts as new branch node IF intermediate node diffing was turned on (as it is in the test below)
 | ||||
| 						Path:      []byte{}, | ||||
| 						NodeType:  statediff.Leaf, | ||||
| 						LeafKey:   testhelpers.BankLeafKey, | ||||
| 						NodeValue: bankAccountAtBlock1LeafNode, | ||||
| 						NodeValue: bankAccountAtBlock0LeafNode, | ||||
| 						Storage:   []statediff.StorageDiff{}, | ||||
| 					}, | ||||
| 				}, | ||||
| 				UpdatedAccounts: emptyAccountMap, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| @ -590,9 +597,10 @@ func TestBuilderWithIntermediateNodes(t *testing.T) { | ||||
| 				BlockHash:   block1.Hash(), | ||||
| 				CreatedAccounts: []statediff.AccountDiff{ | ||||
| 					{ | ||||
| 						Path:      []byte{}, | ||||
| 						NodeType:  statediff.Branch, | ||||
| 						NodeValue: block1BranchNode, | ||||
| 						Path:      []byte{'\x00'}, | ||||
| 						NodeType:  statediff.Leaf, | ||||
| 						LeafKey:   testhelpers.BankLeafKey, | ||||
| 						NodeValue: bankAccountAtBlock1LeafNode, | ||||
| 						Storage:   []statediff.StorageDiff{}, | ||||
| 					}, | ||||
| 					{ | ||||
| @ -613,10 +621,9 @@ func TestBuilderWithIntermediateNodes(t *testing.T) { | ||||
| 				DeletedAccounts: emptyAccountMap, | ||||
| 				UpdatedAccounts: []statediff.AccountDiff{ | ||||
| 					{ | ||||
| 						Path:      []byte{'\x00'}, | ||||
| 						NodeType:  statediff.Leaf, | ||||
| 						LeafKey:   testhelpers.BankLeafKey, | ||||
| 						NodeValue: bankAccountAtBlock1LeafNode, | ||||
| 						Path:      []byte{}, | ||||
| 						NodeType:  statediff.Branch, | ||||
| 						NodeValue: block1BranchNode, | ||||
| 						Storage:   []statediff.StorageDiff{}, | ||||
| 					}, | ||||
| 				}, | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user