vm

package
v0.0.0-...-3060726 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 21 Imported by: 0

README

Geth recipee for falcon Minimal fork

This directory contains the minimal sources to have a forked geth including a Falcon Precompile.

  • Compile ETHFALCON/falcon go bindings
make go
  • Clone geth repository
git clone https://github.com/ethereum/go-ethereum.git
  • Replace contracts.go by the forked version of this directory
mv contracts.go $YOURGETH/core/vm/contracts.go
  • Provide falcon go module to geth
go clean -modcache
go get github.com/ZKNoxHQ/ETHFALCON/falcon@latest
go mod tidy
  • Compile geth
make geth
  • Run geth in dev mode:
./build/bin/geth --http --http.api eth,net,web3 --http.addr 127.0.0.1 --http.port 8547 --dev
  • Run example with cast:

    • generate example
go run test_falconmodule.go

copy paste the result, then call the abi-encode on it.

cast abi-encode "falconvrfy(bytes,bytes,bytes)" $SIG $MSG $PUB
* run example
cast call 0x0000000000000000000000000000000000000013 "$(cast abi-encode "falconvrfy(bytes,bytes,bytes)" "" --rpc-url http://localhost:8547)" --rpc-url http://localhost:8547 

Where INPUT is a valid input for the falcon verification procedure, 0x13 is the precompile value (subject to change with next forks). It can be generated using the test/test_falconmodule.go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PrecompiledAddressesPrague    []common.Address
	PrecompiledAddressesCancun    []common.Address
	PrecompiledAddressesBerlin    []common.Address
	PrecompiledAddressesIstanbul  []common.Address
	PrecompiledAddressesByzantium []common.Address
	PrecompiledAddressesHomestead []common.Address
)
View Source
var PrecompiledContractsBLS = PrecompiledContractsPrague
View Source
var PrecompiledContractsBerlin = PrecompiledContracts{
	common.BytesToAddress([]byte{0x1}): &ecrecover{},
	common.BytesToAddress([]byte{0x2}): &sha256hash{},
	common.BytesToAddress([]byte{0x3}): &ripemd160hash{},
	common.BytesToAddress([]byte{0x4}): &dataCopy{},
	common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: true},
	common.BytesToAddress([]byte{0x6}): &bn256AddIstanbul{},
	common.BytesToAddress([]byte{0x7}): &bn256ScalarMulIstanbul{},
	common.BytesToAddress([]byte{0x8}): &bn256PairingIstanbul{},
	common.BytesToAddress([]byte{0x9}): &blake2F{},
}

PrecompiledContractsBerlin contains the default set of pre-compiled Ethereum contracts used in the Berlin release.

View Source
var PrecompiledContractsByzantium = PrecompiledContracts{
	common.BytesToAddress([]byte{0x1}): &ecrecover{},
	common.BytesToAddress([]byte{0x2}): &sha256hash{},
	common.BytesToAddress([]byte{0x3}): &ripemd160hash{},
	common.BytesToAddress([]byte{0x4}): &dataCopy{},
	common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: false},
	common.BytesToAddress([]byte{0x6}): &bn256AddByzantium{},
	common.BytesToAddress([]byte{0x7}): &bn256ScalarMulByzantium{},
	common.BytesToAddress([]byte{0x8}): &bn256PairingByzantium{},
}

PrecompiledContractsByzantium contains the default set of pre-compiled Ethereum contracts used in the Byzantium release.

View Source
var PrecompiledContractsCancun = PrecompiledContracts{
	common.BytesToAddress([]byte{0x1}): &ecrecover{},
	common.BytesToAddress([]byte{0x2}): &sha256hash{},
	common.BytesToAddress([]byte{0x3}): &ripemd160hash{},
	common.BytesToAddress([]byte{0x4}): &dataCopy{},
	common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: true},
	common.BytesToAddress([]byte{0x6}): &bn256AddIstanbul{},
	common.BytesToAddress([]byte{0x7}): &bn256ScalarMulIstanbul{},
	common.BytesToAddress([]byte{0x8}): &bn256PairingIstanbul{},
	common.BytesToAddress([]byte{0x9}): &blake2F{},
	common.BytesToAddress([]byte{0xa}): &kzgPointEvaluation{},
}

PrecompiledContractsCancun contains the default set of pre-compiled Ethereum contracts used in the Cancun release.

View Source
var PrecompiledContractsHomestead = PrecompiledContracts{
	common.BytesToAddress([]byte{0x1}): &ecrecover{},
	common.BytesToAddress([]byte{0x2}): &sha256hash{},
	common.BytesToAddress([]byte{0x3}): &ripemd160hash{},
	common.BytesToAddress([]byte{0x4}): &dataCopy{},
}

PrecompiledContractsHomestead contains the default set of pre-compiled Ethereum contracts used in the Frontier and Homestead releases.

View Source
var PrecompiledContractsIstanbul = PrecompiledContracts{
	common.BytesToAddress([]byte{0x1}): &ecrecover{},
	common.BytesToAddress([]byte{0x2}): &sha256hash{},
	common.BytesToAddress([]byte{0x3}): &ripemd160hash{},
	common.BytesToAddress([]byte{0x4}): &dataCopy{},
	common.BytesToAddress([]byte{0x5}): &bigModExp{eip2565: false},
	common.BytesToAddress([]byte{0x6}): &bn256AddIstanbul{},
	common.BytesToAddress([]byte{0x7}): &bn256ScalarMulIstanbul{},
	common.BytesToAddress([]byte{0x8}): &bn256PairingIstanbul{},
	common.BytesToAddress([]byte{0x9}): &blake2F{},
}

PrecompiledContractsIstanbul contains the default set of pre-compiled Ethereum contracts used in the Istanbul release.

View Source
var PrecompiledContractsPrague = PrecompiledContracts{
	common.BytesToAddress([]byte{0x01}): &ecrecover{},
	common.BytesToAddress([]byte{0x02}): &sha256hash{},
	common.BytesToAddress([]byte{0x03}): &ripemd160hash{},
	common.BytesToAddress([]byte{0x04}): &dataCopy{},
	common.BytesToAddress([]byte{0x05}): &bigModExp{eip2565: true},
	common.BytesToAddress([]byte{0x06}): &bn256AddIstanbul{},
	common.BytesToAddress([]byte{0x07}): &bn256ScalarMulIstanbul{},
	common.BytesToAddress([]byte{0x08}): &bn256PairingIstanbul{},
	common.BytesToAddress([]byte{0x09}): &blake2F{},
	common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{},
	common.BytesToAddress([]byte{0x0b}): &bls12381G1Add{},
	common.BytesToAddress([]byte{0x0c}): &bls12381G1MultiExp{},
	common.BytesToAddress([]byte{0x0d}): &bls12381G2Add{},
	common.BytesToAddress([]byte{0x0e}): &bls12381G2MultiExp{},
	common.BytesToAddress([]byte{0x0f}): &bls12381Pairing{},
	common.BytesToAddress([]byte{0x10}): &bls12381MapG1{},
	common.BytesToAddress([]byte{0x11}): &bls12381MapG2{},
	common.BytesToAddress([]byte{0x13}): &falconvrfy{},
}

PrecompiledContractsPrague contains the set of pre-compiled Ethereum contracts used in the Prague release.

View Source
var PrecompiledContractsVerkle = PrecompiledContractsPrague

Functions

func ActivePrecompiles

func ActivePrecompiles(rules params.Rules) []common.Address

ActivePrecompiles returns the precompile addresses enabled with the current configuration.

func RunPrecompiledContract

func RunPrecompiledContract(p PrecompiledContract, input []byte, suppliedGas uint64, logger *tracing.Hooks) (ret []byte, remainingGas uint64, err error)

RunPrecompiledContract runs and evaluates the output of a precompiled contract. It returns - the returned bytes, - the _remaining_ gas, - any error that occurred

Types

type PrecompiledContract

type PrecompiledContract interface {
	RequiredGas(input []byte) uint64  // RequiredPrice calculates the contract gas use
	Run(input []byte) ([]byte, error) // Run runs the precompiled contract
}

PrecompiledContract is the basic interface for native Go contracts. The implementation requires a deterministic gas count based on the input size of the Run method of the contract.

type PrecompiledContracts

type PrecompiledContracts map[common.Address]PrecompiledContract

PrecompiledContracts contains the precompiled contracts supported at the given fork.

func ActivePrecompiledContracts

func ActivePrecompiledContracts(rules params.Rules) PrecompiledContracts

ActivePrecompiledContracts returns a copy of precompiled contracts enabled with the current configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL