@@ -692,7 +692,6 @@ func (s *PublicBlockChainAPI) GetProof(ctx context.Context, address common.Addre
692692 storageHash = types .EmptyRootHash
693693 }
694694 keccakCodeHash := state .GetKeccakCodeHash (address )
695- poseidonCodeHash := state .GetPoseidonCodeHash (address )
696695 storageProof := make ([]StorageResult , len (storageKeys ))
697696
698697 // if we have a storageTrie, (which means the account exists), we can update the storagehash
@@ -701,7 +700,6 @@ func (s *PublicBlockChainAPI) GetProof(ctx context.Context, address common.Addre
701700 } else {
702701 // no storageTrie means the account does not exist, so the codeHash is the hash of an empty bytearray.
703702 keccakCodeHash = codehash .EmptyKeccakCodeHash
704- poseidonCodeHash = codehash .EmptyPoseidonCodeHash
705703 }
706704
707705 // create the proof for the storageKeys
@@ -723,17 +721,26 @@ func (s *PublicBlockChainAPI) GetProof(ctx context.Context, address common.Addre
723721 return nil , proofErr
724722 }
725723
726- return & AccountResult {
727- Address : address ,
728- AccountProof : toHexSlice (accountProof ),
729- Balance : (* hexutil .Big )(state .GetBalance (address )),
730- KeccakCodeHash : keccakCodeHash ,
731- PoseidonCodeHash : poseidonCodeHash ,
732- CodeSize : hexutil .Uint64 (state .GetCodeSize (address )),
733- Nonce : hexutil .Uint64 (state .GetNonce (address )),
734- StorageHash : storageHash ,
735- StorageProof : storageProof ,
736- }, state .Error ()
724+ result := & AccountResult {
725+ Address : address ,
726+ AccountProof : toHexSlice (accountProof ),
727+ Balance : (* hexutil .Big )(state .GetBalance (address )),
728+ KeccakCodeHash : keccakCodeHash ,
729+ CodeSize : hexutil .Uint64 (state .GetCodeSize (address )),
730+ Nonce : hexutil .Uint64 (state .GetNonce (address )),
731+ StorageHash : storageHash ,
732+ StorageProof : storageProof ,
733+ }
734+
735+ if state .IsZktrie () {
736+ if storageTrie != nil {
737+ result .PoseidonCodeHash = state .GetPoseidonCodeHash (address )
738+ } else {
739+ result .PoseidonCodeHash = codehash .EmptyPoseidonCodeHash
740+ }
741+ }
742+
743+ return result , state .Error ()
737744}
738745
739746// GetHeaderByNumber returns the requested canonical block header.
0 commit comments