Skip to content

Commit

Permalink
bump geth v1.13.14; rm hack; fix simulated backend; run make generate
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Mar 13, 2024
1 parent e8405d9 commit 86c54b6
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 80 deletions.
57 changes: 33 additions & 24 deletions core/chains/evm/client/simulated_backend_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,6 @@ func (c *SimulatedBackendClient) SubscribeFilterLogs(ctx context.Context, q ethe
return c.b.SubscribeFilterLogs(ctx, q, channel)
}

// currentBlockNumber returns index of *pending* block in simulated blockchain
func (c *SimulatedBackendClient) currentBlockNumber() *big.Int {
return c.b.Blockchain().CurrentBlock().Number
}

func (c *SimulatedBackendClient) finalizedBlockNumber() *big.Int {
return c.b.Blockchain().CurrentFinalBlock().Number
}

func (c *SimulatedBackendClient) TokenBalance(ctx context.Context, address common.Address, contractAddress common.Address) (balance *big.Int, err error) {
callData, err := balanceOfABI.Pack("balanceOf", address)
if err != nil {
Expand All @@ -139,7 +130,7 @@ func (c *SimulatedBackendClient) TokenBalance(ctx context.Context, address commo
}
b, err := c.b.CallContract(ctx, ethereum.CallMsg{
To: &contractAddress, Data: callData},
c.currentBlockNumber())
big.NewInt(int64(rpc.LatestBlockNumber)))
if err != nil {
return nil, fmt.Errorf("%w: while calling ERC20 balanceOf method on %s "+
"for balance of %s", err, contractAddress, address)
Expand All @@ -166,19 +157,37 @@ func (c *SimulatedBackendClient) TransactionByHash(ctx context.Context, txHash c
return
}

func (c *SimulatedBackendClient) blockNumber(number interface{}) (blockNumber *big.Int, err error) {
func (c *SimulatedBackendClient) blockNumber(ctx context.Context, number interface{}) (blockNumber *big.Int, err error) {
switch n := number.(type) {
case string:
switch n {
case "latest":
return c.currentBlockNumber(), nil
var n uint64
n, err = c.b.BlockNumber(ctx)
if err != nil {
return
}
blockNumber = new(big.Int)
blockNumber.SetUint64(n)
return
case "earliest":
return big.NewInt(0), nil
case "pending":
panic("pending block not supported by simulated backend client") // I don't understand the semantics of this.
// return big.NewInt(0).Add(c.currentBlockNumber(), big.NewInt(1)), nil
var h *types.Header
h, err = c.b.HeaderByNumber(ctx, new(big.Int).SetInt64(rpc.PendingBlockNumber.Int64()))
if err != nil {
return
}
blockNumber = h.Number
return
case "finalized":
return c.finalizedBlockNumber(), nil
var h *types.Header
h, err = c.b.HeaderByNumber(ctx, new(big.Int).SetInt64(rpc.FinalizedBlockNumber.Int64()))
if err != nil {
return
}
blockNumber = h.Number
return
default:
blockNumber, err := hexutil.DecodeBig(n)
if err != nil {
Expand All @@ -202,7 +211,7 @@ func (c *SimulatedBackendClient) blockNumber(number interface{}) (blockNumber *b
// HeadByNumber returns our own header type.
func (c *SimulatedBackendClient) HeadByNumber(ctx context.Context, n *big.Int) (*evmtypes.Head, error) {
if n == nil {
n = c.currentBlockNumber()
n = big.NewInt(int64(rpc.LatestBlockNumber))
}
header, err := c.b.HeaderByNumber(ctx, n)
if err != nil {
Expand Down Expand Up @@ -520,11 +529,11 @@ func (c *SimulatedBackendClient) IsL2() bool {
func (c *SimulatedBackendClient) fetchHeader(ctx context.Context, blockNumOrTag string) (*types.Header, error) {
switch blockNumOrTag {
case rpc.SafeBlockNumber.String():
return c.b.Blockchain().CurrentSafeBlock(), nil
return c.b.HeaderByNumber(ctx, big.NewInt(int64(rpc.SafeBlockNumber)))
case rpc.LatestBlockNumber.String():
return c.b.Blockchain().CurrentHeader(), nil
return c.b.HeaderByNumber(ctx, big.NewInt(int64(rpc.LatestBlockNumber)))
case rpc.FinalizedBlockNumber.String():
return c.b.Blockchain().CurrentFinalBlock(), nil
return c.b.HeaderByNumber(ctx, big.NewInt(int64(rpc.FinalizedBlockNumber)))
default:
blockNum, ok := new(big.Int).SetString(blockNumOrTag, 0)
if !ok {
Expand Down Expand Up @@ -611,7 +620,7 @@ func (c *SimulatedBackendClient) ethEstimateGas(ctx context.Context, result inte
return fmt.Errorf("SimulatedBackendClient expected first arg to be map[string]interface{} for eth_call, got: %T", args[0])
}

_, err := c.blockNumber(args[1])
_, err := c.blockNumber(ctx, args[1])
if err != nil {
return fmt.Errorf("SimulatedBackendClient expected second arg to be the string 'latest' or a *big.Int for eth_call, got: %T", args[1])
}
Expand Down Expand Up @@ -643,7 +652,7 @@ func (c *SimulatedBackendClient) ethCall(ctx context.Context, result interface{}
return fmt.Errorf("SimulatedBackendClient expected first arg to be map[string]interface{} for eth_call, got: %T", args[0])
}

if _, err := c.blockNumber(args[1]); err != nil {
if _, err := c.blockNumber(ctx, args[1]); err != nil {
return fmt.Errorf("SimulatedBackendClient expected second arg to be the string 'latest' or a *big.Int for eth_call, got: %T", args[1])
}

Expand Down Expand Up @@ -673,7 +682,7 @@ func (c *SimulatedBackendClient) ethGetHeaderByNumber(ctx context.Context, resul
return fmt.Errorf("SimulatedBackendClient expected 1 arg, got %d for eth_getHeaderByNumber", len(args))
}

blockNumber, err := c.blockNumber(args[0])
blockNumber, err := c.blockNumber(ctx, args[0])
if err != nil {
return fmt.Errorf("SimulatedBackendClient expected first arg to be a string for eth_getHeaderByNumber: %w", err)
}
Expand Down Expand Up @@ -709,14 +718,14 @@ func (c *SimulatedBackendClient) ethGetLogs(ctx context.Context, result interfac
}

if fromBlock, ok := params["fromBlock"]; ok {
from, err = c.blockNumber(fromBlock)
from, err = c.blockNumber(ctx, fromBlock)
if err != nil {
return fmt.Errorf("SimulatedBackendClient expected 'fromBlock' to be a string: %w", err)
}
}

if toBlock, ok := params["toBlock"]; ok {
to, err = c.blockNumber(toBlock)
to, err = c.blockNumber(ctx, toBlock)
if err != nil {
return fmt.Errorf("SimulatedBackendClient expected 'toBlock' to be a string: %w", err)
}
Expand Down
7 changes: 0 additions & 7 deletions core/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/json"
"fmt"
"io"
"log/slog"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -57,12 +56,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/plugins"
)

func init() {
// hack to undo geth's disruption of the std default logger
// remove with geth v1.13.10
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, nil)))
}

var (
initGlobalsOnce sync.Once
prometheus *ginprom.Prometheus
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GETH_VERSION: 1.13.8
GETH_VERSION: 1.13.11
functions: ../../../contracts/solc/v0.8.19/functions/v1_X/FunctionsRequest.abi ../../../contracts/solc/v0.8.19/functions/v1_X/FunctionsRequest.bin 3c972870b0afeb6d73a29ebb182f24956a2cebb127b21c4f867d1ecf19a762db
functions_allow_list: ../../../contracts/solc/v0.8.19/functions/v1_X/TermsOfServiceAllowList.abi ../../../contracts/solc/v0.8.19/functions/v1_X/TermsOfServiceAllowList.bin 0c2156289e11f884ca6e92bf851192d3917c9094a0a301bcefa61266678d0e57
functions_billing_registry_events_mock: ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsBillingRegistryEventsMock.abi ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsBillingRegistryEventsMock.bin 50deeb883bd9c3729702be335c0388f9d8553bab4be5e26ecacac496a89e2b77
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GETH_VERSION: 1.13.8
GETH_VERSION: 1.13.11
aggregator_v2v3_interface: ../../contracts/solc/v0.8.6/AggregatorV2V3Interface/AggregatorV2V3Interface.abi ../../contracts/solc/v0.8.6/AggregatorV2V3Interface/AggregatorV2V3Interface.bin 95e8814b408bb05bf21742ef580d98698b7db6a9bac6a35c3de12b23aec4ee28
aggregator_v3_interface: ../../contracts/solc/v0.8.6/AggregatorV2V3Interface/AggregatorV3Interface.abi ../../contracts/solc/v0.8.6/AggregatorV2V3Interface/AggregatorV3Interface.bin 351b55d3b0f04af67db6dfb5c92f1c64479400ca1fec77afc20bc0ce65cb49ab
arbitrum_module: ../../contracts/solc/v0.8.19/ArbitrumModule/ArbitrumModule.abi ../../contracts/solc/v0.8.19/ArbitrumModule/ArbitrumModule.bin b76cf77e3e8200c5f292e93af3f620f68f207f83634aacaaee43d682701dfea3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<<<<<<< HEAD
GETH_VERSION: 1.13.8
channel_config_store: ../../../contracts/solc/v0.8.19/ChannelConfigStore/ChannelConfigStore.abi ../../../contracts/solc/v0.8.19/ChannelConfigStore/ChannelConfigStore.bin c90e29d9f1a885098982b6175e0447416431b28c605273c807694ac7141e9167
=======
GETH_VERSION: 1.13.11
channel_config_store: ../../../contracts/solc/v0.8.19/ChannelConfigStore/ChannelConfigStore.abi ../../../contracts/solc/v0.8.19/ChannelConfigStore/ChannelConfigStore.bin 4ae3e6ca866fdf48850d67c0c7a4bdaf4905c81a4e3ce5efb9ef9613a55d8454
>>>>>>> cca11613c3 (run make generate)
channel_config_verifier_proxy: ../../../contracts/solc/v0.8.19/ChannelVerifierProxy/ChannelVerifierProxy.abi ../../../contracts/solc/v0.8.19/ChannelVerifierProxy/ChannelVerifierProxy.bin 655658e5f61dfadfe3268de04f948b7e690ad03ca45676e645d6cd6018154661
channel_verifier: ../../../contracts/solc/v0.8.19/ChannelVerifier/ChannelVerifier.abi ../../../contracts/solc/v0.8.19/ChannelVerifier/ChannelVerifier.bin e6020553bd8e3e6b250fcaffe7efd22aea955c8c1a0eb05d282fdeb0ab6550b7
errored_verifier: ../../../contracts/solc/v0.8.19/ErroredVerifier/ErroredVerifier.abi ../../../contracts/solc/v0.8.19/ErroredVerifier/ErroredVerifier.bin a3e5a77262e13ee30fe8d35551b32a3452d71929e43fd780bbfefeaf4aa62e43
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GETH_VERSION: 1.13.8
GETH_VERSION: 1.13.11
burn_mint_erc677: ../../../contracts/solc/v0.8.19/BurnMintERC677/BurnMintERC677.abi ../../../contracts/solc/v0.8.19/BurnMintERC677/BurnMintERC677.bin 405c9016171e614b17e10588653ef8d33dcea21dd569c3fddc596a46fcff68a3
erc20: ../../../contracts/solc/v0.8.19/ERC20/ERC20.abi ../../../contracts/solc/v0.8.19/ERC20/ERC20.bin 5b1a93d9b24f250e49a730c96335a8113c3f7010365cba578f313b483001d4fc
link_token: ../../../contracts/solc/v0.8.19/LinkToken/LinkToken.abi ../../../contracts/solc/v0.8.19/LinkToken/LinkToken.bin c0ef9b507103aae541ebc31d87d051c2764ba9d843076b30ec505d37cdfffaba
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GETH_VERSION: 1.13.8
GETH_VERSION: 1.13.11
entry_point: ../../../contracts/solc/v0.8.15/EntryPoint/EntryPoint.abi ../../../contracts/solc/v0.8.15/EntryPoint/EntryPoint.bin 2cb4bb2ba3efa8df3dfb0a57eb3727d17b68fe202682024fa7cfb4faf026833e
greeter: ../../../contracts/solc/v0.8.15/Greeter.abi ../../../contracts/solc/v0.8.15/Greeter.bin 653dcba5c33a46292073939ce1e639372cf521c0ec2814d4c9f20c72f796f18c
greeter_wrapper: ../../../contracts/solc/v0.8.15/Greeter/Greeter.abi ../../../contracts/solc/v0.8.15/Greeter/Greeter.bin 653dcba5c33a46292073939ce1e639372cf521c0ec2814d4c9f20c72f796f18c
Expand Down
8 changes: 6 additions & 2 deletions core/internal/cltest/simulated_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ func NewApplicationWithConfigV2OnSimulatedBlockchain(
backend *backends.SimulatedBackend,
flagsAndDeps ...interface{},
) *TestApplication {
if bid := backend.Blockchain().Config().ChainID; bid.Cmp(testutils.SimulatedChainID) != 0 {
bid, err := backend.ChainID(testutils.Context(t))
require.NoError(t, err)
if bid.Cmp(testutils.SimulatedChainID) != 0 {
t.Fatalf("expected backend chain ID to be %s but it was %s", testutils.SimulatedChainID.String(), bid.String())
}

Expand All @@ -56,7 +58,9 @@ func NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(
backend *backends.SimulatedBackend,
flagsAndDeps ...interface{},
) *TestApplication {
if bid := backend.Blockchain().Config().ChainID; bid.Cmp(testutils.SimulatedChainID) != 0 {
bid, err := backend.ChainID(testutils.Context(t))
require.NoError(t, err)
if bid.Cmp(testutils.SimulatedChainID) != 0 {
t.Fatalf("expected backend chain ID to be %s but it was %s", testutils.SimulatedChainID.String(), bid.String())
}

Expand Down
12 changes: 10 additions & 2 deletions core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ replace github.com/smartcontractkit/chainlink/v2 => ../../
require (
github.com/docker/docker v24.0.7+incompatible
github.com/docker/go-connections v0.4.0
github.com/ethereum/go-ethereum v1.13.8
github.com/ethereum/go-ethereum v1.13.14
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.4.0
github.com/jmoiron/sqlx v1.3.5
Expand Down Expand Up @@ -109,6 +109,7 @@ require (
github.com/esote/minmaxheap v1.0.0 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fjl/memsize v0.0.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
Expand All @@ -133,7 +134,7 @@ require (
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.5 // indirect
Expand All @@ -143,6 +144,7 @@ require (
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand Down Expand Up @@ -170,6 +172,7 @@ require (
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/consul/sdk v0.14.1 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/hashicorp/go-envparse v0.1.0 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
Expand All @@ -178,6 +181,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
Expand Down Expand Up @@ -214,6 +218,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -240,6 +245,7 @@ require (
github.com/rivo/uniseg v0.4.4 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/cors v1.8.3 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/scylladb/go-reflectx v1.0.1 // indirect
Expand Down Expand Up @@ -280,8 +286,10 @@ require (
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/ulule/limiter/v3 v3.11.2 // indirect
github.com/unrolled/secure v1.13.0 // indirect
github.com/urfave/cli/v2 v2.25.7 // indirect
github.com/valyala/fastjson v1.4.1 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/ledger-go v0.14.1 // indirect
Expand Down
Loading

0 comments on commit 86c54b6

Please sign in to comment.