Commit 7971d924 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

Merge pull request #2148 from ethereum-optimism/develop

Develop -> Master PR
parents 412a1271 98cb7ee6
---
'@eth-optimism/contracts': patch
---
Remove unused gas testing utils
---
'@eth-optimism/l2geth': patch
---
Various small changes to reduce our upstream Geth diff
---
'@eth-optimism/data-transport-layer': patch
---
Handle case where the remote block isn't found for `GET /eth/context/latest` and `GET /eth/context/blocknumber/:number`
......@@ -34,7 +34,6 @@ type ABI struct {
Constructor Method
Methods map[string]Method
Events map[string]Event
MethodsById map[[4]byte]*Method
}
// JSON returns a parsed ABI interface and error if it failed.
......@@ -123,13 +122,6 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
return err
}
abi.Methods = make(map[string]Method)
// UsingOVM specific changes
// Create a cache of methods when running under the OVM because
// looking up methods based on the 4 byte selector is part of the hot
// code path. Without this cache, it was observed that 50% of the CPU
// time during syncing was spent hashing the function selectors
// during the call to `abi.MethodsById`
abi.MethodsById = make(map[[4]byte]*Method)
abi.Events = make(map[string]Event)
for _, field := range fields {
switch field.Type {
......@@ -146,18 +138,13 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
_, ok = abi.Methods[name]
}
isConst := field.Constant || field.StateMutability == "pure" || field.StateMutability == "view"
method := Method{
abi.Methods[name] = Method{
Name: name,
RawName: field.Name,
Const: isConst,
Inputs: field.Inputs,
Outputs: field.Outputs,
}
abi.Methods[name] = method
// UsingOVM specific changes
// Add method to the id cache
sigdata := method.ID()
abi.MethodsById[[4]byte{sigdata[0], sigdata[1], sigdata[2], sigdata[3]}] = &method
case "event":
name := field.Name
_, ok := abi.Events[name]
......@@ -183,15 +170,12 @@ func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
if len(sigdata) < 4 {
return nil, fmt.Errorf("data too short (%d bytes) for abi method lookup", len(sigdata))
}
// UsingOVM specific changes
// Use the method cache to prevent the need to iterate and hash
// each method in the ABI
method, exist := abi.MethodsById[[4]byte{sigdata[0], sigdata[1], sigdata[2], sigdata[3]}]
if !exist {
return nil, fmt.Errorf("no method with id: %#x", sigdata[:4])
for _, method := range abi.Methods {
if bytes.Equal(method.ID(), sigdata[:4]) {
return &method, nil
}
return method, nil
}
return nil, fmt.Errorf("no method with id: %#x", sigdata[:4])
}
// EventByID looks an event up by its topic hash in the
......
......@@ -494,8 +494,6 @@ var bindTests = []struct {
"github.com/ethereum-optimism/optimism/l2geth/crypto"
`,
`
t.Skip("OVM breaks this... SKIPPING: CallFrom test. CALLER must be transpiled for this test to work properly.")
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
......@@ -543,8 +541,6 @@ var bindTests = []struct {
"github.com/ethereum-optimism/optimism/l2geth/core"
`,
`
t.Skip("OVM breaks this... SKIPPING: NonExistent contract test. This should be fixed & should pass if we returned the correct error messages.")
// Create a simulator and wrap a non-deployed contract
sim := backends.NewSimulatedBackend(core.GenesisAlloc{}, uint64(10000000000))
......@@ -643,8 +639,6 @@ var bindTests = []struct {
"github.com/ethereum-optimism/optimism/l2geth/crypto"
`,
`
t.Skip("OVM breaks this... SKIPPING: CallFrom test. CALLER must be transpiled for this test to work properly.")
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
......@@ -1281,8 +1275,6 @@ var bindTests = []struct {
"github.com/ethereum-optimism/optimism/l2geth/crypto"
`,
`
t.Skip("OVM breaks this... SKIPPING: UseLibrary test.")
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
......@@ -1500,8 +1492,6 @@ var bindTests = []struct {
"github.com/ethereum-optimism/optimism/l2geth/core"
`,
`
t.Skip("OVM breaks this... SKIPPING: MultiContracts test.")
key, _ := crypto.GenerateKey()
addr := crypto.PubkeyToAddress(key.PublicKey)
......
......@@ -467,7 +467,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
username, avatar, address, err = authNoAuth(msg.URL)
default:
//lint:ignore ST1005 This error is to be displayed in the browser
err = errors.New("Something funky happened, please open an issue at https://github.com/ethereum-optimism/optimism/l2geth/issues")
err = errors.New("Something funky happened, please open an issue at https://github.com/ethereum-optimism/optimism/issues")
}
if err != nil {
if err = sendError(conn, err); err != nil {
......
......@@ -183,7 +183,7 @@ Fatal: Failed to unlock account f466859ead1932d743d622cb74fc058882e8648a (could
`)
}
// https://github.com/ethereum-optimism/optimism/l2geth/issues/1785
// https://github.com/ethereum/go-ethereum/issues/1785
func TestUnlockFlagMultiIndex(t *testing.T) {
datadir := tmpDatadirWithKeystore(t)
geth := runGeth(t,
......
......@@ -43,7 +43,7 @@ var (
Description: `
The Geth console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API.
See https://github.com/ethereum-optimism/optimism/l2geth/wiki/JavaScript-Console.`,
See https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console.`,
}
attachCommand = cli.Command{
......@@ -56,7 +56,7 @@ See https://github.com/ethereum-optimism/optimism/l2geth/wiki/JavaScript-Console
Description: `
The Geth console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API.
See https://github.com/ethereum-optimism/optimism/l2geth/wiki/JavaScript-Console.
See https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console.
This command allows to open a console on a running geth node.`,
}
......@@ -69,7 +69,7 @@ This command allows to open a console on a running geth node.`,
Category: "CONSOLE COMMANDS",
Description: `
The JavaScript VM exposes a node admin interface as well as the Ðapp
JavaScript API. See https://github.com/ethereum-optimism/optimism/l2geth/wiki/JavaScript-Console`,
JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console`,
}
)
......
......@@ -256,7 +256,7 @@ var dashboardContent = `
<p>Starting with the 1.5 release of go-ethereum, we've transitioned away from shipping only full blown Ethereum clients and started focusing on releasing the code as reusable packages initially for Go projects, then later for Java based Android projects too. Mobile support is still evolving, hence is bound to change often and hard, but the Ethereum network can nonetheless be accessed from Android too.</p>
<p>Under the hood the Android library is backed by a go-ethereum light node, meaning that given a not-too-old Android device, you should be able to join the network without significant issues. Certain functionality is not yet available and rough edges are bound to appear here and there, please report issues if you find any.</p>
<br/>
<p>The stable Android archives are distributed via Maven Central, and the develop snapshots via the Sonatype repositories. Before proceeding, please ensure you have a recent version configured in your Android project. You can find details in <a href="https://github.com/ethereum-optimism/optimism/l2geth/wiki/Mobile:-Introduction#android-archive" target="about:blank">Mobile: Introduction &ndash; Android archive</a>.
<p>The stable Android archives are distributed via Maven Central, and the develop snapshots via the Sonatype repositories. Before proceeding, please ensure you have a recent version configured in your Android project. You can find details in <a href="https://github.com/ethereum/go-ethereum/wiki/Mobile:-Introduction#android-archive" target="about:blank">Mobile: Introduction &ndash; Android archive</a>.
<p>Before connecting to the Ethereum network, download the <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> genesis json file and either store it in your Android project as a resource file you can access, or save it as a string in a variable. You're going to need to to initialize your client.</p>
<p>Inside your Java code you can now import the geth archive and connect to Ethereum:
<pre>import org.ethereum.geth.*;</pre>
......@@ -287,7 +287,7 @@ node.start();
<p>Starting with the 1.5 release of go-ethereum, we've transitioned away from shipping only full blown Ethereum clients and started focusing on releasing the code as reusable packages initially for Go projects, then later for ObjC/Swift based iOS projects too. Mobile support is still evolving, hence is bound to change often and hard, but the Ethereum network can nonetheless be accessed from iOS too.</p>
<p>Under the hood the iOS library is backed by a go-ethereum light node, meaning that given a not-too-old Apple device, you should be able to join the network without significant issues. Certain functionality is not yet available and rough edges are bound to appear here and there, please report issues if you find any.</p>
<br/>
<p>Both stable and develop builds of the iOS framework are available via CocoaPods. Before proceeding, please ensure you have a recent version configured in your iOS project. You can find details in <a href="https://github.com/ethereum-optimism/optimism/l2geth/wiki/Mobile:-Introduction#ios-framework" target="about:blank">Mobile: Introduction &ndash; iOS framework</a>.
<p>Both stable and develop builds of the iOS framework are available via CocoaPods. Before proceeding, please ensure you have a recent version configured in your iOS project. You can find details in <a href="https://github.com/ethereum/go-ethereum/wiki/Mobile:-Introduction#ios-framework" target="about:blank">Mobile: Introduction &ndash; iOS framework</a>.
<p>Before connecting to the Ethereum network, download the <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> genesis json file and either store it in your iOS project as a resource file you can access, or save it as a string in a variable. You're going to need to to initialize your client.</p>
<p>Inside your Swift code you can now import the geth framework and connect to Ethereum (ObjC should be analogous):
<pre>import Geth</pre>
......@@ -419,7 +419,7 @@ try! node?.start();
<p>Puppeth is a tool to aid you in creating a new Ethereum network down to the genesis block, bootnodes, signers, ethstats server, crypto faucet, wallet browsers, block explorer, dashboard and more; without the hassle that it would normally entail to manually configure all these services one by one.</p>
<p>Puppeth uses ssh to dial in to remote servers, and builds its network components out of docker containers using docker-compose. The user is guided through the process via a command line wizard that does the heavy lifting and topology configuration automatically behind the scenes.</p>
<br/>
<p>Puppeth is distributed as part of the <a href="https://geth.ethereum.org/downloads/" target="about:blank">Geth &amp; Tools</a> bundles, but can also be installed separately via:<pre>go get github.com/ethereum-optimism/optimism/l2geth/cmd/puppeth</pre></p>
<p>Puppeth is distributed as part of the <a href="https://geth.ethereum.org/downloads/" target="about:blank">Geth &amp; Tools</a> bundles, but can also be installed separately via:<pre>go get github.com/ethereum/go-ethereum/cmd/puppeth</pre></p>
<br/>
<p><em>Copyright 2017. The go-ethereum Authors.</em></p>
</div>
......
......@@ -363,7 +363,7 @@ func TestClique(t *testing.T) {
failure: errRecentlySigned,
}, {
// Recent signatures should not reset on checkpoint blocks imported in a new
// batch (https://github.com/ethereum-optimism/optimism/l2geth/issues/17593). Whilst this
// batch (https://github.com/ethereum/go-ethereum/issues/17593). Whilst this
// seems overly specific and weird, it was a Rinkeby consensus split.
epoch: 3,
signers: []string{"A", "B", "C"},
......
......@@ -55,7 +55,7 @@ func TestTestMode(t *testing.T) {
}
// This test checks that cache lru logic doesn't crash under load.
// It reproduces https://github.com/ethereum-optimism/optimism/l2geth/issues/14943
// It reproduces https://github.com/ethereum/go-ethereum/issues/14943
func TestCacheFileEvict(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "ethash-test")
if err != nil {
......
......@@ -165,8 +165,6 @@ func (a Accounts) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Accounts) Less(i, j int) bool { return bytes.Compare(a[i].addr.Bytes(), a[j].addr.Bytes()) < 0 }
func TestCheckpointRegister(t *testing.T) {
t.Skip("OVM breaks this with invalid number of events, probably because the CheckpointOracle must be transpiled to function properly.")
// Initialize test accounts
var accounts Accounts
for i := 0; i < 3; i++ {
......
......@@ -982,8 +982,6 @@ func TestLogReorgs(t *testing.T) {
}
func TestLogRebirth(t *testing.T) {
t.Skip("OVM Genesis breaks this test because it adds the OVM contracts to the state.")
var (
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
addr1 = crypto.PubkeyToAddress(key1.PublicKey)
......@@ -1422,8 +1420,6 @@ func TestEIP155Transition(t *testing.T) {
}
func TestEIP161AccountRemoval(t *testing.T) {
t.Skip("OVM breaks with `expected account to exist`, probably based on some unknown transaction failure.")
// Configure and generate a sample block chain
var (
db = rawdb.NewMemoryDatabase()
......@@ -1494,7 +1490,7 @@ func TestEIP161AccountRemoval(t *testing.T) {
// tests that under weird reorg conditions the blockchain and its internal header-
// chain return the same latest block/header.
//
// https://github.com/ethereum-optimism/optimism/l2geth/pull/15941
// https://github.com/ethereum/go-ethereum/pull/15941
func TestBlockchainHeaderchainReorgConsistency(t *testing.T) {
// Generate a canonical chain to act as the main dataset
engine := ethash.NewFaker()
......@@ -1755,8 +1751,8 @@ func TestIncompleteAncientReceiptChainInsertion(t *testing.T) {
// overtake the 'canon' chain until after it's passed canon by about 200 blocks.
//
// Details at:
// - https://github.com/ethereum-optimism/optimism/l2geth/issues/18977
// - https://github.com/ethereum-optimism/optimism/l2geth/pull/18988
// - https://github.com/ethereum/go-ethereum/issues/18977
// - https://github.com/ethereum/go-ethereum/pull/18988
func TestLowDiffLongChain(t *testing.T) {
// Generate a canonical chain to act as the main dataset
engine := ethash.NewFaker()
......
......@@ -82,7 +82,7 @@ func TestMatcherRandom(t *testing.T) {
// Tests that the matcher can properly find matches if the starting block is
// shifter from a multiple of 8. This is needed to cover an optimisation with
// bitset matching https://github.com/ethereum-optimism/optimism/l2geth/issues/15309.
// bitset matching https://github.com/ethereum/go-ethereum/issues/15309.
func TestMatcherShifted(t *testing.T) {
// Block 0 always matches in the tests, skip ahead of first 8 blocks with the
// start to get a potential zero byte in the matcher bitset.
......
......@@ -31,8 +31,6 @@ import (
)
func TestDefaultGenesisBlock(t *testing.T) {
t.Skip("OVM breaks this test because it adds the OVM contracts to the Genesis state.")
block := DefaultGenesisBlock().ToBlock(nil)
if block.Hash() != params.MainnetGenesisHash {
t.Errorf("wrong mainnet genesis hash, got %v, want %v", block.Hash(), params.MainnetGenesisHash)
......
......@@ -638,7 +638,7 @@ func (s *StateDB) Copy() *StateDB {
}
// Copy the dirty states, logs, and preimages
for addr := range s.journal.dirties {
// As documented [here](https://github.com/ethereum-optimism/optimism/l2geth/pull/16485#issuecomment-380438527),
// As documented [here](https://github.com/ethereum/go-ethereum/pull/16485#issuecomment-380438527),
// and in the Finalise-method, there is a case where an object is in the journal but not
// in the stateObjects: OOG after touch on ripeMD prior to Byzantium. Thus, we need to check for
// nil
......
......@@ -146,7 +146,7 @@ func TestIntermediateLeaks(t *testing.T) {
// TestCopy tests that copying a statedb object indeed makes the original and
// the copy independent of each other. This test is a regression test against
// https://github.com/ethereum-optimism/optimism/l2geth/pull/15549.
// https://github.com/ethereum/go-ethereum/pull/15549.
func TestCopy(t *testing.T) {
// Create a random state test to copy and modify "independently"
orig, _ := New(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()))
......@@ -475,7 +475,7 @@ func TestTouchDelete(t *testing.T) {
}
// TestCopyOfCopy tests that modified objects are carried over to the copy, and the copy of the copy.
// See https://github.com/ethereum-optimism/optimism/l2geth/pull/15225#issuecomment-380191512
// See https://github.com/ethereum/go-ethereum/pull/15225#issuecomment-380191512
func TestCopyOfCopy(t *testing.T) {
state, _ := New(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()))
addr := common.HexToAddress("aaaa")
......@@ -492,7 +492,7 @@ func TestCopyOfCopy(t *testing.T) {
// Tests a regression where committing a copy lost some internal meta information,
// leading to corrupted subsequent copies.
//
// See https://github.com/ethereum-optimism/optimism/l2geth/issues/20106.
// See https://github.com/ethereum/go-ethereum/issues/20106.
func TestCopyCommitCopy(t *testing.T) {
state, _ := New(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()))
......@@ -564,7 +564,7 @@ func TestCopyCommitCopy(t *testing.T) {
// Tests a regression where committing a copy lost some internal meta information,
// leading to corrupted subsequent copies.
//
// See https://github.com/ethereum-optimism/optimism/l2geth/issues/20106.
// See https://github.com/ethereum/go-ethereum/issues/20106.
func TestCopyCopyCommitCopy(t *testing.T) {
state, _ := New(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()))
......
......@@ -24,6 +24,7 @@ import (
"github.com/ethereum-optimism/optimism/l2geth/common/math"
"github.com/ethereum-optimism/optimism/l2geth/core/types"
"github.com/ethereum-optimism/optimism/l2geth/params"
"github.com/ethereum-optimism/optimism/l2geth/rollup/rcfg"
"golang.org/x/crypto/sha3"
)
......@@ -883,6 +884,9 @@ func opSuicide(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo
interpreter.evm.StateDB.AddBalance(common.BigToAddress(stack.pop()), balance)
interpreter.evm.StateDB.Suicide(contract.Address())
if rcfg.UsingOVM && interpreter.evm.chainConfig.IsSDUpdate(interpreter.evm.BlockNumber) {
interpreter.evm.StateDB.SubBalance(contract.Address(), balance)
}
return nil, nil
}
......
......@@ -274,8 +274,6 @@ func TestGetNodeData63(t *testing.T) { testGetNodeData(t, 63) }
func TestGetNodeData64(t *testing.T) { testGetNodeData(t, 64) }
func testGetNodeData(t *testing.T, protocol int) {
t.Skip("OVM breaks this test with error: `account does not exist`")
// Define three accounts to simulate transactions with
acc1Key, _ := crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
acc2Key, _ := crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
......@@ -373,8 +371,6 @@ func TestGetReceipt63(t *testing.T) { testGetReceipt(t, 63) }
func TestGetReceipt64(t *testing.T) { testGetReceipt(t, 64) }
func testGetReceipt(t *testing.T, protocol int) {
t.Skip("OVM breaks this test with error: `account does not exist`")
// Define three accounts to simulate transactions with
acc1Key, _ := crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
acc2Key, _ := crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
......
......@@ -121,8 +121,6 @@ type callTracerTest struct {
}
func TestPrestateTracerCreate2(t *testing.T) {
t.Skip("OVM breaks this with `cannot read property` error, probably related to state manager.")
unsignedTx := types.NewTransaction(1, common.HexToAddress("0x00000000000000000000000000000000deadbeef"), new(big.Int), 5000000, big.NewInt(1), []byte{})
privateKeyECDSA, err := ecdsa.GenerateKey(crypto.S256(), rand.Reader)
......@@ -203,8 +201,6 @@ func TestPrestateTracerCreate2(t *testing.T) {
// Iterates over all the input-output datasets in the tracer test harness and
// runs the JavaScript tracers against them.
func TestCallTracer(t *testing.T) {
t.Skip("OVM breaks this with `execution reverted` error, probably some execution mismatch.")
files, err := ioutil.ReadDir("testdata")
if err != nil {
t.Fatalf("failed to retrieve tracer test suite: %v", err)
......
......@@ -437,7 +437,7 @@ func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs
//
// The key used to calculate the signature is decrypted with the given password.
//
// https://github.com/ethereum-optimism/optimism/l2geth/wiki/Management-APIs#personal_sign
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error) {
// Look up the wallet containing the requested signer
account := accounts.Account{Address: addr}
......@@ -465,7 +465,7 @@ func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr c
// Note, the signature must conform to the secp256k1 curve R, S and V values, where
// the V value must be 27 or 28 for legacy reasons.
//
// https://github.com/ethereum-optimism/optimism/l2geth/wiki/Management-APIs#personal_ecRecover
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover
func (s *PrivateAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.Bytes) (common.Address, error) {
if len(sig) != crypto.SignatureLength {
return common.Address{}, fmt.Errorf("signature must be %d bytes long", crypto.SignatureLength)
......
......@@ -51,8 +51,6 @@ func TestGetBlockHeadersLes2(t *testing.T) { testGetBlockHeaders(t, 2) }
func TestGetBlockHeadersLes3(t *testing.T) { testGetBlockHeaders(t, 3) }
func testGetBlockHeaders(t *testing.T, protocol int) {
t.Skip("SKIPPING (OVM)")
server, tearDown := newServerEnv(t, downloader.MaxHashFetch+15, protocol, nil, false, true, 0)
defer tearDown()
......@@ -183,8 +181,6 @@ func TestGetBlockBodiesLes2(t *testing.T) { testGetBlockBodies(t, 2) }
func TestGetBlockBodiesLes3(t *testing.T) { testGetBlockBodies(t, 3) }
func testGetBlockBodies(t *testing.T, protocol int) {
t.Skip("SKIPPING (OVM)")
server, tearDown := newServerEnv(t, downloader.MaxBlockFetch+15, protocol, nil, false, true, 0)
defer tearDown()
......@@ -263,8 +259,6 @@ func TestGetCodeLes2(t *testing.T) { testGetCode(t, 2) }
func TestGetCodeLes3(t *testing.T) { testGetCode(t, 3) }
func testGetCode(t *testing.T, protocol int) {
t.Skip("SKIPPING (OVM)")
// Assemble the test environment
server, tearDown := newServerEnv(t, 4, protocol, nil, false, true, 0)
defer tearDown()
......@@ -296,8 +290,6 @@ func TestGetStaleCodeLes2(t *testing.T) { testGetStaleCode(t, 2) }
func TestGetStaleCodeLes3(t *testing.T) { testGetStaleCode(t, 3) }
func testGetStaleCode(t *testing.T, protocol int) {
t.Skip("SKIPPING (OVM)")
server, tearDown := newServerEnv(t, core.TriesInMemory+4, protocol, nil, false, true, 0)
defer tearDown()
bc := server.handler.blockchain
......@@ -323,8 +315,6 @@ func TestGetReceiptLes2(t *testing.T) { testGetReceipt(t, 2) }
func TestGetReceiptLes3(t *testing.T) { testGetReceipt(t, 3) }
func testGetReceipt(t *testing.T, protocol int) {
t.Skip("SKIPPING (OVM)")
// Assemble the test environment
server, tearDown := newServerEnv(t, 4, protocol, nil, false, true, 0)
defer tearDown()
......@@ -353,8 +343,6 @@ func TestGetProofsLes2(t *testing.T) { testGetProofs(t, 2) }
func TestGetProofsLes3(t *testing.T) { testGetProofs(t, 3) }
func testGetProofs(t *testing.T, protocol int) {
t.Skip("SKIPPING (OVM)")
// Assemble the test environment
server, tearDown := newServerEnv(t, 4, protocol, nil, false, true, 0)
defer tearDown()
......@@ -391,8 +379,6 @@ func TestGetStaleProofLes2(t *testing.T) { testGetStaleProof(t, 2) }
func TestGetStaleProofLes3(t *testing.T) { testGetStaleProof(t, 3) }
func testGetStaleProof(t *testing.T, protocol int) {
t.Skip("SKIPPING (OVM)")
server, tearDown := newServerEnv(t, core.TriesInMemory+4, protocol, nil, false, true, 0)
defer tearDown()
bc := server.handler.blockchain
......@@ -430,8 +416,6 @@ func TestGetCHTProofsLes2(t *testing.T) { testGetCHTProofs(t, 2) }
func TestGetCHTProofsLes3(t *testing.T) { testGetCHTProofs(t, 3) }
func testGetCHTProofs(t *testing.T, protocol int) {
t.Skip("SKIPPING (OVM)")
config := light.TestServerIndexerConfig
waitIndexers := func(cIndexer, bIndexer, btIndexer *core.ChainIndexer) {
......@@ -481,8 +465,6 @@ func TestGetBloombitsProofsLes3(t *testing.T) { testGetBloombitsProofs(t, 3) }
// Tests that bloombits proofs can be correctly retrieved.
func testGetBloombitsProofs(t *testing.T, protocol int) {
t.Skip("SKIPPING (OVM)")
config := light.TestServerIndexerConfig
waitIndexers := func(cIndexer, bIndexer, btIndexer *core.ChainIndexer) {
......@@ -532,8 +514,6 @@ func TestTransactionStatusLes2(t *testing.T) { testTransactionStatus(t, 2) }
func TestTransactionStatusLes3(t *testing.T) { testTransactionStatus(t, 3) }
func testTransactionStatus(t *testing.T, protocol int) {
t.Skip("SKIPPING (OVM)")
server, tearDown := newServerEnv(t, 0, protocol, nil, false, true, 0)
defer tearDown()
server.handler.addTxsSync = true
......
......@@ -182,8 +182,6 @@ func odrTxStatus(ctx context.Context, db ethdb.Database, config *params.ChainCon
// testOdr tests odr requests whose validation guaranteed by block headers.
func testOdr(t *testing.T, protocol int, expFail uint64, checkCached bool, fn odrTestFn) {
t.Skip("OVM breaks this with `insufficient balance for transfer`, probably because transfers don't work.")
// Assemble the test environment
server, client, tearDown := newClientServerEnv(t, 4, protocol, nil, nil, 0, false, true)
defer tearDown()
......
......@@ -78,8 +78,6 @@ func tfCodeAccess(db ethdb.Database, bhash common.Hash, num uint64) light.OdrReq
}
func testAccess(t *testing.T, protocol int, fn accessTestFn) {
t.Skip("OVM breaks this with `insufficient balance for transfer`, probably because transfers don't work.")
// Assemble the test environment
server, client, tearDown := newClientServerEnv(t, 4, protocol, nil, nil, 0, false, true)
defer tearDown()
......
......@@ -41,8 +41,6 @@ func TestLegacyCheckpointSyncingLes3(t *testing.T) { testCheckpointSyncing(t, 3,
func TestCheckpointSyncingLes3(t *testing.T) { testCheckpointSyncing(t, 3, 2) }
func testCheckpointSyncing(t *testing.T, protocol int, syncMode int) {
t.Skip("OVM breaks this with `insufficient balance for transfer`, probably because transfers don't work.")
config := light.TestServerIndexerConfig
waitIndexers := func(cIndexer, bIndexer, btIndexer *core.ChainIndexer) {
......@@ -135,8 +133,6 @@ func TestMissOracleBackend(t *testing.T) { testMissOracleBackend(t,
func TestMissOracleBackendNoCheckpoint(t *testing.T) { testMissOracleBackend(t, false) }
func testMissOracleBackend(t *testing.T, hasCheckpoint bool) {
t.Skip("OVM breaks this with `insufficient balance for transfer`, probably because transfers don't work.")
config := light.TestServerIndexerConfig
waitIndexers := func(cIndexer, bIndexer, btIndexer *core.ChainIndexer) {
......@@ -188,7 +184,7 @@ func testMissOracleBackend(t *testing.T, hasCheckpoint bool) {
// that user wants to unlock something which blocks the oracle backend
// initialisation. But at the same time syncing starts.
//
// See https://github.com/ethereum-optimism/optimism/l2geth/issues/20097 for more detail.
// See https://github.com/ethereum/go-ethereum/issues/20097 for more detail.
//
// In this case, client should run light sync or legacy checkpoint sync
// if hardcoded checkpoint is configured.
......
......@@ -249,8 +249,6 @@ func testChainGen(i int, block *core.BlockGen) {
}
func testChainOdr(t *testing.T, protocol int, fn odrTestFn) {
t.Skip("OVM breaks this with `insufficient balance for transfer`, probably because transfers don't work.")
var (
sdb = rawdb.NewMemoryDatabase()
ldb = rawdb.NewMemoryDatabase()
......
......@@ -197,6 +197,12 @@ type Transaction struct {
tx *types.Transaction
}
// NewContractCreation creates a new transaction for deploying a new contract with
// the given properties.
func NewContractCreation(nonce int64, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction {
return &Transaction{types.NewContractCreation(uint64(nonce), amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
}
// NewTransaction creates a new transaction with the given properties. Contracts
// can be created by transacting with a nil recipient.
func NewTransaction(nonce int64, to *Address, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction {
......
......@@ -77,7 +77,6 @@ func TestDatadirCreation(t *testing.T) {
// Tests that IPC paths are correctly resolved to valid endpoints of different
// platforms.
func TestIPCPathResolution(t *testing.T) {
t.Skip("Skipping for now")
var tests = []struct {
DataDir string
IPCPath string
......
......@@ -226,6 +226,18 @@ var (
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, new(EthashConfig), nil}
TestRules = TestChainConfig.Rules(new(big.Int))
// OpMainnetChainID is the ID of Optimism's mainnet chain.
OpMainnetChainID = big.NewInt(10)
// OpKovanChainID is the ID of Optimism's Kovan testnet chain.
OpKovanChainID = big.NewInt(69)
// OpMainnetSDUpdateForkNum is the height at which the SD update fork activates on Mainnet.
OpMainnetSDUpdateForkNum = big.NewInt(3135900)
// OpKovanSDUpdateForkNum is the height at which the SD update fork activates on Kovan.
OpKovanSDUpdateForkNum = big.NewInt(1094820)
)
// TrustedCheckpoint represents a set of post-processed trie roots (CHT and
......@@ -414,6 +426,17 @@ func (c *ChainConfig) IsEWASM(num *big.Int) bool {
return isForked(c.EWASMBlock, num)
}
// IsSDUpdate returns whether num represents a block number after the SD update fork
func (c *ChainConfig) IsSDUpdate(num *big.Int) bool {
if c.ChainID.Cmp(OpMainnetChainID) == 0 {
return isForked(OpMainnetSDUpdateForkNum, num)
}
if c.ChainID.Cmp(OpKovanChainID) == 0 {
return isForked(OpKovanSDUpdateForkNum, num)
}
return true
}
// CheckCompatible checks whether scheduled fork transitions have been imported
// with a mismatching chain configuration.
func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64) *ConfigCompatError {
......
......@@ -306,7 +306,7 @@ func TestClientSubscribeClose(t *testing.T) {
}
}
// This test reproduces https://github.com/ethereum-optimism/optimism/l2geth/issues/17837 where the
// This test reproduces https://github.com/ethereum/go-ethereum/issues/17837 where the
// client hangs during shutdown when Unsubscribe races with Client.Close.
func TestClientCloseUnsubscribeRace(t *testing.T) {
server := newTestServer()
......
......@@ -99,7 +99,7 @@ Subscriptions are deleted when the user sends an unsubscribe request or when the
connection which was used to create the subscription is closed. This can be initiated by
the client and server. The server will close the connection for any write error.
For more information about subscriptions, see https://github.com/ethereum-optimism/optimism/l2geth/wiki/RPC-PUB-SUB.
For more information about subscriptions, see https://github.com/ethereum/go-ethereum/wiki/RPC-PUB-SUB.
Reverse Calls
......
......@@ -136,7 +136,7 @@ func TestClientWebsocketPing(t *testing.T) {
}
// Wait for the context's deadline to be reached before proceeding.
// This is important for reproducing https://github.com/ethereum-optimism/optimism/l2geth/issues/19798
// This is important for reproducing https://github.com/ethereum/go-ethereum/issues/19798
<-ctx.Done()
close(sendPing)
......
......@@ -612,7 +612,7 @@ func (api *SignerAPI) EcRecover(ctx context.Context, data hexutil.Bytes, sig hex
// Note, the signature must conform to the secp256k1 curve R, S and V values, where
// the V value must be be 27 or 28 for legacy reasons.
//
// https://github.com/ethereum-optimism/optimism/l2geth/wiki/Management-APIs#personal_ecRecover
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover
if len(sig) != 65 {
return common.Address{}, fmt.Errorf("signature must be 65 bytes long")
}
......
......@@ -49,7 +49,7 @@ func (db *Database) ValidateTransaction(selector *string, tx *core.SendTxArgs) (
if tx.To == nil {
// Contract creation should contain sufficient data to deploy a contract. A
// typical error is omitting sender due to some quirk in the javascript call
// e.g. https://github.com/ethereum-optimism/optimism/l2geth/issues/16106.
// e.g. https://github.com/ethereum/go-ethereum/issues/16106.
if len(data) == 0 {
// Prevent sending ether into black hole (show stopper)
if tx.Value.ToInt().Cmp(big.NewInt(0)) > 0 {
......
......@@ -17,7 +17,6 @@
package tests
import (
"fmt"
"testing"
)
......@@ -29,8 +28,6 @@ func TestBlockchain(t *testing.T) {
bt.skipLoad(`^GeneralStateTests/`)
// Skip random failures due to selfish mining test
bt.skipLoad(`.*bcForgedTest/bcForkUncle\.json`)
// Skip these tests because the OVM gas limit will be different
bt.skipLoad(`InvalidBlocks/bcInvalidHeaderTest/wrongGasLimit.json`)
// Slow tests
bt.slow(`.*bcExploitTest/DelegateCallSpam.json`)
......@@ -43,19 +40,12 @@ func TestBlockchain(t *testing.T) {
// Very slow test
bt.skipLoad(`.*/stTimeConsuming/.*`)
// OVM breaks these tests
bt.skipLoad(`^InvalidBlocks`)
bt.skipLoad(`^ValidBlocks`)
bt.skipLoad(`^TransitionTests`)
bt.skipLoad(`^randomStatetest391.json`)
// test takes a lot for time and goes easily OOM because of sha3 calculation on a huge range,
// using 4.6 TGas
bt.skipLoad(`.*randomStatetest94.json.*`)
bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) {
if err := bt.checkFailure(t, name, test.Run()); err != nil {
fmt.Println("******* NAME: ", name)
t.Error(err)
}
})
......
......@@ -44,9 +44,6 @@ func TestState(t *testing.T) {
// Very time consuming
st.skipLoad(`^stTimeConsuming/`)
// OVM changes break these tests
st.skipLoad(`^st`)
// Broken tests:
// Expected failures:
//st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/Byzantium/0`, "bug in test")
......
......@@ -45,7 +45,6 @@ func TestTransaction(t *testing.T) {
// Geth accepts it, which is not a consensus issue since we use big.Int's
// internally to calculate the cost
txt.skipLoad("^ttValue/TransactionWithHighValueOverflow.json")
txt.skipLoad("^ttSignature/TransactionWithTooManyRLPElements.json")
txt.walk(t, transactionTestDir, func(t *testing.T, name string, test *TransactionTest) {
cfg := params.MainnetChainConfig
if err := txt.checkFailure(t, name, test.Run(cfg)); err != nil {
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
/* Library Imports */
import { Lib_RLPReader } from "../rlp/Lib_RLPReader.sol";
/**
* @title Lib_CrossDomainUtils
*/
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract Helper_GasMeasurer {
function measureCallGas(address _target, bytes memory _data) public returns (uint256) {
uint256 gasBefore;
uint256 gasAfter;
uint256 calldataStart;
uint256 calldataLength;
assembly {
calldataStart := add(_data, 0x20)
calldataLength := mload(_data)
}
bool success;
assembly {
gasBefore := gas()
success := call(gas(), _target, 0, calldataStart, calldataLength, 0, 0)
gasAfter := gas()
}
require(success, "Call failed, but calls we want to measure gas for should succeed!");
return gasBefore - gasAfter;
}
}
......@@ -6,7 +6,7 @@
*This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed behind a proxy. Since a proxied contract can&#39;t have a constructor, it&#39;s common to move constructor logic to an external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.*
*This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed behind a proxy. Since a proxied contract can&#39;t have a constructor, it&#39;s common to move constructor logic to an external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. [CAUTION] ==== Avoid leaving a contract uninitialized. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: [.hljs-theme-light.nopadding] ```*
import { ethers } from 'hardhat'
import { Contract, Signer } from 'ethers'
export class GasMeasurement {
GasMeasurementContract: Contract
public async init(wallet: Signer) {
this.GasMeasurementContract = await (
await (await ethers.getContractFactory('Helper_GasMeasurer')).deploy()
).connect(wallet)
}
public async getGasCost(
targetContract: Contract,
methodName: string,
methodArgs: Array<any> = []
): Promise<number> {
const gasCost: number =
await this.GasMeasurementContract.callStatic.measureCallGas(
targetContract.address,
targetContract.interface.encodeFunctionData(methodName, methodArgs)
)
return gasCost
}
}
......@@ -5,4 +5,3 @@ export * from './utils'
export * from './codec'
export * from './test-runner'
export * from './trie'
export * from './gas'
......@@ -340,6 +340,9 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> {
const blockNumber = Math.max(0, tip - this.options.confirmations)
const block = await this.state.l1RpcProvider.getBlock(blockNumber)
if (block === null) {
throw new Error(`Cannot GET /eth/context/latest at ${blockNumber}`)
}
return {
blockNumber: block.number,
......@@ -366,6 +369,10 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> {
}
const block = await this.state.l1RpcProvider.getBlock(number)
if (block === null) {
throw new Error(`Cannot GET /eth/context/blocknumber/${number}`)
}
return {
blockNumber: block.number,
timestamp: block.timestamp,
......
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