From b952cdf49eb2a5fe0561371eaa9318a709707a7e Mon Sep 17 00:00:00 2001 From: StefanIliev545 Date: Mon, 15 Jan 2024 16:02:46 +0200 Subject: [PATCH] Deployment fix. --- go/config/enclave_cli_flags.go | 3 ++- go/enclave/components/batch_executor.go | 4 ---- go/enclave/evm/evm_facade.go | 7 +++++-- go/obsclient/authclient.go | 3 +++ integration/common/constants.go | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/go/config/enclave_cli_flags.go b/go/config/enclave_cli_flags.go index 586a9e7c2a..1c1ffcdfb2 100644 --- a/go/config/enclave_cli_flags.go +++ b/go/config/enclave_cli_flags.go @@ -1,6 +1,7 @@ package config import ( + "github.com/ethereum/go-ethereum/params" "github.com/ten-protocol/go-ten/go/common" "github.com/ten-protocol/go-ten/go/common/flag" ) @@ -53,7 +54,7 @@ var EnclaveFlags = map[string]*flag.TenFlag{ SequencerIDFlag: flag.NewStringFlag(SequencerIDFlag, "", "The 20 bytes of the address of the sequencer for this network"), MaxBatchSizeFlag: flag.NewUint64Flag(MaxBatchSizeFlag, 1024*25, "The maximum size a batch is allowed to reach uncompressed"), MaxRollupSizeFlag: flag.NewUint64Flag(MaxRollupSizeFlag, 1024*64, "The maximum size a rollup is allowed to reach"), - L2BaseFeeFlag: flag.NewUint64Flag(L2BaseFeeFlag, 1, ""), + L2BaseFeeFlag: flag.NewUint64Flag(L2BaseFeeFlag, params.InitialBaseFee, ""), L2CoinbaseFlag: flag.NewStringFlag(L2CoinbaseFlag, "0xd6C9230053f45F873Cb66D8A02439380a37A4fbF", ""), GasBatchExecutionLimit: flag.NewUint64Flag(GasBatchExecutionLimit, 30_000_000, "Max gas that can be executed in a single batch"), ObscuroGenesisFlag: flag.NewStringFlag(ObscuroGenesisFlag, "", "The json string with the obscuro genesis"), diff --git a/go/enclave/components/batch_executor.go b/go/enclave/components/batch_executor.go index 14f18ce464..327bcd4cb7 100644 --- a/go/enclave/components/batch_executor.go +++ b/go/enclave/components/batch_executor.go @@ -108,10 +108,6 @@ func (executor *batchExecutor) estimateL1Fees(stateDB *state.StateDB, context *B continue } - /*stateDB.SubBalance(*sender, cost) - stateDB.AddBalance(context.Creator, cost)*/ - // todo - add refund logic. - transactions = append(transactions, common.L2PricedTransaction{ Tx: tx, PublishingCost: big.NewInt(0).Set(cost), diff --git a/go/enclave/evm/evm_facade.go b/go/enclave/evm/evm_facade.go index 6bcd20358f..fc04248bd8 100644 --- a/go/enclave/evm/evm_facade.go +++ b/go/enclave/evm/evm_facade.go @@ -4,6 +4,9 @@ import ( "errors" "fmt" "math/big" + + // unsafe package imported in order to link to a private function in go-ethereum. + // This allows us to customize the message generated from a signed transaction and inject custom gas logic. _ "unsafe" "github.com/ethereum/go-ethereum/accounts/abi" @@ -130,10 +133,10 @@ func executeTransaction( if hasL1Cost { l1Gas.Div(l1cost, header.BaseFee) - l1Gas.Add(l1Gas, big.NewInt(1)) // account for leftover + l1Gas.Add(l1Gas, big.NewInt(1)) if msg.GasLimit < l1Gas.Uint64() { - return nil, fmt.Errorf("gas limit for tx too low. Want at least: %d have: %d", l1Gas, msg.GasLimit) + return nil, fmt.Errorf("gas limit set by user is too low to pay for execution and l1 fees. Want at least: %d have: %d", l1Gas, msg.GasLimit) } msg.GasLimit -= l1Gas.Uint64() diff --git a/go/obsclient/authclient.go b/go/obsclient/authclient.go index 46ab845e3f..2db0151f61 100644 --- a/go/obsclient/authclient.go +++ b/go/obsclient/authclient.go @@ -191,6 +191,9 @@ func (ac *AuthObsClient) EstimateGasAndGasPrice(txData types.TxData) types.TxDat gasPrice, err := ac.GasPrice(context.Background()) if err != nil { + // params.InitialBaseFee should be the new standard gas price. + // If the gas price is too low, then the gas required to be put in a transaction + // becomes astronomical. gasPrice = big.NewInt(params.InitialBaseFee) } diff --git a/integration/common/constants.go b/integration/common/constants.go index b21cb138b9..ef510672c5 100644 --- a/integration/common/constants.go +++ b/integration/common/constants.go @@ -76,7 +76,7 @@ func DefaultEnclaveConfig() *config.EnclaveConfig { EdgelessDBHost: "", SqliteDBPath: "", ProfilerEnabled: false, - MinGasPrice: big.NewInt(1), + MinGasPrice: big.NewInt(params.InitialBaseFee), SequencerID: gethcommon.BytesToAddress([]byte("")), ObscuroGenesis: "", DebugNamespaceEnabled: false,