Commit 75816d14 authored by Roberto Bayardo's avatar Roberto Bayardo Committed by GitHub

update geth dependency to version w/ v1.13.11 upstream commits (#10041)

* update geth dependency to version with upstream updates to v1.13.11

* fix op-program tests

* update op-geth dep to tagged commit
parent 8f516faf
......@@ -78,7 +78,7 @@ func NewEVMEnv(contracts *Contracts, addrs *Addresses) (*vm.EVM, *state.StateDB)
copy(mipsCtorArgs[12:], addrs.Oracle[:])
mipsDeploy := append(hexutil.MustDecode(bindings.MIPSMetaData.Bin), mipsCtorArgs[:]...)
startingGas := uint64(30_000_000)
_, deployedMipsAddr, leftOverGas, err := env.Create(vm.AccountRef(addrs.Sender), mipsDeploy, startingGas, big.NewInt(0))
_, deployedMipsAddr, leftOverGas, err := env.Create(vm.AccountRef(addrs.Sender), mipsDeploy, startingGas, common.U2560)
if err != nil {
panic(fmt.Errorf("failed to deploy MIPS contract: %w. took %d gas", err, startingGas-leftOverGas))
}
......
......@@ -72,12 +72,12 @@ func (m *MIPSEVM) Step(t *testing.T, stepWitness *StepWitness) []byte {
t.Logf("reading preimage key %x at offset %d", stepWitness.PreimageKey, stepWitness.PreimageOffset)
poInput, err := encodePreimageOracleInput(t, stepWitness, LocalContext{}, m.localOracle)
require.NoError(t, err, "encode preimage oracle input")
_, leftOverGas, err := m.env.Call(vm.AccountRef(sender), m.addrs.Oracle, poInput, startingGas, big.NewInt(0))
_, leftOverGas, err := m.env.Call(vm.AccountRef(sender), m.addrs.Oracle, poInput, startingGas, common.U2560)
require.NoErrorf(t, err, "evm should not fail, took %d gas", startingGas-leftOverGas)
}
input := encodeStepInput(t, stepWitness, LocalContext{})
ret, leftOverGas, err := m.env.Call(vm.AccountRef(sender), m.addrs.MIPS, input, startingGas, big.NewInt(0))
ret, leftOverGas, err := m.env.Call(vm.AccountRef(sender), m.addrs.MIPS, input, startingGas, common.U2560)
require.NoError(t, err, "evm should not fail")
require.Len(t, ret, 32, "expecting 32-byte state hash")
// remember state hash, to check it against state
......@@ -293,7 +293,7 @@ func TestEVMFault(t *testing.T) {
input := encodeStepInput(t, stepWitness, LocalContext{})
startingGas := uint64(30_000_000)
_, _, err := env.Call(vm.AccountRef(sender), addrs.MIPS, input, startingGas, big.NewInt(0))
_, _, err := env.Call(vm.AccountRef(sender), addrs.MIPS, input, startingGas, common.U2560)
require.EqualValues(t, err, vm.ErrExecutionReverted)
logs := evmState.Logs()
require.Equal(t, 0, len(logs))
......
......@@ -12,7 +12,7 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240318114348-52d3dbd1605d
github.com/ethereum/go-ethereum v1.13.9
github.com/ethereum/go-ethereum v1.13.11
github.com/fsnotify/fsnotify v1.7.0
github.com/go-chi/chi/v5 v5.0.12
github.com/go-chi/docgen v1.2.0
......@@ -103,7 +103,7 @@ require (
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
......@@ -247,7 +247,7 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)
replace github.com/ethereum/go-ethereum v1.13.9 => github.com/ethereum-optimism/op-geth v1.101309.0-rc.2
replace github.com/ethereum/go-ethereum v1.13.11 => github.com/ethereum-optimism/op-geth v1.101311.0-rc.1
//replace github.com/ethereum/go-ethereum v1.13.9 => ../op-geth
......
......@@ -189,8 +189,8 @@ github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/
github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v1.101309.0-rc.2 h1:8XIKJAH78fLl0AAY4Bq00nIeAeoodZjCcm5CNTcr0eU=
github.com/ethereum-optimism/op-geth v1.101309.0-rc.2/go.mod h1:eFb6HyjixYhM8b0r0imIYKKfhPKx+xIvTqbkIipoBig=
github.com/ethereum-optimism/op-geth v1.101311.0-rc.1 h1:3JE5FyGXNQCnXUuiK3I6ZD3zbB2DBIcEMsXCpjrXUwM=
github.com/ethereum-optimism/op-geth v1.101311.0-rc.1/go.mod h1:K23yb9efVf9DdUOv/vl/Ux57Tng00rLaFqWYlFF45CA=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240318114348-52d3dbd1605d h1:K7HdD/ZAcSFhcqqnUAbvU+8vsg0DzL8pvetHw5vRLCc=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240318114348-52d3dbd1605d/go.mod h1:7xh2awFQqsiZxFrHKTgEd+InVfDRrkKVUIuK8SAFHp0=
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
......@@ -244,8 +244,9 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
......@@ -1061,6 +1062,7 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
......
......@@ -11,6 +11,7 @@ import (
"path"
"time"
"github.com/holiman/uint256"
"github.com/pkg/profile"
"github.com/urfave/cli/v2"
......@@ -257,7 +258,7 @@ func simulate(ctx context.Context, logger log.Logger, conf *params.ChainConfig,
}
for addr, acc := range dump {
state.CreateAccount(addr)
state.SetBalance(addr, new(big.Int).Set((*big.Int)(&acc.Balance)))
state.SetBalance(addr, uint256.MustFromBig((*big.Int)(&acc.Balance)))
state.SetNonce(addr, acc.Nonce)
state.SetCode(addr, acc.Code)
state.SetStorage(addr, acc.Storage)
......
......@@ -4,13 +4,13 @@ import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/holiman/uint256"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core"
gstate "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-chain-ops/state"
......@@ -76,9 +76,9 @@ func BuildL1DeveloperGenesis(config *DeployConfig, dump *gstate.Dump, l1Deployme
memDB.CreateAccount(address)
memDB.SetNonce(address, account.Nonce)
balance, ok := math.ParseBig256(account.Balance)
if !ok {
return nil, fmt.Errorf("failed to parse balance for %s", address)
balance := &uint256.Int{}
if err := balance.UnmarshalText([]byte(account.Balance)); err != nil {
return nil, fmt.Errorf("failed to parse balance for %s: %w", address, err)
}
memDB.AddBalance(address, balance)
memDB.SetCode(address, account.Code)
......
......@@ -5,6 +5,8 @@ import (
"fmt"
"math/big"
"github.com/holiman/uint256"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"
......@@ -26,7 +28,7 @@ func FundDevAccounts(db vm.StateDB) {
if !db.Exist(account) {
db.CreateAccount(account)
}
db.AddBalance(account, devBalance)
db.AddBalance(account, uint256.MustFromBig(devBalance))
}
}
......@@ -61,7 +63,7 @@ func SetPrecompileBalances(db vm.StateDB) {
for i := 0; i < PrecompileCount; i++ {
addr := common.BytesToAddress([]byte{byte(i)})
db.CreateAccount(addr)
db.AddBalance(addr, common.Big1)
db.AddBalance(addr, uint256.NewInt(1))
}
}
......
......@@ -6,6 +6,8 @@ import (
"math/big"
"sync"
"github.com/holiman/uint256"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
......@@ -78,7 +80,7 @@ func (db *MemoryStateDB) createAccount(addr common.Address) {
}
}
func (db *MemoryStateDB) SubBalance(addr common.Address, amount *big.Int) {
func (db *MemoryStateDB) SubBalance(addr common.Address, amount *uint256.Int) {
db.rw.Lock()
defer db.rw.Unlock()
......@@ -89,11 +91,11 @@ func (db *MemoryStateDB) SubBalance(addr common.Address, amount *big.Int) {
if account.Balance.Sign() == 0 {
return
}
account.Balance = new(big.Int).Sub(account.Balance, amount)
account.Balance.Sub(account.Balance, amount.ToBig())
db.genesis.Alloc[addr] = account
}
func (db *MemoryStateDB) AddBalance(addr common.Address, amount *big.Int) {
func (db *MemoryStateDB) AddBalance(addr common.Address, amount *uint256.Int) {
db.rw.Lock()
defer db.rw.Unlock()
......@@ -101,19 +103,19 @@ func (db *MemoryStateDB) AddBalance(addr common.Address, amount *big.Int) {
if !ok {
panic(fmt.Sprintf("%s not in state", addr))
}
account.Balance = new(big.Int).Add(account.Balance, amount)
account.Balance.Add(account.Balance, amount.ToBig())
db.genesis.Alloc[addr] = account
}
func (db *MemoryStateDB) GetBalance(addr common.Address) *big.Int {
func (db *MemoryStateDB) GetBalance(addr common.Address) *uint256.Int {
db.rw.RLock()
defer db.rw.RUnlock()
account, ok := db.genesis.Alloc[addr]
if !ok {
return common.Big0
return common.U2560
}
return account.Balance
return uint256.MustFromBig(account.Balance)
}
func (db *MemoryStateDB) GetNonce(addr common.Address) uint64 {
......
......@@ -7,6 +7,8 @@ import (
"testing"
"time"
"github.com/holiman/uint256"
"github.com/ethereum-optimism/optimism/op-chain-ops/state"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
......@@ -22,14 +24,14 @@ func TestAddBalance(t *testing.T) {
for i := 0; i < 100; i++ {
key, _ := crypto.GenerateKey()
addr := crypto.PubkeyToAddress(key.PublicKey)
value := new(big.Int).Rand(rng, big.NewInt(1000))
value := uint256.NewInt(uint64(rng.Intn(1000)))
db.CreateAccount(addr)
db.AddBalance(addr, value)
account := db.GetAccount(addr)
require.NotNil(t, account)
require.True(t, BigEqual(account.Balance, value))
require.Equal(t, uint256.MustFromBig(account.Balance), value)
}
}
......
......@@ -6,6 +6,7 @@ import (
"fmt"
"math/big"
"os"
"strings"
"time"
"github.com/ethereum/go-ethereum"
......@@ -46,7 +47,7 @@ func ForReceipt(ctx context.Context, client *ethclient.Client, hash common.Hash,
defer ticker.Stop()
for {
receipt, err := client.TransactionReceipt(ctx, hash)
if errors.Is(err, ethereum.NotFound) {
if errors.Is(err, ethereum.NotFound) || (err != nil && strings.Contains(err.Error(), "transaction indexing is in progress")) {
select {
case <-ctx.Done():
return nil, ctx.Err()
......
......@@ -6,6 +6,7 @@ import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/holiman/uint256"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/accounts/abi"
......@@ -251,7 +252,7 @@ func FuzzUnmarshallLogEvent(f *testing.F) {
if err != nil {
t.Fatal(err)
}
state.SetBalance(from, BytesToBigInt([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}))
state.SetBalance(from, uint256.MustFromBig(BytesToBigInt([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff})))
state.SetCode(addr, common.FromHex(bindings.OptimismPortalDeployedBin))
_, err = state.Commit(0, false)
if err != nil {
......
......@@ -5,6 +5,8 @@ import (
"errors"
"fmt"
"github.com/holiman/uint256"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
......@@ -76,12 +78,16 @@ func VerifyStorageProof(root common.Hash, proof gethclient.StorageResult) error
}
func VerifyProof(stateRoot common.Hash, proof *gethclient.AccountResult) error {
balance, overflow := uint256.FromBig(proof.Balance)
if overflow {
return fmt.Errorf("proof balance overflows uint256: %d", proof.Balance)
}
err := VerifyAccountProof(
stateRoot,
proof.Address,
types.StateAccount{
Nonce: proof.Nonce,
Balance: proof.Balance,
Balance: balance,
Root: proof.StorageHash,
CodeHash: proof.CodeHash[:],
},
......
......@@ -17,6 +17,7 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/hashdb"
"github.com/holiman/uint256"
"github.com/stretchr/testify/require"
)
......@@ -129,13 +130,13 @@ func TestUpdateState(t *testing.T) {
statedb, err := state.New(genesisBlock.Root(), state.NewDatabase(rawdb.NewDatabase(db)), nil)
require.NoError(t, err)
statedb.SetBalance(userAccount, big.NewInt(50))
require.Equal(t, big.NewInt(50), statedb.GetBalance(userAccount))
statedb.SetBalance(userAccount, uint256.NewInt(50))
require.Equal(t, uint256.NewInt(50), statedb.GetBalance(userAccount))
statedb.SetNonce(userAccount, uint64(5))
require.Equal(t, uint64(5), statedb.GetNonce(userAccount))
statedb.SetBalance(unknownAccount, big.NewInt(60))
require.Equal(t, big.NewInt(60), statedb.GetBalance(unknownAccount))
statedb.SetBalance(unknownAccount, uint256.NewInt(60))
require.Equal(t, uint256.NewInt(60), statedb.GetBalance(unknownAccount))
statedb.SetCode(codeAccount, []byte{1})
require.Equal(t, []byte{1}, statedb.GetCode(codeAccount))
......@@ -147,9 +148,9 @@ func TestUpdateState(t *testing.T) {
statedb, err = state.New(newRoot, state.NewDatabase(rawdb.NewDatabase(db)), nil)
require.NoError(t, err)
require.Equal(t, big.NewInt(50), statedb.GetBalance(userAccount))
require.Equal(t, uint256.NewInt(50), statedb.GetBalance(userAccount))
require.Equal(t, uint64(5), statedb.GetNonce(userAccount))
require.Equal(t, big.NewInt(60), statedb.GetBalance(unknownAccount))
require.Equal(t, uint256.NewInt(60), statedb.GetBalance(unknownAccount))
require.Equal(t, []byte{1}, statedb.GetCode(codeAccount))
}
......@@ -183,7 +184,7 @@ func assertStateDataAvailable(t *testing.T, db ethdb.KeyValueStore, l2Genesis *c
require.NoError(t, err)
for address, account := range l2Genesis.Alloc {
require.Equal(t, account.Balance, statedb.GetBalance(address))
require.Equal(t, uint256.MustFromBig(account.Balance), statedb.GetBalance(address))
require.Equal(t, account.Nonce, statedb.GetNonce(address))
require.Equal(t, common.BytesToHash(crypto.Keccak256(account.Code)), statedb.GetCodeHash(address))
require.Equal(t, account.Code, statedb.GetCode(address))
......@@ -192,7 +193,7 @@ func assertStateDataAvailable(t *testing.T, db ethdb.KeyValueStore, l2Genesis *c
}
}
require.Equal(t, common.Hash{}, statedb.GetState(codeAccount, common.HexToHash("0x99")), "retrieve unset storage key")
require.Equal(t, common.Big0, statedb.GetBalance(unknownAccount), "unset account balance")
require.Equal(t, common.U2560, statedb.GetBalance(unknownAccount), "unset account balance")
require.Equal(t, uint64(0), statedb.GetNonce(unknownAccount), "unset account balance")
require.Nil(t, statedb.GetCode(unknownAccount), "unset account code")
require.Equal(t, common.Hash{}, statedb.GetCodeHash(unknownAccount), "unset account code hash")
......
......@@ -7,8 +7,6 @@ import (
"math/rand"
"testing"
"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
gokzg4844 "github.com/crate-crypto/go-kzg-4844"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
......@@ -158,38 +156,29 @@ func TestFetchL1Receipts(t *testing.T) {
})
}
// Globally initialize a kzgCtx for blob tests.
var kzgCtx, _ = gokzg4844.NewContext4096Secure()
// Returns a serialized random field element in big-endian
func GetRandFieldElement(seed int64) [32]byte {
var r fr.Element
_, _ = r.SetRandom()
return gokzg4844.SerializeScalar(r)
}
func GetRandBlob(seed int64) gokzg4844.Blob {
var blob gokzg4844.Blob
bytesPerBlob := gokzg4844.ScalarsPerBlob * gokzg4844.SerializedScalarSize
for i := 0; i < bytesPerBlob; i += gokzg4844.SerializedScalarSize {
fieldElementBytes := GetRandFieldElement(seed + int64(i))
copy(blob[i:i+gokzg4844.SerializedScalarSize], fieldElementBytes[:])
func GetRandBlob(t *testing.T, seed int64) eth.Blob {
r := rand.New(rand.NewSource(seed))
bigData := eth.Data(make([]byte, eth.MaxBlobDataSize))
for i := range bigData {
bigData[i] = byte(r.Intn(256))
}
return blob
var b eth.Blob
err := b.FromData(bigData)
require.NoError(t, err)
return b
}
func TestFetchL1Blob(t *testing.T) {
blob := GetRandBlob(0xf00f00)
commitment, err := kzgCtx.BlobToKZGCommitment(blob, 0)
blob := GetRandBlob(t, 0xf00f00)
commitment, err := blob.ComputeKZGCommitment()
require.NoError(t, err)
versionedHash := sha256.Sum256(commitment[:])
versionedHash[0] = params.BlobTxHashVersion
versionedHash := eth.KZGToVersionedHash(commitment)
blobHash := eth.IndexedBlobHash{Hash: versionedHash, Index: 0xFACADE}
l1Ref := eth.L1BlockRef{Time: 0}
t.Run("AlreadyKnown", func(t *testing.T) {
prefetcher, _, blobFetcher, _, kv := createPrefetcher(t)
storeBlob(t, kv, (eth.Bytes48)(commitment), (*eth.Blob)(&blob))
storeBlob(t, kv, (eth.Bytes48)(commitment), &blob)
oracle := l1.NewPreimageOracle(asOracleFn(t, prefetcher), asHinter(t, prefetcher))
defer blobFetcher.AssertExpectations(t)
......@@ -207,7 +196,7 @@ func TestFetchL1Blob(t *testing.T) {
l1Ref,
[]eth.IndexedBlobHash{blobHash},
(eth.Bytes48)(commitment),
[]*eth.Blob{(*eth.Blob)(&blob)},
[]*eth.Blob{&blob},
nil,
)
defer blobFetcher.AssertExpectations(t)
......
......@@ -2,7 +2,6 @@ package prefetcher
import (
"context"
"crypto/sha256"
"errors"
"testing"
......@@ -12,7 +11,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/retry"
......@@ -115,11 +113,10 @@ func createL1Source(t *testing.T) (*RetryingL1Source, *testutils.MockL1Source) {
func TestRetryingL1BlobSource(t *testing.T) {
ctx := context.Background()
blob := GetRandBlob(0xFACADE)
commitment, err := kzgCtx.BlobToKZGCommitment(blob, 0)
blob := GetRandBlob(t, 0xFACADE)
commitment, err := blob.ComputeKZGCommitment()
require.NoError(t, err)
versionedHash := sha256.Sum256(commitment[:])
versionedHash[0] = params.BlobTxHashVersion
versionedHash := eth.KZGToVersionedHash(commitment)
blobHash := eth.IndexedBlobHash{Hash: versionedHash, Index: 0xFACADE}
l1BlockRef := eth.L1BlockRef{Time: 0}
......
......@@ -9,7 +9,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/ethereum/go-ethereum/params"
)
const (
......@@ -64,14 +63,8 @@ func (b *Blob) ComputeKZGCommitment() (kzg4844.Commitment, error) {
// KZGToVersionedHash computes the "blob hash" (a.k.a. versioned-hash) of a blob-commitment, as used in a blob-tx.
// We implement it here because it is unfortunately not (currently) exposed by geth.
func KZGToVersionedHash(commitment kzg4844.Commitment) (out common.Hash) {
// EIP-4844 spec:
// def kzg_to_versioned_hash(commitment: KZGCommitment) -> VersionedHash:
// return VERSIONED_HASH_VERSION_KZG + sha256(commitment)[1:]
h := sha256.New()
h.Write(commitment[:])
_ = h.Sum(out[:0])
out[0] = params.BlobTxHashVersion
return out
hasher := sha256.New()
return kzg4844.CalcBlobHashV1(hasher, &commitment)
}
// VerifyBlobProof verifies that the given blob and proof corresponds to the given commitment,
......
......@@ -8,7 +8,7 @@ require (
cloud.google.com/go/kms v1.12.1
github.com/BurntSushi/toml v1.3.2
github.com/ethereum-optimism/optimism v1.6.2-0.20240222202618-f707883038d5
github.com/ethereum/go-ethereum v1.13.9
github.com/ethereum/go-ethereum v1.13.11
github.com/gorilla/mux v1.8.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.0
......@@ -52,7 +52,7 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
......@@ -130,6 +130,6 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)
replace github.com/ethereum/go-ethereum v1.13.9 => github.com/ethereum-optimism/op-geth v1.101309.0-rc.2
replace github.com/ethereum/go-ethereum v1.13.11 => github.com/ethereum-optimism/op-geth v1.101311.0-rc.1
replace github.com/ethereum-optimism/optimism => ../.
......@@ -100,8 +100,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum-optimism/op-geth v1.101309.0-rc.2 h1:8XIKJAH78fLl0AAY4Bq00nIeAeoodZjCcm5CNTcr0eU=
github.com/ethereum-optimism/op-geth v1.101309.0-rc.2/go.mod h1:eFb6HyjixYhM8b0r0imIYKKfhPKx+xIvTqbkIipoBig=
github.com/ethereum-optimism/op-geth v1.101311.0-rc.1 h1:3JE5FyGXNQCnXUuiK3I6ZD3zbB2DBIcEMsXCpjrXUwM=
github.com/ethereum-optimism/op-geth v1.101311.0-rc.1/go.mod h1:K23yb9efVf9DdUOv/vl/Ux57Tng00rLaFqWYlFF45CA=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240318114348-52d3dbd1605d h1:K7HdD/ZAcSFhcqqnUAbvU+8vsg0DzL8pvetHw5vRLCc=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240318114348-52d3dbd1605d/go.mod h1:7xh2awFQqsiZxFrHKTgEd+InVfDRrkKVUIuK8SAFHp0=
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
......@@ -128,8 +128,9 @@ github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnR
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
......@@ -465,6 +466,7 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
......
......@@ -10,9 +10,8 @@ import (
"path/filepath"
"strings"
"github.com/ethereum/go-ethereum/core/types"
"github.com/holiman/uint256"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus/beacon"
......@@ -20,11 +19,14 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum-optimism/optimism/op-service/eth"
)
var HundredETH = big.NewInt(0).Mul(big.NewInt(100), big.NewInt(params.Ether))
......@@ -335,7 +337,7 @@ func StoragePatch(patch io.Reader, address common.Address) HeadFn {
func SetBalance(addr common.Address, amount *big.Int) HeadFn {
return func(_ *types.Header, headState *state.StateDB) error {
headState.SetBalance(addr, amount)
headState.SetBalance(addr, uint256.MustFromBig(amount))
return nil
}
}
......
......@@ -292,7 +292,7 @@ func DiffTestUtils() {
// Put the put the rlp encoded account in the world trie
account := types.StateAccount{
Nonce: 0,
Balance: big.NewInt(0),
Balance: common.U2560,
Root: state.Hash(),
}
writer := new(bytes.Buffer)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment