go-ethereum/crypto/codehash/codehash.go
Péter Garamvölgyi 81e7775aa8
feat: dual code hash (#188)
* add KeccakCodeHash and CodeSize to StateAccount

* update StateAccount marshalling logic

* change emptyCodeHash to poseidon(nil)

* purge StateAccount.hash

* fix/disable failing tests

* change keccak and poseidon hash order in StateAccount

* fix lint

* update l2trace account wrapper

* update eth_getProof response type

* fix eth_getProof response type

* goimports

* update the codehash computation

* update the codehash test cases

* go mod tidy

* fix tests

* use keccak instead of poseidon

* update trace codehash field name

* upgrade zktrie to 4.2

* trigger ci

* update state account marshalling according to spec

* improve generatorStats estimation

* add comment

* upgrade zktrie to 4.3

* go mod tidy

* misc fixes

* fix TestDump

* fix snap sync tests

* handle err in the codehash

* fix tests in snapshot/generate_test.go

* remove prevhash from state journal

* add state_account_marshalling_test.go

* goimports

* add more tests

---------

Co-authored-by: Ho Vei <noelwei@gmail.com>
Co-authored-by: Haichen Shen <shenhaichen@gmail.com>
2023-02-08 16:12:41 -08:00

23 lines
539 B
Go

package codehash
import (
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/scroll-tech/go-ethereum/crypto/poseidon"
)
var EmptyPoseidonCodeHash common.Hash
var EmptyKeccakCodeHash common.Hash
func PoseidonCodeHash(code []byte) (h common.Hash) {
return poseidon.CodeHash(code)
}
func KeccakCodeHash(code []byte) (h common.Hash) {
return crypto.Keccak256Hash(code)
}
func init() {
EmptyPoseidonCodeHash = poseidon.CodeHash(nil)
EmptyKeccakCodeHash = crypto.Keccak256Hash(nil)
}