diff --git a/l2geth/.dockerignore b/l2geth/.dockerignore deleted file mode 100644 index 0c013d18b13f..000000000000 --- a/l2geth/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -**/*_test.go - -build/_workspace -build/_bin -tests/testdata diff --git a/l2geth/.gitattributes b/l2geth/.gitattributes deleted file mode 100644 index 0269fab9cba2..000000000000 --- a/l2geth/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto -*.sol linguist-language=Solidity diff --git a/l2geth/.gitmodules b/l2geth/.gitmodules deleted file mode 100644 index 32bdb3b6e5a6..000000000000 --- a/l2geth/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "tests"] - path = tests/testdata - url = https://github.com/ethereum/tests diff --git a/l2geth/.mailmap b/l2geth/.mailmap deleted file mode 100644 index cc4b871a3cb5..000000000000 --- a/l2geth/.mailmap +++ /dev/null @@ -1,123 +0,0 @@ -Jeffrey Wilcke -Jeffrey Wilcke -Jeffrey Wilcke -Jeffrey Wilcke - -Viktor Trón - -Joseph Goulden - -Nick Savers - -Maran Hidskes - -Taylor Gerring -Taylor Gerring - -Bas van Kervel -Bas van Kervel -Bas van Kervel -Bas van Kervel - -Sven Ehlert - -Vitalik Buterin - -Marian Oancea - -Christoph Jentzsch - -Heiko Hees - -Alex Leverington -Alex Leverington - -Zsolt Felföldi - -Gavin Wood - -Martin Becze -Martin Becze - -Dimitry Khokhlov - -Roman Mandeleil - -Alec Perseghin - -Alon Muroch - -Arkadiy Paronyan - -Jae Kwon - -Aaron Kumavis - -Nick Dodson - -Jason Carver -Jason Carver - -Joseph Chow -Joseph Chow ethers - -Enrique Fynn - -Vincent G - -RJ Catalano -RJ Catalano - -Nchinda Nchinda - -Aron Fischer - -Vlad Gluhovsky - -Ville Sundell - -Elliot Shepherd - -Yohann Léon - -Gregg Dourgarian - -Casey Detrio - -Jens Agerberg - -Nick Johnson - -Henning Diedrich -Henning Diedrich Drake Burroughs - -Felix Lange -Felix Lange - -Максим Чусовлянов - -Louis Holbrook -Louis Holbrook - -Thomas Bocek - -Victor Tran - -Justin Drake - -Frank Wang - -Gary Rong - -Guillaume Nicolas - -Sorin Neacsu -Sorin Neacsu - -Valentin Wüstholz -Valentin Wüstholz - -Armin Braun - -Ernesto del Toro -Ernesto del Toro diff --git a/l2geth/Dockerfile b/l2geth/Dockerfile deleted file mode 100644 index 84874a1c1b75..000000000000 --- a/l2geth/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -# Build Geth in a stock Go builder container -FROM golang:1.14-alpine as builder - -RUN apk add --no-cache make gcc musl-dev linux-headers git - -ADD . /go-ethereum -RUN cd /go-ethereum && make geth - -# Pull Geth into a second stage deploy alpine container -FROM alpine:latest - -RUN apk add --no-cache ca-certificates -COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/ - -EXPOSE 8545 8546 8547 30303 30303/udp - -COPY docker/entrypoint.sh /bin -COPY docker/state_dump_entrypoint.sh /bin -RUN chmod +x /bin/entrypoint.sh \ - && chmod +x /bin/state_dump_entrypoint.sh - -ENTRYPOINT ["sh", "/bin/entrypoint.sh"] diff --git a/l2geth/Dockerfile.alltools b/l2geth/Dockerfile.alltools deleted file mode 100644 index 9c28979a1e91..000000000000 --- a/l2geth/Dockerfile.alltools +++ /dev/null @@ -1,15 +0,0 @@ -# Build Geth in a stock Go builder container -FROM golang:1.14-alpine as builder - -RUN apk add --no-cache make gcc musl-dev linux-headers git - -ADD . /go-ethereum -RUN cd /go-ethereum && make all - -# Pull all binaries into a second stage deploy alpine container -FROM alpine:latest - -RUN apk add --no-cache ca-certificates -COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/ - -EXPOSE 8545 8546 8547 30303 30303/udp diff --git a/l2geth/Dockerfile.dev b/l2geth/Dockerfile.dev deleted file mode 100644 index e2bcdbe5ca51..000000000000 --- a/l2geth/Dockerfile.dev +++ /dev/null @@ -1,12 +0,0 @@ -# Requires the root repo dir to be mounted at /mnt/go-ethereum in order to run this! -FROM golang:1.14-alpine - -RUN apk add --no-cache make gcc musl-dev linux-headers git -RUN apk add --no-cache ca-certificates - -EXPOSE 8545 8546 8547 30303 30303/udp - -# Used to mount the code so image isn't re-built every time code changes -WORKDIR /mnt/go-ethereum - -ENTRYPOINT ["sh", "./docker/dev_entrypoint.sh"] diff --git a/l2geth/Dockerfile.test b/l2geth/Dockerfile.test deleted file mode 100644 index c5659715c6ee..000000000000 --- a/l2geth/Dockerfile.test +++ /dev/null @@ -1,13 +0,0 @@ -FROM golang:1.14-alpine - -RUN apk add --no-cache make gcc musl-dev linux-headers git - -ENV GO111MODULE=on - -COPY . /go-ethereum -RUN cd /go-ethereum && go run build/ci.go install - -COPY docker/test_entrypoint.sh /bin -RUN chmod +x /bin/test_entrypoint.sh - -ENTRYPOINT ["sh", "/bin/test_entrypoint.sh"] diff --git a/l2geth/Dockerfile.test.dockerignore b/l2geth/Dockerfile.test.dockerignore deleted file mode 100644 index fdf3a954ceb6..000000000000 --- a/l2geth/Dockerfile.test.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -build/_workspace -build/_bin diff --git a/l2geth/appveyor.yml b/l2geth/appveyor.yml deleted file mode 100644 index fe15cc7f0ea3..000000000000 --- a/l2geth/appveyor.yml +++ /dev/null @@ -1,41 +0,0 @@ -os: Visual Studio 2015 - -# Clone directly into GOPATH. -clone_folder: C:\gopath\src\github.com\ethereum\go-ethereum -clone_depth: 5 -version: "{branch}.{build}" -environment: - global: - GO111MODULE: on - GOPATH: C:\gopath - CC: gcc.exe - matrix: - - GETH_ARCH: amd64 - MSYS2_ARCH: x86_64 - MSYS2_BITS: 64 - MSYSTEM: MINGW64 - PATH: C:\msys64\mingw64\bin\;C:\Program Files (x86)\NSIS\;%PATH% - - GETH_ARCH: 386 - MSYS2_ARCH: i686 - MSYS2_BITS: 32 - MSYSTEM: MINGW32 - PATH: C:\msys64\mingw32\bin\;C:\Program Files (x86)\NSIS\;%PATH% - -install: - - git submodule update --init - - rmdir C:\go /s /q - - appveyor DownloadFile https://dl.google.com/go/go1.14.2.windows-%GETH_ARCH%.zip - - 7z x go1.14.2.windows-%GETH_ARCH%.zip -y -oC:\ > NUL - - go version - - gcc --version - -build_script: - - go run build\ci.go install - -after_build: - - go run build\ci.go archive -type zip -signer WINDOWS_SIGNING_KEY -upload gethstore/builds - - go run build\ci.go nsis -signer WINDOWS_SIGNING_KEY -upload gethstore/builds - -test_script: - - set CGO_ENABLED=1 - - go run build\ci.go test -coverage diff --git a/l2geth/circle.yml b/l2geth/circle.yml deleted file mode 100644 index 39ff5d83c68e..000000000000 --- a/l2geth/circle.yml +++ /dev/null @@ -1,32 +0,0 @@ -machine: - services: - - docker - -dependencies: - cache_directories: - - "~/.ethash" # Cache the ethash DAG generated by hive for consecutive builds - - "~/.docker" # Cache all docker images manually to avoid lengthy rebuilds - override: - # Restore all previously cached docker images - - mkdir -p ~/.docker - - for img in `ls ~/.docker`; do docker load -i ~/.docker/$img; done - - # Pull in and hive, restore cached ethash DAGs and do a dry run - - go get -u github.com/karalabe/hive - - (cd ~/.go_workspace/src/github.com/karalabe/hive && mkdir -p workspace/ethash/ ~/.ethash) - - (cd ~/.go_workspace/src/github.com/karalabe/hive && cp -r ~/.ethash/. workspace/ethash/) - - (cd ~/.go_workspace/src/github.com/karalabe/hive && hive --docker-noshell --client=NONE --test=. --sim=. --loglevel=6) - - # Cache all the docker images and the ethash DAGs - - for img in `docker images | grep -v "^" | tail -n +2 | awk '{print $1}'`; do docker save $img > ~/.docker/`echo $img | tr '/' ':'`.tar; done - - cp -r ~/.go_workspace/src/github.com/karalabe/hive/workspace/ethash/. ~/.ethash - -test: - override: - # Build Geth and move into a known folder - - make geth - - cp ./build/bin/geth $HOME/geth - - # Run hive and move all generated logs into the public artifacts folder - - (cd ~/.go_workspace/src/github.com/karalabe/hive && hive --docker-noshell --client=go-ethereum:local --override=$HOME/geth --test=. --sim=.) - - cp -r ~/.go_workspace/src/github.com/karalabe/hive/workspace/logs/* $CIRCLE_ARTIFACTS diff --git a/l2geth/cmd/geth/consolecmd_test.go b/l2geth/cmd/geth/consolecmd_test.go index a31c88a65c1a..b16819e4f45a 100644 --- a/l2geth/cmd/geth/consolecmd_test.go +++ b/l2geth/cmd/geth/consolecmd_test.go @@ -31,7 +31,7 @@ import ( ) const ( - ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rollup:1.0 rollup_personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0" + ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rollup:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0" httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0" ) diff --git a/l2geth/cmd/geth/main.go b/l2geth/cmd/geth/main.go index ff0ad41f306f..56f557661126 100644 --- a/l2geth/cmd/geth/main.go +++ b/l2geth/cmd/geth/main.go @@ -164,7 +164,6 @@ var ( utils.RollupStateDumpPathFlag, utils.RollupDiffDbFlag, utils.RollupMaxCalldataSizeFlag, - utils.RollupL1GasPriceFlag, } rpcFlags = []cli.Flag{ diff --git a/l2geth/cmd/geth/usage.go b/l2geth/cmd/geth/usage.go index c59d214dbf5a..0d81d7a1365b 100644 --- a/l2geth/cmd/geth/usage.go +++ b/l2geth/cmd/geth/usage.go @@ -78,7 +78,6 @@ var AppHelpFlagGroups = []flagGroup{ utils.RollupStateDumpPathFlag, utils.RollupDiffDbFlag, utils.RollupMaxCalldataSizeFlag, - utils.RollupL1GasPriceFlag, }, }, { diff --git a/l2geth/cmd/utils/flags.go b/l2geth/cmd/utils/flags.go index 432599ae4b86..0db507395018 100644 --- a/l2geth/cmd/utils/flags.go +++ b/l2geth/cmd/utils/flags.go @@ -879,12 +879,6 @@ var ( Value: eth.DefaultConfig.Rollup.MaxCallDataSize, EnvVar: "ROLLUP_MAX_CALLDATA_SIZE", } - RollupL1GasPriceFlag = BigFlag{ - Name: "rollup.l1gasprice", - Usage: "The L1 gas price to use for the sequencer fees", - Value: eth.DefaultConfig.Rollup.L1GasPrice, - EnvVar: "ROLLUP_L1_GASPRICE", - } ) // MakeDataDir retrieves the currently requested data directory, terminating @@ -1158,9 +1152,6 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) { if ctx.GlobalIsSet(RollupTimstampRefreshFlag.Name) { cfg.TimestampRefreshThreshold = ctx.GlobalDuration(RollupTimstampRefreshFlag.Name) } - if ctx.GlobalIsSet(RollupL1GasPriceFlag.Name) { - cfg.L1GasPrice = GlobalBig(ctx, RollupL1GasPriceFlag.Name) - } } // setLes configures the les server and ultra light client settings from the command line flags. diff --git a/l2geth/core/rollup_fee.go b/l2geth/core/rollup_fee.go deleted file mode 100644 index 7f0e6208c818..000000000000 --- a/l2geth/core/rollup_fee.go +++ /dev/null @@ -1,22 +0,0 @@ -package core - -import ( - "math/big" -) - -/// ROLLUP_BASE_TX_SIZE is the encoded rollup transaction's compressed size excluding -/// the variable length data. -/// Ref: https://github.com/ethereum-optimism/contracts/blob/409f190518b90301db20d0d4f53760021bc203a8/contracts/optimistic-ethereum/OVM/precompiles/OVM_SequencerEntrypoint.sol#L47 -const ROLLUP_BASE_TX_SIZE int = 96 - -/// CalculateFee calculates the fee that must be paid to the Rollup sequencer, taking into -/// account the cost of publishing data to L1. -/// Returns: (ROLLUP_BASE_TX_SIZE + len(data)) * dataPrice + executionPrice * gasUsed -func CalculateRollupFee(data []byte, gasUsed uint64, dataPrice, executionPrice *big.Int) *big.Int { - dataLen := int64(ROLLUP_BASE_TX_SIZE + len(data)) - // get the data fee - dataFee := new(big.Int).Mul(dataPrice, big.NewInt(dataLen)) - executionFee := new(big.Int).Mul(executionPrice, new(big.Int).SetUint64(gasUsed)) - fee := new(big.Int).Add(dataFee, executionFee) - return fee -} diff --git a/l2geth/core/rollup_fee_test.go b/l2geth/core/rollup_fee_test.go deleted file mode 100644 index 3ae86dd1bae2..000000000000 --- a/l2geth/core/rollup_fee_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package core - -import ( - "math/big" - "testing" -) - -var feeTests = map[string]struct { - dataLen int - gasUsed uint64 - dataPrice int64 - executionPrice int64 -}{ - "simple": {10000, 10, 20, 30}, - "zero gas used": {10000, 0, 20, 30}, - "zero data price": {10000, 0, 0, 30}, - "zero execution price": {10000, 0, 0, 0}, -} - -func TestCalculateRollupFee(t *testing.T) { - for name, tt := range feeTests { - t.Run(name, func(t *testing.T) { - data := make([]byte, 0, tt.dataLen) - fee := CalculateRollupFee(data, tt.gasUsed, big.NewInt(tt.dataPrice), big.NewInt(tt.executionPrice)) - - dataFee := uint64((ROLLUP_BASE_TX_SIZE + len(data)) * int(tt.dataPrice)) - executionFee := uint64(tt.executionPrice) * tt.gasUsed - expectedFee := dataFee + executionFee - if fee.Cmp(big.NewInt(int64(expectedFee))) != 0 { - t.Errorf("rollup fee check failed: expected %d, got %s", expectedFee, fee.String()) - } - }) - } -} diff --git a/l2geth/core/tx_pool.go b/l2geth/core/tx_pool.go index 281da9fe6a80..a5a581c83c71 100644 --- a/l2geth/core/tx_pool.go +++ b/l2geth/core/tx_pool.go @@ -92,9 +92,8 @@ var ( ) var ( - evictionInterval = time.Minute // Time interval to check for evictable transactions - statsReportInterval = 8 * time.Second // Time interval to report transaction pool stats - gwei = big.NewInt(params.GWei) // 1 gwei, used as a flag for "rollup" transactions + evictionInterval = time.Minute // Time interval to check for evictable transactions + statsReportInterval = 8 * time.Second // Time interval to report transaction pool stats ) var ( @@ -538,14 +537,10 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { if tx.Value().Sign() < 0 { return ErrNegativeValue } - // Ensure the transaction doesn't exceed the current block limit gas. - // We skip this condition check if the transaction's gasPrice is set to 1gwei, - // which indicates a "rollup" transaction that's paying for its data. - if pool.currentMaxGas < tx.Gas() && tx.GasPrice().Cmp(gwei) != 0 { + if pool.currentMaxGas < tx.Gas() { return ErrGasLimit } - // Make sure the transaction is signed properly from, err := types.Sender(pool.signer, tx) if err != nil { @@ -590,7 +585,6 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { // whitelisted, preventing any associated transaction from being dropped out of the pool // due to pricing constraints. func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err error) { - log.Debug("received tx", "gas", tx.Gas(), "gasprice", tx.GasPrice().Uint64()) // If the transaction is already known, discard it hash := tx.Hash() if pool.all.Get(hash) != nil { @@ -598,7 +592,6 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e knownTxMeter.Mark(1) return false, fmt.Errorf("known transaction: %x", hash) } - // If the transaction fails basic validation, discard it if err := pool.validateTx(tx, local); err != nil { log.Trace("Discarding invalid transaction", "hash", hash, "err", err) diff --git a/l2geth/eth/api_backend.go b/l2geth/eth/api_backend.go index bd242e7274cf..c592698364c2 100644 --- a/l2geth/eth/api_backend.go +++ b/l2geth/eth/api_backend.go @@ -46,7 +46,6 @@ type EthAPIBackend struct { extRPCEnabled bool eth *Ethereum gpo *gasprice.Oracle - l1gpo *gasprice.L1Oracle verifier bool gasLimit uint64 UsingOVM bool @@ -372,14 +371,6 @@ func (b *EthAPIBackend) SuggestPrice(ctx context.Context) (*big.Int, error) { return b.gpo.SuggestPrice(ctx) } -func (b *EthAPIBackend) SuggestDataPrice(ctx context.Context) (*big.Int, error) { - return b.l1gpo.SuggestDataPrice(ctx) -} - -func (b *EthAPIBackend) SetL1GasPrice(ctx context.Context, gasPrice *big.Int) { - b.l1gpo.SetL1GasPrice(gasPrice) -} - func (b *EthAPIBackend) ChainDb() ethdb.Database { return b.eth.ChainDb() } diff --git a/l2geth/eth/api_backend_test.go b/l2geth/eth/api_backend_test.go index 3f4d916834b4..7f84758c6c86 100644 --- a/l2geth/eth/api_backend_test.go +++ b/l2geth/eth/api_backend_test.go @@ -15,7 +15,6 @@ func TestGasLimit(t *testing.T) { extRPCEnabled: false, eth: nil, gpo: nil, - l1gpo: nil, verifier: false, gasLimit: 0, UsingOVM: true, diff --git a/l2geth/eth/backend.go b/l2geth/eth/backend.go index 657422cb7c7f..ba3f43eca105 100644 --- a/l2geth/eth/backend.go +++ b/l2geth/eth/backend.go @@ -226,17 +226,13 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { eth.miner = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock) eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData)) - log.Info("Backend Config", "max-calldata-size", config.Rollup.MaxCallDataSize, "gas-limit", config.Rollup.GasLimit, "is-verifier", config.Rollup.IsVerifier, "using-ovm", vm.UsingOVM, "l1-gasprice", config.Rollup.L1GasPrice) - eth.APIBackend = &EthAPIBackend{ctx.ExtRPCEnabled(), eth, nil, nil, config.Rollup.IsVerifier, config.Rollup.GasLimit, vm.UsingOVM, config.Rollup.MaxCallDataSize} + log.Info("Backend Config", "max-calldata-size", config.Rollup.MaxCallDataSize, "gas-limit", config.Rollup.GasLimit, "is-verifier", config.Rollup.IsVerifier, "using-ovm", vm.UsingOVM) + eth.APIBackend = &EthAPIBackend{ctx.ExtRPCEnabled(), eth, nil, config.Rollup.IsVerifier, config.Rollup.GasLimit, vm.UsingOVM, config.Rollup.MaxCallDataSize} gpoParams := config.GPO if gpoParams.Default == nil { gpoParams.Default = config.Miner.GasPrice } eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams) - // create the L1 GPO and allow the API backend and the sync service to access it - l1Gpo := gasprice.NewL1Oracle(config.Rollup.L1GasPrice) - eth.APIBackend.l1gpo = l1Gpo - eth.syncService.L1gpo = l1Gpo return eth, nil } diff --git a/l2geth/eth/config.go b/l2geth/eth/config.go index 56ae60837b42..63b0e1ad091d 100644 --- a/l2geth/eth/config.go +++ b/l2geth/eth/config.go @@ -81,7 +81,6 @@ var DefaultConfig = Config{ // is additional overhead that is unaccounted. Round down to 127000 for // safety. MaxCallDataSize: 127000, - L1GasPrice: big.NewInt(100 * params.GWei), }, DiffDbCache: 256, } diff --git a/l2geth/eth/gasprice/l1_gasprice.go b/l2geth/eth/gasprice/l1_gasprice.go deleted file mode 100644 index b6870c3e6bf0..000000000000 --- a/l2geth/eth/gasprice/l1_gasprice.go +++ /dev/null @@ -1,24 +0,0 @@ -package gasprice - -import ( - "context" - "math/big" -) - -type L1Oracle struct { - gasPrice *big.Int -} - -func NewL1Oracle(gasPrice *big.Int) *L1Oracle { - return &L1Oracle{gasPrice} -} - -/// SuggestDataPrice returns the gas price which should be charged per byte of published -/// data by the sequencer. -func (gpo *L1Oracle) SuggestDataPrice(ctx context.Context) (*big.Int, error) { - return gpo.gasPrice, nil -} - -func (gpo *L1Oracle) SetL1GasPrice(gasPrice *big.Int) { - gpo.gasPrice = gasPrice -} diff --git a/l2geth/go.mod b/l2geth/go.mod index 47277f950dba..6026ad14facc 100644 --- a/l2geth/go.mod +++ b/l2geth/go.mod @@ -32,7 +32,6 @@ require ( github.com/huin/goupnp v1.0.0 github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883 github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 - github.com/jarcoal/httpmock v1.0.8 github.com/jmoiron/sqlx v1.2.0 github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21 github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356 diff --git a/l2geth/go.sum b/l2geth/go.sum index 5c53cca7b501..d0ac6c0f91f6 100644 --- a/l2geth/go.sum +++ b/l2geth/go.sum @@ -108,8 +108,6 @@ github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883 h1:FSeK4fZCo github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 h1:6OvNmYgJyexcZ3pYbTI9jWx5tHo1Dee/tWbLMfPe2TA= github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= -github.com/jarcoal/httpmock v1.0.8 h1:8kI16SoO6LQKgPE7PvQuV+YuD/inwHd7fOOe2zMbo4k= -github.com/jarcoal/httpmock v1.0.8/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA= diff --git a/l2geth/internal/ethapi/api.go b/l2geth/internal/ethapi/api.go index a987112216a6..aa7ba45200c8 100644 --- a/l2geth/internal/ethapi/api.go +++ b/l2geth/internal/ethapi/api.go @@ -63,9 +63,10 @@ func NewPublicEthereumAPI(b Backend) *PublicEthereumAPI { return &PublicEthereumAPI{b} } -// GasPrice always returns 1 gwei. See `DoEstimateGas` below for context. +// GasPrice returns a suggestion for a gas price. func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { - return (*hexutil.Big)(big.NewInt(defaultGasPrice)), nil + price, err := s.b.SuggestPrice(ctx) + return (*hexutil.Big)(price), err } // ProtocolVersion returns the current Ethereum protocol version this node supports @@ -995,120 +996,74 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOr return (hexutil.Bytes)(result), err } -// Optimism note: The gasPrice in Optimism is modified to always return 1 gwei. We -// use the gasLimit field to communicate the entire user fee. This is done for -// for compatibility reasons with the existing Ethereum toolchain, so that the user -// fees can compensate for the additional costs the sequencer pays for publishing the -// transaction calldata func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap *big.Int) (hexutil.Uint64, error) { - if args.Data == nil { - return 0, errors.New("transaction data cannot be nil") - } - - // 1. get the gas that would be used by the transaction - gasUsed, err := legacyDoEstimateGas(ctx, b, args, blockNrOrHash, gasCap) + // // Binary search the gas requirement, as it may be higher than the amount used + // var ( + // lo uint64 = params.TxGas - 1 + // hi uint64 + // cap uint64 + // ) + // if args.Gas != nil && uint64(*args.Gas) >= params.TxGas { + // hi = uint64(*args.Gas) + // } else { + // // Retrieve the block to act as the gas ceiling + // block, err := b.BlockByNumberOrHash(ctx, blockNrOrHash) + // if err != nil { + // return 0, err + // } + // hi = block.GasLimit() + // } + // if gasCap != nil && hi > gasCap.Uint64() { + // log.Warn("Caller gas above allowance, capping", "requested", hi, "cap", gasCap) + // hi = gasCap.Uint64() + // } + // cap = hi + + // // Set sender address or use a default if none specified + // if args.From == nil { + // if wallets := b.AccountManager().Wallets(); len(wallets) > 0 { + // if accounts := wallets[0].Accounts(); len(accounts) > 0 { + // args.From = &accounts[0].Address + // } + // } + // } + // // Use zero-address if none other is available + // if args.From == nil { + // args.From = &common.Address{} + // } + // // Create a helper to check if a gas allowance results in an executable transaction + // executable := func(gas uint64) bool { + // args.Gas = (*hexutil.Uint64)(&gas) + + // _, _, failed, err := DoCall(ctx, b, args, blockNrOrHash, nil, vm.Config{}, 0, gasCap) + // if err != nil || failed { + // return false + // } + // return true + // } + // // Execute the binary search and hone in on an executable gas limit + // for lo+1 < hi { + // mid := (hi + lo) / 2 + // if !executable(mid) { + // lo = mid + // } else { + // hi = mid + // } + // } + + // // Reject the transaction as invalid if it still fails at the highest allowance + // if hi == cap { + // if !executable(hi) { + // return 0, fmt.Errorf("gas required exceeds allowance (%d) or always failing transaction", cap) + // } + // } + // return hexutil.Uint64(hi), nil + + block, err := b.BlockByNumberOrHash(ctx, blockNrOrHash) if err != nil { return 0, err } - - // 2a. fetch the data price, depends on how the sequencer has chosen to update their values based on the - // l1 gas prices - dataPrice, err := b.SuggestDataPrice(ctx) - if err != nil { - return 0, err - } - - // 2b. fetch the execution gas price, by the typical mempool dynamics - executionPrice, err := b.SuggestPrice(ctx) - if err != nil { - return 0, err - } - - // 3. calculate the fee and normalize by the default gas price - fee := core.CalculateRollupFee(*args.Data, uint64(gasUsed), dataPrice, executionPrice).Uint64() / defaultGasPrice - return (hexutil.Uint64)(fee), nil -} - -func legacyDoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap *big.Int) (hexutil.Uint64, error) { - // Binary search the gas requirement, as it may be higher than the amount used - var ( - lo uint64 = params.TxGas - 1 - hi uint64 - cap uint64 - ) - if args.Gas != nil && uint64(*args.Gas) >= params.TxGas { - hi = uint64(*args.Gas) - } else { - // Retrieve the block to act as the gas ceiling - block, err := b.BlockByNumberOrHash(ctx, blockNrOrHash) - if err != nil { - return 0, err - } - hi = block.GasLimit() - } - if gasCap != nil && hi > gasCap.Uint64() { - log.Warn("Caller gas above allowance, capping", "requested", hi, "cap", gasCap) - hi = gasCap.Uint64() - } - cap = hi - - // Set sender address or use a default if none specified - if args.From == nil { - if wallets := b.AccountManager().Wallets(); len(wallets) > 0 { - if accounts := wallets[0].Accounts(); len(accounts) > 0 { - args.From = &accounts[0].Address - } - } - } - // Use zero-address if none other is available - if args.From == nil { - args.From = &common.Address{} - } - // Create a helper to check if a gas allowance results in an executable transaction - executable := func(gas uint64) bool { - args.Gas = (*hexutil.Uint64)(&gas) - - _, _, failed, err := DoCall(ctx, b, args, blockNrOrHash, nil, vm.Config{}, 0, gasCap) - if err != nil || failed { - return false - } - return true - } - // Execute the binary search and hone in on an executable gas limit - for lo+1 < hi { - mid := (hi + lo) / 2 - if !executable(mid) { - lo = mid - } else { - hi = mid - } - } - - // Fudging to account for gas required to verify signatures + pass around data. - // Specifically, this line accounts for the fact that there's a bit of computation performed in - // a "real" transaction that won't be covered by an eth_call: - // 1. Going into the OVM_SequencerEntrypoint. - // 2. Going into the OVM_ProxyEOA + OVM_ECDSAContractAccount. - // 3. Verify signatures in various places. - // eth_call skips all of this and therefore won't correctly estimate gas by default. We need to - // tweak the gas estimate to account for this discrepancy. Cost is quite high here because of - // the EVM limitation that CALL can only pass 63/64 of total gas available -- so most of this - // gas isn't actually spent during execution but needs to be provided to avoid a revert. - hi += 1000000 - if args.Data != nil { - hi += uint64(len([]byte(*args.Data))) * 128 - } - if hi > cap { - hi = cap - } - - // Reject the transaction as invalid if it still fails at the highest allowance - if hi == cap { - if !executable(hi) { - return 0, fmt.Errorf("gas required exceeds allowance (%d) or always failing transaction", cap) - } - } - return hexutil.Uint64(hi), nil + return hexutil.Uint64(block.GasLimit() - 1), nil } // EstimateGas returns an estimate of the amount of gas needed to execute the @@ -1967,24 +1922,6 @@ func (api *PublicRollupAPI) GetInfo(ctx context.Context) rollupInfo { } } -// PrivatelRollupAPI provides private RPC methods to control the sequencer. -// These methods can be abused by external users and must be considered insecure for use by untrusted users. -type PrivateRollupAPI struct { - b Backend -} - -// NewPrivateRollupAPI creates a new API definition for the rollup methods of the -// Ethereum service. -func NewPrivateRollupAPI(b Backend) *PrivateRollupAPI { - return &PrivateRollupAPI{b: b} -} - -// SetGasPrice sets the gas price to be used when quoting calldata publishing costs -// to users -func (api *PrivateRollupAPI) SetL1GasPrice(ctx context.Context, gasPrice hexutil.Big) { - api.b.SetL1GasPrice(ctx, (*big.Int)(&gasPrice)) -} - // PublicDebugAPI is the collection of Ethereum APIs exposed over the public // debugging endpoint. type PublicDebugAPI struct { diff --git a/l2geth/internal/ethapi/backend.go b/l2geth/internal/ethapi/backend.go index 734a83702fd1..0ff8643a25ce 100644 --- a/l2geth/internal/ethapi/backend.go +++ b/l2geth/internal/ethapi/backend.go @@ -94,8 +94,6 @@ type Backend interface { GetRollupContext() (uint64, uint64) GasLimit() uint64 GetDiff(*big.Int) (diffdb.Diff, error) - SuggestDataPrice(ctx context.Context) (*big.Int, error) - SetL1GasPrice(context.Context, *big.Int) } func GetAPIs(apiBackend Backend) []rpc.API { @@ -121,10 +119,6 @@ func GetAPIs(apiBackend Backend) []rpc.API { Version: "1.0", Service: NewPublicRollupAPI(apiBackend), Public: true, - }, { - Namespace: "rollup_personal", - Version: "1.0", - Service: NewPrivateRollupAPI(apiBackend), }, { Namespace: "txpool", Version: "1.0", diff --git a/l2geth/les/api_backend.go b/l2geth/les/api_backend.go index 75e30bbbd835..d0007cf92b2d 100644 --- a/l2geth/les/api_backend.go +++ b/l2geth/les/api_backend.go @@ -281,16 +281,6 @@ func (b *LesApiBackend) SuggestPrice(ctx context.Context) (*big.Int, error) { return b.gpo.SuggestPrice(ctx) } -// NB: Non sequencer nodes cannot suggest L1 gas prices. -func (b *LesApiBackend) SuggestDataPrice(ctx context.Context) (*big.Int, error) { - panic("SuggestDataPrice not implemented") -} - -// NB: Non sequencer nodes cannot set L1 gas prices. -func (b *LesApiBackend) SetL1GasPrice(ctx context.Context, gasPrice *big.Int) { - panic("SetL1GasPrice is not implemented") -} - func (b *LesApiBackend) ChainDb() ethdb.Database { return b.eth.chainDb } diff --git a/l2geth/mobile/android_test.go b/l2geth/mobile/android_test.go index a1ab1833d756..9465717dcc2c 100644 --- a/l2geth/mobile/android_test.go +++ b/l2geth/mobile/android_test.go @@ -155,7 +155,7 @@ public class AndroidTest extends InstrumentationTestCase { // // This method has been adapted from golang.org/x/mobile/bind/java/seq_test.go/runTest func TestAndroid(t *testing.T) { - t.Skip("OVM: Skipping Android Tests") + t.Skip("Skipping Android Test (OVM)") // Skip tests on Windows altogether if runtime.GOOS == "windows" { t.Skip("cannot test Android bindings on Windows, skipping") diff --git a/l2geth/rollup/client.go b/l2geth/rollup/client.go index d890d8e67821..bfa7952ce2e0 100644 --- a/l2geth/rollup/client.go +++ b/l2geth/rollup/client.go @@ -42,10 +42,6 @@ type SyncStatus struct { CurrentTransactionIndex uint64 `json:"currentTransactionIndex"` } -type L1GasPrice struct { - GasPrice string `json:"gasPrice"` -} - type transaction struct { Index uint64 `json:"index"` BatchIndex uint64 `json:"batchIndex"` @@ -96,7 +92,6 @@ type RollupClient interface { GetLatestEthContext() (*EthContext, error) GetLastConfirmedEnqueue() (*types.Transaction, error) SyncStatus() (*SyncStatus, error) - GetL1GasPrice() (*big.Int, error) } type Client struct { @@ -444,25 +439,3 @@ func (c *Client) SyncStatus() (*SyncStatus, error) { return status, nil } - -func (c *Client) GetL1GasPrice() (*big.Int, error) { - response, err := c.client.R(). - SetResult(&L1GasPrice{}). - Get("/eth/gasprice") - - if err != nil { - return nil, fmt.Errorf("Cannot fetch L1 gas price: %w", err) - } - - gasPriceResp, ok := response.Result().(*L1GasPrice) - if !ok { - return nil, fmt.Errorf("Cannot parse L1 gas price response") - } - - gasPrice, ok := new(big.Int).SetString(gasPriceResp.GasPrice, 10) - if !ok { - return nil, fmt.Errorf("Cannot parse response as big number") - } - - return gasPrice, nil -} diff --git a/l2geth/rollup/client_test.go b/l2geth/rollup/client_test.go deleted file mode 100644 index a391f6c87534..000000000000 --- a/l2geth/rollup/client_test.go +++ /dev/null @@ -1,43 +0,0 @@ -package rollup - -import ( - "fmt" - "math/big" - "testing" - - "github.com/jarcoal/httpmock" -) - -func TestRollupClientGetL1GasPrice(t *testing.T) { - url := "http://localhost:9999" - endpoint := fmt.Sprintf("%s/eth/gasprice", url) - // url/chain-id does not matter, we'll mock the responses - client := NewClient(url, big.NewInt(1)) - // activate the mock - httpmock.ActivateNonDefault(client.client.GetClient()) - - // The API responds with a string value - expectedGasPrice, _ := new(big.Int).SetString("123132132151245817421893", 10) - body := map[string]interface{}{ - "gasPrice": expectedGasPrice.String(), - } - response, _ := httpmock.NewJsonResponder( - 200, - body, - ) - httpmock.RegisterResponder( - "GET", - endpoint, - response, - ) - - gasPrice, err := client.GetL1GasPrice() - - if err != nil { - t.Fatal("could not get mocked gas price", err) - } - - if gasPrice.Cmp(expectedGasPrice) != 0 { - t.Fatal("gasPrice is not parsed properly in the client") - } -} diff --git a/l2geth/rollup/config.go b/l2geth/rollup/config.go index c79ee411cb5b..fe5855e97a90 100644 --- a/l2geth/rollup/config.go +++ b/l2geth/rollup/config.go @@ -33,6 +33,4 @@ type Config struct { PollInterval time.Duration // Interval for updating the timestamp TimestampRefreshThreshold time.Duration - // The gas price to use when estimating L1 calldata publishing costs - L1GasPrice *big.Int } diff --git a/l2geth/rollup/sync_service.go b/l2geth/rollup/sync_service.go index b38683448d65..19c74bc34e34 100644 --- a/l2geth/rollup/sync_service.go +++ b/l2geth/rollup/sync_service.go @@ -19,8 +19,6 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" - - "github.com/ethereum/go-ethereum/eth/gasprice" ) // OVMContext represents the blocknumber and timestamp @@ -44,7 +42,6 @@ type SyncService struct { eth1ChainId uint64 bc *core.BlockChain txpool *core.TxPool - L1gpo *gasprice.L1Oracle client RollupClient syncing atomic.Value OVMContext OVMContext @@ -360,14 +357,6 @@ func (s *SyncService) SequencerLoop() { } func (s *SyncService) sequence() error { - // Update to the latest L1 gas price - l1GasPrice, err := s.client.GetL1GasPrice() - if err != nil { - return err - } - s.L1gpo.SetL1GasPrice(l1GasPrice) - log.Info("Adjusted L1 Gas Price", "gasprice", l1GasPrice) - // Only the sequencer needs to poll for enqueue transactions // and then can choose when to apply them. We choose to apply // transactions such that it makes for efficient batch submitting. @@ -452,7 +441,6 @@ func (s *SyncService) updateContext() error { if err != nil { return err } - current := time.Unix(int64(s.GetLatestL1Timestamp()), 0) next := time.Unix(int64(context.Timestamp), 0) if next.Sub(current) > s.timestampRefreshThreshold { diff --git a/l2geth/rollup/sync_service_test.go b/l2geth/rollup/sync_service_test.go index 2f3a981682bd..017dfb6bf769 100644 --- a/l2geth/rollup/sync_service_test.go +++ b/l2geth/rollup/sync_service_test.go @@ -14,7 +14,6 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/eth/gasprice" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/params" ) @@ -151,37 +150,6 @@ func TestSyncServiceTransactionEnqueued(t *testing.T) { } } -func TestSyncServiceL1GasPrice(t *testing.T) { - service, _, _, err := newTestSyncService(true) - setupMockClient(service, map[string]interface{}{}) - service.L1gpo = gasprice.NewL1Oracle(big.NewInt(0)) - - if err != nil { - t.Fatal(err) - } - - gasBefore, err := service.L1gpo.SuggestDataPrice(context.Background()) - if err != nil { - t.Fatal(err) - } - - if gasBefore.Cmp(big.NewInt(0)) != 0 { - t.Fatal("expected 0 gas price, got", gasBefore) - } - - // run 1 iteration of the eloop - service.sequence() - - gasAfter, err := service.L1gpo.SuggestDataPrice(context.Background()) - if err != nil { - t.Fatal(err) - } - - if gasAfter.Cmp(big.NewInt(100*int64(params.GWei))) != 0 { - t.Fatal("expected 100 gas price, got", gasAfter) - } -} - // Pass true to set as a verifier func TestSyncServiceSync(t *testing.T) { service, txCh, sub, err := newTestSyncService(true) @@ -346,7 +314,6 @@ type mockClient struct { func setupMockClient(service *SyncService, responses map[string]interface{}) { client := newMockClient(responses) service.client = client - service.L1gpo = gasprice.NewL1Oracle(big.NewInt(0)) } func newMockClient(responses map[string]interface{}) *mockClient { @@ -433,7 +400,3 @@ func (m *mockClient) SyncStatus() (*SyncStatus, error) { Syncing: false, }, nil } - -func (m *mockClient) GetL1GasPrice() (*big.Int, error) { - return big.NewInt(100 * int64(params.GWei)), nil -}