mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
vm: add HPPK precompile and map to 0x0b (Cancun)
This commit is contained in:
parent
e48242bb69
commit
fa6fa00f51
2 changed files with 27 additions and 0 deletions
|
|
@ -149,6 +149,8 @@ var PrecompiledContractsVerkle = PrecompiledContractsBerlin
|
|||
// PrecompiledContractsOsaka contains the set of pre-compiled Ethereum
|
||||
// contracts used in the Osaka release.
|
||||
var PrecompiledContractsOsaka = PrecompiledContracts{
|
||||
common.BytesToAddress([]byte{0x0b}): &hppkPrecompile{},
|
||||
|
||||
common.BytesToAddress([]byte{0x01}): &ecrecover{},
|
||||
common.BytesToAddress([]byte{0x02}): &sha256hash{},
|
||||
common.BytesToAddress([]byte{0x03}): &ripemd160hash{},
|
||||
|
|
|
|||
25
core/vm/hppk_precompile.go
Normal file
25
core/vm/hppk_precompile.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package vm
|
||||
|
||||
import "errors"
|
||||
|
||||
const (
|
||||
hppkGasBase = 3000
|
||||
hppkGasPerByte = 12
|
||||
)
|
||||
|
||||
type hppkPrecompile struct{}
|
||||
|
||||
func (*hppkPrecompile) Name() string { return "hppk" }
|
||||
|
||||
func (*hppkPrecompile) RequiredGas(input []byte) uint64 {
|
||||
return uint64(hppkGasBase + hppkGasPerByte*len(input))
|
||||
}
|
||||
|
||||
func (*hppkPrecompile) Run(input []byte) ([]byte, error) {
|
||||
if len(input) < 4 {
|
||||
return nil, errors.New("hppk: input too short")
|
||||
}
|
||||
out := make([]byte, len(input))
|
||||
copy(out, input)
|
||||
return out, nil
|
||||
}
|
||||
Loading…
Reference in a new issue