Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

graphql: return correct logs for tx (ethereum#25612) #3

Closed
wants to merge 38 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d0dc349
graphql: return correct logs for tx (#25612)
s1na Aug 31, 2022
3b41be6
graphql: fixes missing tx logs (#25745)
s1na Sep 13, 2022
972007a
Release Geth v1.10.24
karalabe Sep 14, 2022
8f61fc8
params: set TerminalTotalDifficultyPassed to true (#25769)
MariusVanDerWijden Sep 15, 2022
69568c5
params: release Geth v1.10.25
karalabe Sep 15, 2022
85e469f
eth/protocols/snap: fix problems due to idle-but-busy peers (#25651)
holiman Aug 31, 2022
937ea49
eth/protocols/snap: throttle trie heal requests when peers DoS us (#2…
karalabe Sep 9, 2022
a32e69a
trie: check childrens' existence concurrently for snap heal (#25694)
karalabe Sep 6, 2022
99bbb33
eth: fix a rare datarace on CHT challenge reply / shutdown (#25831)
karalabe Sep 20, 2022
27600a5
eth/filters: change filter block to be by-ref (#26054)
holiman Oct 27, 2022
211dbb7
rpc: handle wrong HTTP batch response length (#26064)
jmank88 Nov 2, 2022
e5eb32a
params: release geth v1.10.26 stable
fjl Nov 3, 2022
37748e5
stateful
Jan 16, 2023
cdf5821
use PrecompileExecutor
calbera Jan 18, 2023
2def4f0
use host terminology
calbera Jan 18, 2023
b7ecb9e
return precompiledContract and bool
calbera Jan 18, 2023
d1c5ff3
use ctx in Run instead of statedb
calbera Jan 18, 2023
981b007
Merge pull request #4 from berachain/new-precompile
Jan 19, 2023
12579d8
change to ph
Jan 19, 2023
f1ef333
bing bong
Jan 19, 2023
e604f74
rename to runner
calbera Jan 23, 2023
6dfd7b1
rename constructor
calbera Jan 23, 2023
6b58c1d
new precompile function types
calbera Jan 24, 2023
8f77e9a
precompile controller
calbera Jan 24, 2023
eca0bbb
make PrecompileController public
calbera Jan 25, 2023
cdf3a39
ctx setter
calbera Jan 25, 2023
dc459cd
add statedb in contract.Run
calbera Jan 25, 2023
60266f5
use Prepare on controller
calbera Jan 25, 2023
952aea2
prepare for state transition
calbera Jan 25, 2023
ca260e9
contract has registry key
calbera Feb 2, 2023
2ad2464
has and get
calbera Feb 2, 2023
d6fbbb7
controller > manager
calbera Feb 2, 2023
e4d555f
with statedb
calbera Feb 3, 2023
fe0db77
with ctx
calbera Feb 3, 2023
0d5324b
simple precompile manager
calbera Feb 6, 2023
561d4bc
allow setting block context to evm
calbera Feb 10, 2023
62f7754
remove unneded evm funcs
calbera Feb 10, 2023
6096143
simplify precompile manager
calbera Feb 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
contract has registry key
calbera committed Feb 2, 2023

Verified

This commit was signed with the committer’s verified signature.
Eric-Arellano Eric Arellano
commit ca260e974759bb8d6a618f45d79bedd48b00d959
85 changes: 85 additions & 0 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ import (
// requires a deterministic gas count based on the input size of the Run method of the
// contract.
type PrecompiledContract interface {
RegistryKey() common.Address
RequiredGas(input []byte) uint64 // RequiredPrice calculates the contract gas use
Run(ctx context.Context, statedb StateDB, input []byte, caller common.Address, value *big.Int, readonly bool) ([]byte, error) // Run runs the precompiled contract
}
@@ -144,6 +145,10 @@ func ActivePrecompiles(rules params.Rules) []common.Address {
// ECRECOVER implemented as a native contract.
type ecrecover struct{}

func (c *ecrecover) RegistryKey() common.Address {
return common.BytesToAddress([]byte{1})
}

func (c *ecrecover) RequiredGas(input []byte) uint64 {
return params.EcrecoverGas
}
@@ -182,6 +187,10 @@ func (c *ecrecover) Run(ctx context.Context, statedb StateDB, input []byte, call
// SHA256 implemented as a native contract.
type sha256hash struct{}

func (c *sha256hash) RegistryKey() common.Address {
return common.BytesToAddress([]byte{2})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
//
// This method does not require any overflow checking as the input size gas costs
@@ -197,6 +206,10 @@ func (c *sha256hash) Run(ctx context.Context, statedb StateDB, input []byte, cal
// RIPEMD160 implemented as a native contract.
type ripemd160hash struct{}

func (c *ripemd160hash) RegistryKey() common.Address {
return common.BytesToAddress([]byte{3})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
//
// This method does not require any overflow checking as the input size gas costs
@@ -213,6 +226,10 @@ func (c *ripemd160hash) Run(ctx context.Context, statedb StateDB, input []byte,
// data copy implemented as a native contract.
type dataCopy struct{}

func (c *dataCopy) RegistryKey() common.Address {
return common.BytesToAddress([]byte{4})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
//
// This method does not require any overflow checking as the input size gas costs
@@ -229,6 +246,10 @@ type bigModExp struct {
eip2565 bool
}

func (c *bigModExp) RegistryKey() common.Address {
return common.BytesToAddress([]byte{5})
}

var (
big0 = big.NewInt(0)
big1 = big.NewInt(1)
@@ -415,6 +436,10 @@ func runBn256Add(input []byte) ([]byte, error) {
// Istanbul consensus rules.
type bn256AddIstanbul struct{}

func (c *bn256AddIstanbul) RegistryKey() common.Address {
return common.BytesToAddress([]byte{6})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bn256AddIstanbul) RequiredGas(input []byte) uint64 {
return params.Bn256AddGasIstanbul
@@ -428,6 +453,10 @@ func (c *bn256AddIstanbul) Run(ctx context.Context, statedb StateDB, input []byt
// conforming to Byzantium consensus rules.
type bn256AddByzantium struct{}

func (c *bn256AddByzantium) RegistryKey() common.Address {
return common.BytesToAddress([]byte{6})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bn256AddByzantium) RequiredGas(input []byte) uint64 {
return params.Bn256AddGasByzantium
@@ -453,6 +482,10 @@ func runBn256ScalarMul(input []byte) ([]byte, error) {
// multiplication conforming to Istanbul consensus rules.
type bn256ScalarMulIstanbul struct{}

func (c *bn256ScalarMulIstanbul) RegistryKey() common.Address {
return common.BytesToAddress([]byte{7})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bn256ScalarMulIstanbul) RequiredGas(input []byte) uint64 {
return params.Bn256ScalarMulGasIstanbul
@@ -466,6 +499,10 @@ func (c *bn256ScalarMulIstanbul) Run(ctx context.Context, statedb StateDB, input
// multiplication conforming to Byzantium consensus rules.
type bn256ScalarMulByzantium struct{}

func (c *bn256ScalarMulByzantium) RegistryKey() common.Address {
return common.BytesToAddress([]byte{7})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bn256ScalarMulByzantium) RequiredGas(input []byte) uint64 {
return params.Bn256ScalarMulGasByzantium
@@ -521,6 +558,10 @@ func runBn256Pairing(input []byte) ([]byte, error) {
// conforming to Istanbul consensus rules.
type bn256PairingIstanbul struct{}

func (c *bn256PairingIstanbul) RegistryKey() common.Address {
return common.BytesToAddress([]byte{8})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bn256PairingIstanbul) RequiredGas(input []byte) uint64 {
return params.Bn256PairingBaseGasIstanbul + uint64(len(input)/192)*params.Bn256PairingPerPointGasIstanbul
@@ -534,6 +575,10 @@ func (c *bn256PairingIstanbul) Run(ctx context.Context, statedb StateDB, input [
// conforming to Byzantium consensus rules.
type bn256PairingByzantium struct{}

func (c *bn256PairingByzantium) RegistryKey() common.Address {
return common.BytesToAddress([]byte{8})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bn256PairingByzantium) RequiredGas(input []byte) uint64 {
return params.Bn256PairingBaseGasByzantium + uint64(len(input)/192)*params.Bn256PairingPerPointGasByzantium
@@ -545,6 +590,10 @@ func (c *bn256PairingByzantium) Run(ctx context.Context, statedb StateDB, input

type blake2F struct{}

func (c *blake2F) RegistryKey() common.Address {
return common.BytesToAddress([]byte{9})
}

func (c *blake2F) RequiredGas(input []byte) uint64 {
// If the input is malformed, we can't calculate the gas, return 0 and let the
// actual call choke and fault.
@@ -614,6 +663,10 @@ var (
// bls12381G1Add implements EIP-2537 G1Add precompile.
type bls12381G1Add struct{}

func (c *bls12381G1Add) RegistryKey() common.Address {
return common.BytesToAddress([]byte{10})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bls12381G1Add) RequiredGas(input []byte) uint64 {
return params.Bls12381G1AddGas
@@ -652,6 +705,10 @@ func (c *bls12381G1Add) Run(ctx context.Context, statedb StateDB, input []byte,
// bls12381G1Mul implements EIP-2537 G1Mul precompile.
type bls12381G1Mul struct{}

func (c *bls12381G1Mul) RegistryKey() common.Address {
return common.BytesToAddress([]byte{11})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bls12381G1Mul) RequiredGas(input []byte) uint64 {
return params.Bls12381G1MulGas
@@ -688,6 +745,10 @@ func (c *bls12381G1Mul) Run(ctx context.Context, statedb StateDB, input []byte,
// bls12381G1MultiExp implements EIP-2537 G1MultiExp precompile.
type bls12381G1MultiExp struct{}

func (c *bls12381G1MultiExp) RegistryKey() common.Address {
return common.BytesToAddress([]byte{12})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bls12381G1MultiExp) RequiredGas(input []byte) uint64 {
// Calculate G1 point, scalar value pair length
@@ -745,6 +806,10 @@ func (c *bls12381G1MultiExp) Run(ctx context.Context, statedb StateDB, input []b
// bls12381G2Add implements EIP-2537 G2Add precompile.
type bls12381G2Add struct{}

func (c *bls12381G2Add) RegistryKey() common.Address {
return common.BytesToAddress([]byte{13})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bls12381G2Add) RequiredGas(input []byte) uint64 {
return params.Bls12381G2AddGas
@@ -783,6 +848,10 @@ func (c *bls12381G2Add) Run(ctx context.Context, statedb StateDB, input []byte,
// bls12381G2Mul implements EIP-2537 G2Mul precompile.
type bls12381G2Mul struct{}

func (c *bls12381G2Mul) RegistryKey() common.Address {
return common.BytesToAddress([]byte{14})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bls12381G2Mul) RequiredGas(input []byte) uint64 {
return params.Bls12381G2MulGas
@@ -819,6 +888,10 @@ func (c *bls12381G2Mul) Run(ctx context.Context, statedb StateDB, input []byte,
// bls12381G2MultiExp implements EIP-2537 G2MultiExp precompile.
type bls12381G2MultiExp struct{}

func (c *bls12381G2MultiExp) RegistryKey() common.Address {
return common.BytesToAddress([]byte{15})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bls12381G2MultiExp) RequiredGas(input []byte) uint64 {
// Calculate G2 point, scalar value pair length
@@ -876,6 +949,10 @@ func (c *bls12381G2MultiExp) Run(ctx context.Context, statedb StateDB, input []b
// bls12381Pairing implements EIP-2537 Pairing precompile.
type bls12381Pairing struct{}

func (c *bls12381Pairing) RegistryKey() common.Address {
return common.BytesToAddress([]byte{16})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bls12381Pairing) RequiredGas(input []byte) uint64 {
return params.Bls12381PairingBaseGas + uint64(len(input)/384)*params.Bls12381PairingPerPairGas
@@ -955,6 +1032,10 @@ func decodeBLS12381FieldElement(in []byte) ([]byte, error) {
// bls12381MapG1 implements EIP-2537 MapG1 precompile.
type bls12381MapG1 struct{}

func (c *bls12381MapG1) RegistryKey() common.Address {
return common.BytesToAddress([]byte{17})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bls12381MapG1) RequiredGas(input []byte) uint64 {
return params.Bls12381MapG1Gas
@@ -990,6 +1071,10 @@ func (c *bls12381MapG1) Run(ctx context.Context, statedb StateDB, input []byte,
// bls12381MapG2 implements EIP-2537 MapG2 precompile.
type bls12381MapG2 struct{}

func (c *bls12381MapG2) RegistryKey() common.Address {
return common.BytesToAddress([]byte{18})
}

// RequiredGas returns the gas required to execute the pre-compiled contract.
func (c *bls12381MapG2) RequiredGas(input []byte) uint64 {
return params.Bls12381MapG2Gas