diff --git a/bindings/hardhat/hardhat.go b/bindings/hardhat/hardhat.go index 64e0045eb..26a2d37a6 100644 --- a/bindings/hardhat/hardhat.go +++ b/bindings/hardhat/hardhat.go @@ -120,7 +120,7 @@ func (h *Hardhat) initSingleDeployment() error { entry["name"], ) } - //fmt.Println("=======>> init hardhat deployment instance:", deployment) + // fmt.Println("=======>> init hardhat deployment instance:", deployment) h.deployments = append(h.deployments, &deployment) knownDeployments[deployment.Name] = entry["name"].(string) diff --git a/bindings/solc/types.go b/bindings/solc/types.go index c982274a3..c242a9ac7 100644 --- a/bindings/solc/types.go +++ b/bindings/solc/types.go @@ -82,8 +82,10 @@ type CompilerOutputBytecode struct { LinkReferences LinkReferences `json:"linkReferences"` } -type LinkReferences map[string]LinkReference -type LinkReference map[string][]LinkReferenceOffset +type ( + LinkReferences map[string]LinkReference + LinkReference map[string][]LinkReferenceOffset +) type LinkReferenceOffset struct { Length uint `json:"length"` diff --git a/node/core/batch.go b/node/core/batch.go index 2ecb561ba..fd91b5cbf 100644 --- a/node/core/batch.go +++ b/node/core/batch.go @@ -102,7 +102,7 @@ func (e *Executor) CalculateCapWithProposalBlock(currentBlockBytes []byte, curre var txsPayload []byte var l1TxHashes []common.Hash - var totalL1MessagePopped = parentBatchHeader.TotalL1MessagePopped + totalL1MessagePopped := parentBatchHeader.TotalL1MessagePopped var lastHeightBeforeCurrentBatch uint64 var lastBlockStateRoot common.Hash var lastBlockWithdrawRoot common.Hash @@ -393,7 +393,7 @@ func (e *Executor) setCurrentBlock(currentBlockBytes []byte, currentTxs tmtypes. if err != nil { return err } - var curBlock = new(types.WrappedBlock) + curBlock := new(types.WrappedBlock) if err = curBlock.UnmarshalBinary(currentBlockBytes); err != nil { return err } @@ -496,7 +496,7 @@ func (e *Executor) ConvertBlsData(blsData l2node.BlsData) (*eth.BatchSignature, } func wrappedBlockFromBytes(blockBytes []byte) (*types.WrappedBlock, error) { - var curBlock = new(types.WrappedBlock) + curBlock := new(types.WrappedBlock) if err := curBlock.UnmarshalBinary(blockBytes); err != nil { return nil, err } diff --git a/node/core/config.go b/node/core/config.go index f14d66488..e255404fb 100644 --- a/node/core/config.go +++ b/node/core/config.go @@ -56,7 +56,7 @@ func (c *Config) SetCliContext(ctx *cli.Context) error { output := io.Writer(os.Stderr) if ctx.GlobalIsSet(flags.LogFilename.Name) { logFilename := ctx.GlobalString(flags.LogFilename.Name) - f, err := os.OpenFile(filepath.Clean(logFilename), os.O_CREATE|os.O_RDWR, os.FileMode(0600)) + f, err := os.OpenFile(filepath.Clean(logFilename), os.O_CREATE|os.O_RDWR, os.FileMode(0o600)) if err != nil { return fmt.Errorf("wrong log.filename set: %d", err) } @@ -114,7 +114,7 @@ func (c *Config) SetCliContext(ctx *cli.Context) error { if _, err := io.ReadFull(rand.Reader, secret[:]); err != nil { return fmt.Errorf("failed to generate jwt secret: %w", err) } - if err := os.WriteFile(fileName, []byte(hexutil.Encode(secret[:])), 0600); err != nil { + if err := os.WriteFile(fileName, []byte(hexutil.Encode(secret[:])), 0o600); err != nil { return err } } diff --git a/node/core/executor.go b/node/core/executor.go index 90f97e253..0d290d6d8 100644 --- a/node/core/executor.go +++ b/node/core/executor.go @@ -130,7 +130,7 @@ func NewExecutor(newSyncFunc NewSyncerFunc, config *Config, tmPubKey crypto.PubK if err != nil { return nil, err } - //executor.syncer.Start() + // executor.syncer.Start() executor.l1MsgReader = executor.syncer return executor, nil } @@ -324,7 +324,7 @@ func (e *Executor) DeliverBlock(txs [][]byte, metaData []byte, consensusData l2n // end block e.updateNextL1MessageIndex(l2Block) - var newValidatorSet = consensusData.ValidatorSet + newValidatorSet := consensusData.ValidatorSet var newBatchParams *tmproto.BatchParams if !e.devSequencer { if newValidatorSet, err = e.updateSequencerSet(); err != nil { diff --git a/node/core/l1_message.go b/node/core/l1_message.go index 83a7ec7c1..90b08aaa1 100644 --- a/node/core/l1_message.go +++ b/node/core/l1_message.go @@ -13,7 +13,6 @@ import ( func (e *Executor) updateNextL1MessageIndex(l2Block *catalyst.ExecutableL2Data) { e.nextL1MsgIndex = l2Block.NextL1MessageIndex e.metrics.NextL1MessageQueueIndex.Set(float64(e.nextL1MsgIndex)) - } // validateL1Messages has the constraints diff --git a/node/core/l1_message_test.go b/node/core/l1_message_test.go index d425dbe1e..aa96ffd85 100644 --- a/node/core/l1_message_test.go +++ b/node/core/l1_message_test.go @@ -142,7 +142,7 @@ func TestValidateL1Messages(t *testing.T) { l1MsgReader: &l1Reader, logger: tmlog.NewTMLogger(tmlog.NewSyncWriter(os.Stdout)), } - //block.Transactions + // block.Transactions l2tx := eth.NewTx(ð.LegacyTx{ Nonce: 1, GasPrice: big.NewInt(1000000000), @@ -183,7 +183,6 @@ func TestValidateL1Messages(t *testing.T) { err = executor.validateL1Messages(block, collectedL1TxHashes) require.ErrorIs(t, err, types.ErrWrongNextL1MessageIndex) }) - } var _ types.L1MessageReader = (*testL1MsgReader)(nil) diff --git a/node/db/store.go b/node/db/store.go index dcabfc091..6e9546ab0 100644 --- a/node/db/store.go +++ b/node/db/store.go @@ -91,8 +91,8 @@ func (s *Store) ReadL1MessagesInRange(start, end uint64) []types.L1Message { if start > end { return nil } - //expectedCount := end - start + 1 - //messages := make([]types.L1Message, 0, expectedCount) + // expectedCount := end - start + 1 + // messages := make([]types.L1Message, 0, expectedCount) var messages []types.L1Message it := IterateL1MessagesFrom(s.db, start) defer it.Release() @@ -118,10 +118,8 @@ func (s *Store) ReadL1MessageByIndex(index uint64) *types.L1Message { var l1Msg types.L1Message if err := rlp.DecodeBytes(data, &l1Msg); err != nil { panic(fmt.Sprintf("invalid L1 message RLP, err: %v", err)) - } return &l1Msg - } func (s *Store) WriteLatestDerivationL1Height(latest uint64) { diff --git a/node/derivation/batch_decode.go b/node/derivation/batch_decode.go index 693b4cfc6..0569087d6 100644 --- a/node/derivation/batch_decode.go +++ b/node/derivation/batch_decode.go @@ -13,7 +13,7 @@ import ( type BatchData struct { Txs []*types.Transaction BlockContexts []*BlockInfo - //Signature *bindings.RollupBatchSignature + // Signature *bindings.RollupBatchSignature } // number || timestamp || base_fee || gas_limit || num_txs || tx_hashs diff --git a/node/derivation/batch_info.go b/node/derivation/batch_info.go index 17d4fe88a..1a6a755a8 100644 --- a/node/derivation/batch_info.go +++ b/node/derivation/batch_info.go @@ -143,7 +143,7 @@ func (bi *BatchInfo) ParseBatch(batch geth.RPCRollupBatch) error { } func encodeTransactions(txs []*eth.Transaction) [][]byte { - var enc = make([][]byte, len(txs)) + enc := make([][]byte, len(txs)) for i, tx := range txs { enc[i], _ = tx.MarshalBinary() } diff --git a/node/derivation/config.go b/node/derivation/config.go index 439acbc42..aceeb783f 100644 --- a/node/derivation/config.go +++ b/node/derivation/config.go @@ -128,7 +128,7 @@ func (c *Config) SetCliContext(ctx *cli.Context) error { if _, err := io.ReadFull(rand.Reader, secret[:]); err != nil { return fmt.Errorf("failed to generate jwt secret: %w", err) } - if err := os.WriteFile(fileName, []byte(hexutil.Encode(secret[:])), 0600); err != nil { + if err := os.WriteFile(fileName, []byte(hexutil.Encode(secret[:])), 0o600); err != nil { return err } } diff --git a/node/receipt/batching.go b/node/receipt/batching.go index 587d9786b..4c5c4a6b5 100644 --- a/node/receipt/batching.go +++ b/node/receipt/batching.go @@ -36,8 +36,8 @@ func NewIterativeBatchCall[K any, V any]( requestsKeys []K, makeRequest func(K) (V, rpc.BatchElem), getBatch BatchCallContextFn, - batchSize int) *IterativeBatchCall[K, V] { - + batchSize int, +) *IterativeBatchCall[K, V] { if len(requestsKeys) < batchSize { batchSize = len(requestsKeys) } diff --git a/node/sequencer/mock/sequencer.go b/node/sequencer/mock/sequencer.go index 55e9e6017..478b5d234 100644 --- a/node/sequencer/mock/sequencer.go +++ b/node/sequencer/mock/sequencer.go @@ -68,7 +68,6 @@ func (s *Sequencer) Start() { return } } - } func (s *Sequencer) Stop() { diff --git a/node/sequencer/tm_node.go b/node/sequencer/tm_node.go index 6f6bf994c..0346d290f 100644 --- a/node/sequencer/tm_node.go +++ b/node/sequencer/tm_node.go @@ -67,7 +67,7 @@ func SetupNode(tmCfg *config.Config, privValidator types.PrivValidator, executor return nil, fmt.Errorf("failed to load bls priv key") } - //var app types.Application + // var app types.Application n, err := tmnode.NewNode( tmCfg, executor, diff --git a/node/sync/syncer_test.go b/node/sync/syncer_test.go index 743953955..f99ccd1ba 100644 --- a/node/sync/syncer_test.go +++ b/node/sync/syncer_test.go @@ -18,7 +18,7 @@ import ( ) func TestSyncer_GetL1Message(t *testing.T) { - //prepare msg + // prepare msg to := common.BigToAddress(big.NewInt(101)) msg := types.L1Message{ L1MessageTx: gethTypes.L1MessageTx{ @@ -32,10 +32,10 @@ func TestSyncer_GetL1Message(t *testing.T) { L1TxHash: common.BigToHash(big.NewInt(1111)), } - //prepare context + // prepare context ctx := PrepareContext() - //syncer + // syncer store := prepareDB(msg) store.WriteLatestSyncedL1Height(100) syncConfig := DefaultConfig() @@ -54,7 +54,6 @@ func TestSyncer_GetL1Message(t *testing.T) { require.EqualValues(t, msg.Value, actualMsg.Value) require.EqualValues(t, msg.Data, actualMsg.Data) require.EqualValues(t, msg.Sender, actualMsg.Sender) - } func prepareDB(msg types.L1Message) *db.Store { diff --git a/node/types/batch.go b/node/types/batch.go index 12b95cd96..0cf44b6e5 100644 --- a/node/types/batch.go +++ b/node/types/batch.go @@ -34,7 +34,7 @@ type BatchHeader struct { ParentBatchHash common.Hash SkippedL1MessageBitmap hexutil.Bytes - //cache + // cache EncodedBytes hexutil.Bytes } diff --git a/node/types/blob.go b/node/types/blob.go index a6b86e26a..c97ec3def 100644 --- a/node/types/blob.go +++ b/node/types/blob.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "morph-l2/node/zstd" eth "github.com/morph-l2/go-ethereum/core/types" @@ -248,7 +249,7 @@ func isEmptyBlob(blob *kzg4844.Blob) bool { } func extractInnerTxFullBytes(firstByte byte, reader io.Reader) ([]byte, error) { - //the occupied byte length for storing the size of the following rlp encoded bytes + // the occupied byte length for storing the size of the following rlp encoded bytes sizeByteLen := firstByte - 0xf7 // the size of the following rlp encoded bytes diff --git a/node/types/blob_test.go b/node/types/blob_test.go index 11f72476c..b57e76b07 100644 --- a/node/types/blob_test.go +++ b/node/types/blob_test.go @@ -2,9 +2,10 @@ package types import ( "math/big" - "morph-l2/node/zstd" "testing" + "morph-l2/node/zstd" + "github.com/morph-l2/go-ethereum/accounts/abi/bind" "github.com/morph-l2/go-ethereum/common" eth "github.com/morph-l2/go-ethereum/core/types" diff --git a/ops/l2-genesis/cmd/genesis/cmd.go b/ops/l2-genesis/cmd/genesis/cmd.go index 30f249e54..fe4df996e 100644 --- a/ops/l2-genesis/cmd/genesis/cmd.go +++ b/ops/l2-genesis/cmd/genesis/cmd.go @@ -56,7 +56,7 @@ var Subcommands = cli.Commands{ return err } - //directly process the deployment file, insteadof deployment-dir + // directly process the deployment file, insteadof deployment-dir // deployment-dir will be generated by forge deploy depPath := ctx.String("deployment-dir") _, network := filepath.Split(depPath) diff --git a/ops/l2-genesis/cmd/main.go b/ops/l2-genesis/cmd/main.go index 504820077..1c78638dd 100644 --- a/ops/l2-genesis/cmd/main.go +++ b/ops/l2-genesis/cmd/main.go @@ -43,7 +43,7 @@ func main() { app.Name = "op-node" app.Usage = "Optimism Rollup Node" app.Description = "The Optimism Rollup Node derives L2 block inputs from L1 data and drives an external L2 Execution Engine to build a L2 chain." - //app.Action = RollupNodeMain + // app.Action = RollupNodeMain app.Commands = []cli.Command{ { Name: "genesis", diff --git a/ops/l2-genesis/eth/heads.go b/ops/l2-genesis/eth/heads.go index 6fa64dfde..ce09b98b4 100644 --- a/ops/l2-genesis/eth/heads.go +++ b/ops/l2-genesis/eth/heads.go @@ -54,7 +54,8 @@ type L1BlockRefsSource interface { // on provided interval and with request timeout. Results are returned with provided callback fn, // which may block to pause/back-pressure polling. func PollBlockChanges(ctx context.Context, log log.Logger, src L1BlockRefsSource, fn HeadSignalFn, - label BlockLabel, interval time.Duration, timeout time.Duration) ethereum.Subscription { + label BlockLabel, interval time.Duration, timeout time.Duration, +) ethereum.Subscription { return event.NewSubscription(func(quit <-chan struct{}) error { if interval <= 0 { log.Warn("polling of block is disabled", "interval", interval, "label", label) diff --git a/ops/l2-genesis/eth/types.go b/ops/l2-genesis/eth/types.go index 215e0e85f..bc7fbca99 100644 --- a/ops/l2-genesis/eth/types.go +++ b/ops/l2-genesis/eth/types.go @@ -122,8 +122,7 @@ type Uint256Quantity = uint256.Int type Data = hexutil.Bytes -//type PayloadID = engine.PayloadID - +// type PayloadID = engine.PayloadID type ExecutionPayload struct { ParentHash common.Hash `json:"parentHash"` FeeRecipient common.Address `json:"feeRecipient"` @@ -275,7 +274,7 @@ type ForkchoiceUpdatedResult struct { // the result of the payload execution PayloadStatus PayloadStatusV1 `json:"payloadStatus"` // the payload id if requested - //PayloadID *PayloadID `json:"payloadId"` + // PayloadID *PayloadID `json:"payloadId"` } // SystemConfig represents the rollup system configuration that carries over in every L2 block, diff --git a/ops/l2-genesis/morph-chain-ops/genesis/config.go b/ops/l2-genesis/morph-chain-ops/genesis/config.go index 9102c780e..29b6b3458 100644 --- a/ops/l2-genesis/morph-chain-ops/genesis/config.go +++ b/ops/l2-genesis/morph-chain-ops/genesis/config.go @@ -118,11 +118,11 @@ type DeployConfig struct { RecordNextBatchSubmissionIndex uint64 `json:"recordNextBatchSubmissionIndex"` // MorphToken configs - //MorphTokenOwner common.Address `json:"morphTokenOwner"` - //MorphTokenName string `json:"morphTokenName"` - //MorphTokenSymbol string `json:"morphTokenSymbol"` - //MorphTokenInitialSupply uint64 `json:"morphTokenInitialSupply"` - //MorphTokenDailyInflationRate uint64 `json:"morphTokenDailyInflationRate"` + // MorphTokenOwner common.Address `json:"morphTokenOwner"` + // MorphTokenName string `json:"morphTokenName"` + // MorphTokenSymbol string `json:"morphTokenSymbol"` + // MorphTokenInitialSupply uint64 `json:"morphTokenInitialSupply"` + // MorphTokenDailyInflationRate uint64 `json:"morphTokenDailyInflationRate"` FundDevAccounts bool `json:"fundDevAccounts"` } @@ -240,7 +240,7 @@ func (d *DeployConfig) GetDeployedAddresses(hh *hardhat.Hardhat) error { // RollupConfig converts a DeployConfig to a rollup.Config func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2GenesisBlockHash common.Hash, l2GenesisBlockNumber uint64, l2GenesisStateRoot common.Hash, withdrawRoot common.Hash, genesisBatchHeader []byte) (*rollup.Config, error) { - //return nil, nil + // return nil, nil return &rollup.Config{ Genesis: rollup.Genesis{ L1: eth.BlockID{ diff --git a/ops/l2-genesis/morph-chain-ops/genesis/layer_two_test.go b/ops/l2-genesis/morph-chain-ops/genesis/layer_two_test.go index 8ce0e6ae8..a5477436b 100644 --- a/ops/l2-genesis/morph-chain-ops/genesis/layer_two_test.go +++ b/ops/l2-genesis/morph-chain-ops/genesis/layer_two_test.go @@ -64,11 +64,11 @@ func Test_BuildL2DeveloperGenesis(t *testing.T) { GovBatchTimeout: 100, // MorphToken - //MorphTokenOwner: address1, - //MorphTokenName: "Morph Token", - //MorphTokenSymbol: "Morph", - //MorphTokenInitialSupply: 1000000000, - //MorphTokenDailyInflationRate: 1, + // MorphTokenOwner: address1, + // MorphTokenName: "Morph Token", + // MorphTokenSymbol: "Morph", + // MorphTokenInitialSupply: 1000000000, + // MorphTokenDailyInflationRate: 1, FundDevAccounts: true, } diff --git a/ops/l2-genesis/morph-chain-ops/genesis/setters.go b/ops/l2-genesis/morph-chain-ops/genesis/setters.go index a41393383..bcdb37458 100644 --- a/ops/l2-genesis/morph-chain-ops/genesis/setters.go +++ b/ops/l2-genesis/morph-chain-ops/genesis/setters.go @@ -14,15 +14,13 @@ import ( "morph-l2/morph-deployer/morph-chain-ops/state" ) -var ( - // UntouchablePredeploys are addresses in the predeploy namespace - // that should not be touched by the migration process. - UntouchablePredeploys = map[common.Address]bool{ - //predeploys.ProxyAdminAddr: true, - predeploys.MorphStandardERC20Addr: true, - predeploys.L2WETHAddr: true, - } -) +// UntouchablePredeploys are addresses in the predeploy namespace +// that should not be touched by the migration process. +var UntouchablePredeploys = map[common.Address]bool{ + // predeploys.ProxyAdminAddr: true, + predeploys.MorphStandardERC20Addr: true, + predeploys.L2WETHAddr: true, +} // FundDevAccounts will fund each of the development accounts. func FundDevAccounts(db vm.StateDB) { diff --git a/ops/l2-genesis/morph-chain-ops/state/memory_db.go b/ops/l2-genesis/morph-chain-ops/state/memory_db.go index 556b922c9..b4d7dc262 100644 --- a/ops/l2-genesis/morph-chain-ops/state/memory_db.go +++ b/ops/l2-genesis/morph-chain-ops/state/memory_db.go @@ -27,37 +27,37 @@ type MemoryStateDB struct { } func (db *MemoryStateDB) GetKeccakCodeHash(address common.Address) common.Hash { - //TODO implement me + // TODO implement me panic("implement me") } func (db *MemoryStateDB) GetPoseidonCodeHash(address common.Address) common.Hash { - //TODO implement me + // TODO implement me panic("implement me") } func (db *MemoryStateDB) GetRootHash() common.Hash { - //TODO implement me + // TODO implement me panic("implement me") } func (db *MemoryStateDB) GetLiveStateAccount(addr common.Address) *types.StateAccount { - //TODO implement me + // TODO implement me panic("implement me") } func (db *MemoryStateDB) GetProof(addr common.Address) ([][]byte, error) { - //TODO implement me + // TODO implement me panic("implement me") } func (db *MemoryStateDB) GetProofByHash(addrHash common.Hash) ([][]byte, error) { - //TODO implement me + // TODO implement me panic("implement me") } func (db *MemoryStateDB) GetStorageProof(a common.Address, key common.Hash) ([][]byte, error) { - //TODO implement me + // TODO implement me panic("implement me") } @@ -104,7 +104,6 @@ func (db *MemoryStateDB) CreateAccount(addr common.Address) { Nonce: 0, } } - } func (db *MemoryStateDB) SubBalance(addr common.Address, amount *big.Int) { diff --git a/ops/l2-genesis/morph-chain-ops/state/state.go b/ops/l2-genesis/morph-chain-ops/state/state.go index 1a18d09fc..611c590ae 100644 --- a/ops/l2-genesis/morph-chain-ops/state/state.go +++ b/ops/l2-genesis/morph-chain-ops/state/state.go @@ -83,7 +83,6 @@ func ComputeStorageSlots(layout *solc.StorageLayout, values StorageValues) ([]*E storageType := layout.Types[target.Type] if storageType.Label == "" { return nil, fmt.Errorf("storage type for %s not found", label) - } storage, err := EncodeStorage(target, value, storageType) diff --git a/ops/tools/batchparse/main.go b/ops/tools/batchparse/main.go index 3b1b9a441..dc52f7e4c 100644 --- a/ops/tools/batchparse/main.go +++ b/ops/tools/batchparse/main.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "morph-l2/node/derivation" "github.com/morph-l2/go-ethereum/ethclient" diff --git a/ops/tools/bls12381/main.go b/ops/tools/bls12381/main.go index 86ba6d2aa..66e0000cb 100644 --- a/ops/tools/bls12381/main.go +++ b/ops/tools/bls12381/main.go @@ -89,7 +89,7 @@ func main() { byteRaw := blssignatures.PublicKeyToBytes(aggPubKeys) fmt.Println("aggPubKeys length: ", len(byteRaw)) - //the below behavior acts like: bls12381.NewG2().EncodePoint(aggPubKeys.key) + // the below behavior acts like: bls12381.NewG2().EncodePoint(aggPubKeys.key) byteRaw = byteRaw[1:] out := make([]byte, 256) // encode x diff --git a/ops/tools/gasinspect/main.go b/ops/tools/gasinspect/main.go index 06f74c9c4..4512c7e2e 100644 --- a/ops/tools/gasinspect/main.go +++ b/ops/tools/gasinspect/main.go @@ -41,7 +41,6 @@ func main() { //rollupTxCostInfo(client, common.HexToHash("0xdd82c92dc80f55c76471a805f26f3f740dfccbe0179db3f539c4da0f3a7ea677")) // //rollupTxCostInfo(client, common.HexToHash("0xf5ab1ddc7d5aed9e016ad943475d0baffdbe6c2d94be1b951b419dbeca9edea8")) - } func rollupTxCostInfo(client *ethclient.Client, txHash common.Hash) { diff --git a/oracle/backoff/operation.go b/oracle/backoff/operation.go index 5e0f7601a..26c8c211a 100644 --- a/oracle/backoff/operation.go +++ b/oracle/backoff/operation.go @@ -59,6 +59,5 @@ func DoCtx(ctx context.Context, maxAttempts int, strategy Strategy, op Operation } time.AfterFunc(strategy.Duration(attempt-1), doReattempt) } - } } diff --git a/oracle/cmd/staking-oracle/main.go b/oracle/cmd/staking-oracle/main.go index 7fc0d856a..1cbb6d493 100644 --- a/oracle/cmd/staking-oracle/main.go +++ b/oracle/cmd/staking-oracle/main.go @@ -19,7 +19,6 @@ var ( ) func main() { - app := cli.NewApp() app.Flags = flags.Flags app.Version = fmt.Sprintf("%s-%s", GitVersion, params.VersionWithCommit(GitCommit, GitDate)) diff --git a/oracle/flags/flags.go b/oracle/flags/flags.go index daaef255f..594d674bd 100644 --- a/oracle/flags/flags.go +++ b/oracle/flags/flags.go @@ -158,7 +158,6 @@ var requiredFlags = []cli.Flag{ } var optionalFlags = []cli.Flag{ - LogLevelFlag, LogTerminalFlag, LogFilenameFlag, diff --git a/oracle/oracle/batch.go b/oracle/oracle/batch.go index 4270bc117..00d7363b3 100644 --- a/oracle/oracle/batch.go +++ b/oracle/oracle/batch.go @@ -23,10 +23,12 @@ var BeforeRemoveSkipMapMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"_chainID\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ErrZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrorIncorrectBatchLength\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ErrorNoBlockInBatch\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"winner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"string\",\"name\":\"res\",\"type\":\"string\"}],\"name\":\"ChallengeRes\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ChallengeRewardClaim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"batchIndex\",\"type\":\"uint64\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"challenger\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"challengeDeposit\",\"type\":\"uint256\"}],\"name\":\"ChallengeState\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"batchHash\",\"type\":\"bytes32\"}],\"name\":\"CommitBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"batchHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"stateRoot\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"withdrawRoot\",\"type\":\"bytes32\"}],\"name\":\"FinalizeBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ProveRemainingClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"batchHash\",\"type\":\"bytes32\"}],\"name\":\"RevertBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"name\":\"UpdateChallenger\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldPeriod\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newPeriod\",\"type\":\"uint256\"}],\"name\":\"UpdateFinalizationPeriodSeconds\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldPercent\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newPercent\",\"type\":\"uint256\"}],\"name\":\"UpdateProofRewardPercent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldWindow\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newWindow\",\"type\":\"uint256\"}],\"name\":\"UpdateProofWindow\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldVerifier\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newVerifier\",\"type\":\"address\"}],\"name\":\"UpdateVerifier\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"LAYER_2_CHAIN_ID\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"__maxNumTxInChunk\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"addChallenger\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"batchChallengeReward\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"batchChallenged\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"}],\"name\":\"batchChallengedSuccess\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"}],\"name\":\"batchDataStore\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"originTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"finalizeTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"signedSequencersBitmap\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"}],\"name\":\"batchExist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"}],\"name\":\"batchInChallenge\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"}],\"name\":\"batchInsideChallengeWindow\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"batchIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"_batchHash\",\"type\":\"bytes32\"}],\"name\":\"challengeState\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"}],\"name\":\"challenges\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"batchIndex\",\"type\":\"uint64\"},{\"internalType\":\"address\",\"name\":\"challenger\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"challengeDeposit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"startTime\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"challengeSuccess\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"finished\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"claimProveRemaining\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"claimReward\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"parentBatchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"blockContexts\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"skippedL1MessageBitmap\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"prevStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"postStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"withdrawalRoot\",\"type\":\"bytes32\"}],\"internalType\":\"structIRollup.BatchDataInput\",\"name\":\"batchDataInput\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"signedSequencersBitmap\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"sequencerSets\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structIRollup.BatchSignatureInput\",\"name\":\"batchSignatureInput\",\"type\":\"tuple\"}],\"name\":\"commitBatch\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"}],\"name\":\"committedBatches\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"batchHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizationPeriodSeconds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_batchHeader\",\"type\":\"bytes\"}],\"name\":\"finalizeBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"}],\"name\":\"finalizedStateRoots\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"stateRoot\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_batchHeader\",\"type\":\"bytes\"}],\"name\":\"importGenesisBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"inChallenge\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_l1StakingContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_messageQueue\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_verifier\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_finalizationPeriodSeconds\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_proofWindow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_proofRewardPercent\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_batchIndex\",\"type\":\"uint256\"}],\"name\":\"isBatchFinalized\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"challengerAddress\",\"type\":\"address\"}],\"name\":\"isChallenger\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isChallenger\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"l1StakingContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastCommittedBatchIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastFinalizedBatchIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"messageQueue\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proofRewardPercent\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proofWindow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proveRemaining\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"_batchProof\",\"type\":\"bytes\"}],\"name\":\"proveState\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"removeChallenger\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_count\",\"type\":\"uint256\"}],\"name\":\"revertBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"revertReqIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"_status\",\"type\":\"bool\"}],\"name\":\"setPause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newPeriod\",\"type\":\"uint256\"}],\"name\":\"updateFinalizePeriodSeconds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newWindow\",\"type\":\"uint256\"}],\"name\":\"updateProofWindow\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newProofRewardPercent\",\"type\":\"uint256\"}],\"name\":\"updateRewardPercentage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newVerifier\",\"type\":\"address\"}],\"name\":\"updateVerifier\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"verifier\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"withdrawalRoot\",\"type\":\"bytes32\"}],\"name\":\"withdrawalRoots\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"exist\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", } -type BatchInfoMap map[common.Hash][]BatchInfo -type RollupBatch struct { - TxCount uint64 -} +type ( + BatchInfoMap map[common.Hash][]BatchInfo + RollupBatch struct { + TxCount uint64 + } +) type BatchInfo struct { BatchIndex uint64 @@ -229,7 +231,6 @@ func (o *Oracle) GetNextBatchSubmissionIndex() (*big.Int, error) { func (o *Oracle) LastBatchIndex(opts *bind.CallOpts) (*big.Int, error) { if o.isFinalized { return o.rollup.LastFinalizedBatchIndex(opts) - } return o.rollup.LastCommittedBatchIndex(opts) } diff --git a/oracle/oracle/oracle.go b/oracle/oracle/oracle.go index 5c789e938..d87cdeac3 100644 --- a/oracle/oracle/oracle.go +++ b/oracle/oracle/oracle.go @@ -6,7 +6,6 @@ import ( "crypto/rsa" "errors" "fmt" - "io" "math/big" "os" @@ -96,7 +95,7 @@ func NewOracle(cfg *config.Config, m *metrics.Metrics) (*Oracle, error) { var logHandler log.Handler output := io.Writer(os.Stderr) if cfg.LogFilename != "" { - f, err := os.OpenFile(cfg.LogFilename, os.O_CREATE|os.O_RDWR, os.FileMode(0600)) + f, err := os.OpenFile(cfg.LogFilename, os.O_CREATE|os.O_RDWR, os.FileMode(0o600)) if err != nil { return nil, fmt.Errorf("wrong log.filename set: %d", err) } @@ -247,7 +246,6 @@ func (o *Oracle) Start() { } }() } - } func (o *Oracle) waitReceiptWithCtx(ctx context.Context, txHash common.Hash) (*types.Receipt, error) { diff --git a/oracle/oracle/reward.go b/oracle/oracle/reward.go index f67ad451e..2b7536ab7 100644 --- a/oracle/oracle/reward.go +++ b/oracle/oracle/reward.go @@ -304,7 +304,6 @@ func (o *Oracle) setStartBlock() { return nil } return ErrRewardNotStart - }() if err != nil { if errors.Is(err, ErrRewardNotStart) { diff --git a/oracle/oracle/rollup.go b/oracle/oracle/rollup.go index 6c9256b09..cf94af8d6 100644 --- a/oracle/oracle/rollup.go +++ b/oracle/oracle/rollup.go @@ -18,9 +18,7 @@ import ( "github.com/morph-l2/go-ethereum/log" ) -var ( - MaxEpochCount = 50 -) +var MaxEpochCount = 50 type SequencerSetUpdateEpoch struct { Submitters []common.Address diff --git a/oracle/oracle/sign.go b/oracle/oracle/sign.go index 05e32d476..e0649007d 100644 --- a/oracle/oracle/sign.go +++ b/oracle/oracle/sign.go @@ -79,5 +79,6 @@ func (o *Oracle) newRecordTxAndSign(callData []byte) (*types.Transaction, error) GasFeeCap: gasFeeCap, Gas: gas, To: &o.recordAddr, - Data: callData})) + Data: callData, + })) } diff --git a/oracle/oracle/types.go b/oracle/oracle/types.go index 2c5fde6d2..55cd9389e 100644 --- a/oracle/oracle/types.go +++ b/oracle/oracle/types.go @@ -5,6 +5,4 @@ import "errors" // empirical value const maxBatchSize = 72 -var ( - ErrRewardNotStart = errors.New("reward has not start") -) +var ErrRewardNotStart = errors.New("reward has not start") diff --git a/tx-submitter/db/db.go b/tx-submitter/db/db.go index d6913390b..d773fc0d4 100644 --- a/tx-submitter/db/db.go +++ b/tx-submitter/db/db.go @@ -10,9 +10,7 @@ import ( "github.com/morph-l2/go-ethereum/ethdb/leveldb" ) -var ( - ErrKeyNotFound = fmt.Errorf("not found") -) +var ErrKeyNotFound = fmt.Errorf("not found") type Db struct { db *leveldb.Database @@ -27,6 +25,7 @@ func New(pathname string) (*Db, error) { } return &Db{db: ldb}, nil } + func (d *Db) GetFloat(key string) (float64, error) { d.m.Lock() defer d.m.Unlock() @@ -40,6 +39,7 @@ func (d *Db) GetFloat(key string) (float64, error) { } return res, nil } + func (d *Db) PutFloat(key string, val float64) error { d.m.Lock() defer d.m.Unlock() @@ -50,6 +50,7 @@ func (d *Db) PutFloat(key string, val float64) error { } return nil } + func (d *Db) GetString(key string) (string, error) { d.m.Lock() defer d.m.Unlock() @@ -59,11 +60,13 @@ func (d *Db) GetString(key string) (string, error) { } return string(v), nil } + func (d *Db) PutString(key, val string) error { d.m.Lock() defer d.m.Unlock() return d.db.Put([]byte(key), []byte(val)) } + func (d *Db) Close() error { return d.db.Close() } diff --git a/tx-submitter/entry.go b/tx-submitter/entry.go index b44be5628..32e401fc8 100644 --- a/tx-submitter/entry.go +++ b/tx-submitter/entry.go @@ -38,7 +38,6 @@ import ( // e.g. GitVersion, to be captured and used once the function is executed. func Main() func(ctx *cli.Context) error { return func(cliCtx *cli.Context) error { - cfg, err := utils.NewConfig(cliCtx) if err != nil { return err @@ -84,7 +83,7 @@ func Main() func(ctx *cli.Context) error { // for collection. Otherwise, logs will only be posted to stdout. output := io.Writer(os.Stdout) if cfg.LogFilename != "" { - f, err := os.OpenFile(cfg.LogFilename, os.O_CREATE|os.O_RDWR, os.FileMode(0600)) + f, err := os.OpenFile(cfg.LogFilename, os.O_CREATE|os.O_RDWR, os.FileMode(0o600)) if err != nil { return fmt.Errorf("wrong log.filename set: %d", err) } diff --git a/tx-submitter/event/indexer.go b/tx-submitter/event/indexer.go index 0ba87ab5b..0d1c76922 100644 --- a/tx-submitter/event/indexer.go +++ b/tx-submitter/event/indexer.go @@ -81,13 +81,11 @@ func (l *EventIndexer) Index() { } } - } // filter logs from from_block to to_block // if the range is too large, will divide the range func (ei *EventIndexer) index(client *ethclient.Client, fromBlock, toBlock *big.Int) (*EventInfo, error) { - endBlock := toBlock.Uint64() startBlock := endBlock - ei.indexStep lastProcessedBlock := fromBlock.Uint64() @@ -139,6 +137,7 @@ func (ei *EventIndexer) index(client *ethclient.Client, fromBlock, toBlock *big. func (l *EventIndexer) GetFilter() ethereum.FilterQuery { return l.filterQuery } + func (l *EventIndexer) GetStorage() *EventInfoStorage { return l.storage } diff --git a/tx-submitter/event/storage.go b/tx-submitter/event/storage.go index d77f857f7..11b361e9a 100644 --- a/tx-submitter/event/storage.go +++ b/tx-submitter/event/storage.go @@ -33,7 +33,6 @@ func NewEventInfoStorage(db *db.Db) *EventInfoStorage { } func (e *EventInfoStorage) Store() error { - // Convert struct to JSON string jsonData, err := json.Marshal(e.EventInfo) if err != nil { @@ -49,6 +48,7 @@ func (e *EventInfoStorage) Store() error { } return nil } + func (e *EventInfoStorage) Load() error { e.mu.Lock() defer e.mu.Unlock() diff --git a/tx-submitter/event/storage_test.go b/tx-submitter/event/storage_test.go index 74e78b094..9664fad3c 100644 --- a/tx-submitter/event/storage_test.go +++ b/tx-submitter/event/storage_test.go @@ -1,14 +1,14 @@ package event import ( - "morph-l2/tx-submitter/db" "testing" + "morph-l2/tx-submitter/db" + "github.com/stretchr/testify/require" ) func TestEventInfoStorage(t *testing.T) { - db, err := db.New("./testleveldb") require.NoError(t, err) storage := NewEventInfoStorage(db) diff --git a/tx-submitter/flags/flags.go b/tx-submitter/flags/flags.go index e7de38ff6..5a8ab0a44 100644 --- a/tx-submitter/flags/flags.go +++ b/tx-submitter/flags/flags.go @@ -126,7 +126,7 @@ var ( TxFeeLimitFlag = cli.Uint64Flag{ Name: "tx_fee_limit", Usage: "The maximum fee for a transaction", - Value: 5e17, //0.5eth + Value: 5e17, // 0.5eth EnvVar: prefixEnvVar("TX_FEE_LIMIT"), Required: true, } @@ -217,25 +217,25 @@ var ( TipFeeBumpFlag = cli.Uint64Flag{ Name: "TIP_FEE_BUMP", Usage: "The fee bump for tip", - Value: 120, //bumpTip = tip * TipFeeBump/100 + Value: 120, // bumpTip = tip * TipFeeBump/100 EnvVar: prefixEnvVar("TIP_FEE_BUMP"), } MaxTipFlag = cli.Uint64Flag{ Name: "max_tip", Usage: "The maximum tip for a transaction", - Value: 10e9, //10gwei + Value: 10e9, // 10gwei EnvVar: prefixEnvVar("MAX_TIP"), } MinTipFlag = cli.Uint64Flag{ Name: "min_tip", Usage: "The minimum tip for a transaction", - Value: 5e8, //0.5gwei + Value: 5e8, // 0.5gwei EnvVar: prefixEnvVar("MIN_TIP"), } MaxBaseFeeFlag = cli.Uint64Flag{ Name: "max_base_fee", Usage: "The maximum base fee for a transaction", - Value: 100e9, //100gwei + Value: 100e9, // 100gwei EnvVar: prefixEnvVar("MAX_BASE_FEE"), } diff --git a/tx-submitter/l1checker/blockmonitor.go b/tx-submitter/l1checker/blockmonitor.go index 9c870809b..9b9d22ad4 100644 --- a/tx-submitter/l1checker/blockmonitor.go +++ b/tx-submitter/l1checker/blockmonitor.go @@ -17,7 +17,7 @@ type IBlockMonitor interface { } type BlockMonitor struct { - blockGenerateTime time.Duration //12s for Dencun + blockGenerateTime time.Duration // 12s for Dencun latestBlockTime time.Time noGrowthBlockCntTime time.Duration client iface.L1Client diff --git a/tx-submitter/l1checker/blockmonitor_test.go b/tx-submitter/l1checker/blockmonitor_test.go index 846e814ce..1e45ab924 100644 --- a/tx-submitter/l1checker/blockmonitor_test.go +++ b/tx-submitter/l1checker/blockmonitor_test.go @@ -8,7 +8,6 @@ import ( ) func TestIsGrowth(t *testing.T) { - blockCnt := int64(2) monitor := NewBlockMonitor(blockCnt, nil) monitor.latestBlockTime = time.Time{} @@ -19,5 +18,4 @@ func TestIsGrowth(t *testing.T) { monitor.latestBlockTime = time.Now().Add(-monitor.noGrowthBlockCntTime) require.Equal(t, false, monitor.IsGrowth()) - } diff --git a/tx-submitter/localpool/journal.go b/tx-submitter/localpool/journal.go index ca918f106..aa94124d7 100644 --- a/tx-submitter/localpool/journal.go +++ b/tx-submitter/localpool/journal.go @@ -25,6 +25,7 @@ type Journal struct { func New(path string) *Journal { return &Journal{path: path} } + func (j *Journal) Init() error { // create file if file not exist _, err := os.Stat(j.path) @@ -39,7 +40,6 @@ func (j *Journal) Init() error { } else { return fmt.Errorf("failed to stat journal file: %w", err) } - } return nil @@ -63,7 +63,6 @@ func (j *Journal) AddToFileEnd(str string) error { j.mu.Lock() defer j.mu.Unlock() return addToFileEnd(j.path, str) - } func (j *Journal) ParseAllTxsAndCleanJournal() ([]*types.Transaction, error) { @@ -80,7 +79,6 @@ func (j *Journal) ParseAllTxsAndCleanJournal() ([]*types.Transaction, error) { func (j *Journal) ParseAllTxs() ([]*types.Transaction, error) { content, err := readFileContent(j.path) - if err != nil { return nil, fmt.Errorf("failed to parse txs: %w", err) } @@ -101,7 +99,6 @@ func (j *Journal) ParseAllTxs() ([]*types.Transaction, error) { } return ans, nil - } func addToFileStart(path string, str string) error { @@ -116,7 +113,7 @@ func addToFileStart(path string, str string) error { newContent = str } - err = os.WriteFile(path, []byte(newContent), 0600) + err = os.WriteFile(path, []byte(newContent), 0o600) if err != nil { return fmt.Errorf("failed to write journal file: %w", err) } @@ -165,7 +162,7 @@ func addToFileEnd(path string, str string) error { } else { newContent = str } - err = os.WriteFile(path, []byte(newContent), 0600) + err = os.WriteFile(path, []byte(newContent), 0o600) if err != nil { return fmt.Errorf("failed to add line to file end: %w", err) } @@ -191,11 +188,12 @@ func readFileContent(path string) (string, error) { } return string(content), nil } + func getLines(str string) []string { return strings.Split(str, "\n") } -func getFirstLine(path string) (string, error) { +func getFirstLine(path string) (string, error) { content, err := readFileContent(path) if err != nil { return "", fmt.Errorf("failed to get first line: %w", err) @@ -210,7 +208,6 @@ func getFirstLine(path string) (string, error) { } return "", nil - } func getLastLine(path string) (string, error) { diff --git a/tx-submitter/localpool/journal_test.go b/tx-submitter/localpool/journal_test.go index 5c597b276..f6ecff250 100644 --- a/tx-submitter/localpool/journal_test.go +++ b/tx-submitter/localpool/journal_test.go @@ -7,7 +7,6 @@ import ( ) func getTestJournal() *Journal { - jn := New("journal.rlp") err := jn.rm() if err != nil { @@ -30,6 +29,7 @@ func TestAddToFileStart(t *testing.T) { require.NoError(t, err) require.Equal(t, "hello", fl) } + func TestAddToFileEnd(t *testing.T) { jn := getTestJournal() err := jn.AddToFileEnd("hello") @@ -43,5 +43,4 @@ func TestAddToFileEnd(t *testing.T) { ll, err := jn.GetLastLine() require.NoError(t, err) require.Equal(t, "hello", ll) - } diff --git a/tx-submitter/localpool/tx.go b/tx-submitter/localpool/tx.go index b024e9f9d..b43b8e60c 100644 --- a/tx-submitter/localpool/tx.go +++ b/tx-submitter/localpool/tx.go @@ -13,6 +13,7 @@ func EncodeTx(tx *types.Transaction) (string, error) { } return string(txbs), nil } + func ParseTx(tx string) (*types.Transaction, error) { var res types.Transaction if err := res.UnmarshalJSON([]byte(tx)); err != nil { diff --git a/tx-submitter/metrics/metrics.go b/tx-submitter/metrics/metrics.go index 2b09d467c..2aac6908d 100644 --- a/tx-submitter/metrics/metrics.go +++ b/tx-submitter/metrics/metrics.go @@ -25,7 +25,6 @@ type Metrics struct { } func NewMetrics() *Metrics { - return &Metrics{ RpcErrors: promauto.NewCounter(prometheus.CounterOpts{ Name: "submitter_rpc_errors", diff --git a/tx-submitter/mock/l1mock.go b/tx-submitter/mock/l1mock.go index 10dccef62..3a77b288b 100644 --- a/tx-submitter/mock/l1mock.go +++ b/tx-submitter/mock/l1mock.go @@ -54,6 +54,7 @@ func (c *L1ClientWrapper) SubscribeNewHead(ctx context.Context, ch chan<- *types func (c *L1ClientWrapper) SetBlock(block *types.Block) { c.Block = block } + func (c *L1ClientWrapper) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) { return nil, nil } @@ -61,27 +62,35 @@ func (c *L1ClientWrapper) CodeAt(ctx context.Context, contract common.Address, b func (c *L1ClientWrapper) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) { return nil, nil } + func (c *L1ClientWrapper) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error) { return nil, nil } + func (c *L1ClientWrapper) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) { return 0, nil } + func (c *L1ClientWrapper) SuggestGasPrice(ctx context.Context) (*big.Int, error) { return big.NewInt(0), nil } + func (c *L1ClientWrapper) SuggestGasTipCap(ctx context.Context) (*big.Int, error) { return c.TipCap, nil } + func (c *L1ClientWrapper) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error) { return 0, nil } + func (c *L1ClientWrapper) SendTransaction(ctx context.Context, tx *types.Transaction) error { return nil } + func (c *L1ClientWrapper) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) { return nil, nil } + func (c *L1ClientWrapper) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) { return nil, nil } diff --git a/tx-submitter/services/pendingtx.go b/tx-submitter/services/pendingtx.go index 53276fb7a..108ab2584 100644 --- a/tx-submitter/services/pendingtx.go +++ b/tx-submitter/services/pendingtx.go @@ -141,6 +141,7 @@ func (pt *PendingTxs) GetAll() []TxInfo { defer pt.mu.Unlock() return pt.getAll() } + func (pt *PendingTxs) getAll() []TxInfo { // copy txs and return txs := make([]TxInfo, 0, len(pt.txinfos)) @@ -180,6 +181,7 @@ func (pt *PendingTxs) TrySetFailedBatchIndex(index uint64) { pt.failedIndex = &index } + func (pt *PendingTxs) SetPindex(index uint64) { pt.mu.Lock() defer pt.mu.Unlock() @@ -211,7 +213,6 @@ func (pt *PendingTxs) HaveFailed() bool { } func (pt *PendingTxs) ExistedIndex(index uint64) bool { - txs := pt.GetAll() abi, _ := bindings.RollupMetaData.GetAbi() @@ -229,5 +230,4 @@ func (pt *PendingTxs) ExistedIndex(index uint64) bool { } return false - } diff --git a/tx-submitter/services/rollup.go b/tx-submitter/services/rollup.go index 272c258a6..cd36ef257 100644 --- a/tx-submitter/services/rollup.go +++ b/tx-submitter/services/rollup.go @@ -100,7 +100,6 @@ func NewRollup( bm *l1checker.BlockMonitor, eventInfoStorage *event.EventInfoStorage, ) *Rollup { - return &Rollup{ ctx: ctx, metrics: metrics, @@ -125,7 +124,6 @@ func NewRollup( } func (r *Rollup) Start() error { - // init rollup service if err := r.PreCheck(); err != nil { return err @@ -158,7 +156,6 @@ func (r *Rollup) Start() error { // metrics go utils.Loop(r.ctx, 10*time.Second, func() { - // get balacnce of wallet balance, err := r.L1Client.BalanceAt(context.Background(), r.WalletAddr(), nil) if err != nil { @@ -179,7 +176,6 @@ func (r *Rollup) Start() error { } r.metrics.SetWalletBalance(balanceEthFloat) - }) go utils.Loop(r.ctx, r.cfg.RollupInterval, func() { @@ -194,7 +190,6 @@ func (r *Rollup) Start() error { }) if r.cfg.Finalize { - go utils.Loop(r.ctx, r.cfg.FinalizeInterval, func() { r.rollupFinalizeMu.Lock() defer r.rollupFinalizeMu.Unlock() @@ -224,7 +219,6 @@ func (r *Rollup) Start() error { } func (r *Rollup) ProcessTx() error { - // case 1: in mempool // -> check timeout // case 2: no in mempool @@ -340,7 +334,6 @@ func (r *Rollup) ProcessTx() error { r.rollupFinalizeMu.Unlock() } - } else { if method == "commitBatch" && r.pendingTxs.failedIndex != nil { log.Info("fail revover", "failed_index", r.pendingTxs.failedIndex) @@ -394,7 +387,6 @@ func (r *Rollup) ProcessTx() error { } return nil - } func (r *Rollup) finalize() error { @@ -553,11 +545,9 @@ func (r *Rollup) finalize() error { } return nil - } func (r *Rollup) rollup() error { - if !r.cfg.PriorityRollup { cur, err := r.rotator.CurrentSubmitter(r.L2Clients, r.Staking) if err != nil { @@ -640,7 +630,6 @@ func (r *Rollup) rollup() error { } else { batchIndex = r.pendingTxs.pindex + 1 } - } else { batchIndex = cindex + 1 } @@ -864,7 +853,6 @@ func (r *Rollup) buildSignatureInput(batch *eth.RPCRollupBatch) (*bindings.IRoll } func (r *Rollup) GetGasTipAndCap() (*big.Int, *big.Int, *big.Int, error) { - head, err := r.L1Client.HeaderByNumber(context.Background(), nil) if err != nil { return nil, nil, nil, err @@ -917,7 +905,6 @@ func (r *Rollup) GetGasTipAndCap() (*big.Int, *big.Int, *big.Int, error) { // PreCheck is run before the submitter to check whether the submitter can be started func (r *Rollup) PreCheck() error { - // debug stakers stakers, err := r.Staking.GetStakers(nil) if err != nil { @@ -952,13 +939,11 @@ func (r *Rollup) PreCheck() error { } func (r *Rollup) WalletAddr() common.Address { - if r.cfg.ExternalSign { return common.HexToAddress(r.cfg.ExternalSignAddress) } else { return crypto.PubkeyToAddress(r.privKey.PublicKey) } - } func GetRollupBatchByIndex(index uint64, clients []iface.L2Client) (*eth.RPCRollupBatch, error) { @@ -1027,7 +1012,6 @@ func GetEpoch(addr common.Address, clients []iface.L2Client) (*big.Int, error) { // query sequencer set update time from sequencer contract on l2 func GetSequencerSetUpdateTime(addr common.Address, clients []iface.L2Client) (*big.Int, error) { - if len(clients) < 1 { return nil, fmt.Errorf("no client to query sequencer set update time") } @@ -1071,7 +1055,6 @@ func GetEpochUpdateTime(addr common.Address, clients []iface.L2Client) (*big.Int } return nil, fmt.Errorf("no epoch update time found after querying all clients") - } func UpdateGasLimit(tx *ethtypes.Transaction) (*ethtypes.Transaction, error) { @@ -1080,7 +1063,6 @@ func UpdateGasLimit(tx *ethtypes.Transaction) (*ethtypes.Transaction, error) { var newTx *ethtypes.Transaction if tx.Type() == ethtypes.LegacyTxType { - newTx = ethtypes.NewTx(ðtypes.LegacyTx{ Nonce: tx.Nonce(), GasPrice: big.NewInt(tx.GasPrice().Int64()), @@ -1113,7 +1095,6 @@ func UpdateGasLimit(tx *ethtypes.Transaction) (*ethtypes.Transaction, error) { BlobHashes: tx.BlobHashes(), Sidecar: tx.BlobTxSidecar(), }) - } else { return nil, fmt.Errorf("unknown tx type:%v", tx.Type()) } @@ -1122,7 +1103,6 @@ func UpdateGasLimit(tx *ethtypes.Transaction) (*ethtypes.Transaction, error) { // send tx to l1 with business logic check func (r *Rollup) SendTx(tx *ethtypes.Transaction) error { - // judge tx info is valid if tx == nil { return errors.New("nil tx") @@ -1144,7 +1124,6 @@ func (r *Rollup) SendTx(tx *ethtypes.Transaction) error { } return nil - } // send tx to l1 with business logic check @@ -1256,9 +1235,9 @@ func (r *Rollup) ReSubmitTx(resend bool, tx *ethtypes.Transaction) (*ethtypes.Tr log.Info("new tx info", "tx_type", newTx.Type(), - "gas_tip", tip.String(), //todo: convert to gwei - "gas_fee_cap", gasFeeCap.String(), //todo: convert to gwei - "blob_fee_cap", blobFeeCap.String(), //todo: convert to gwei + "gas_tip", tip.String(), // todo: convert to gwei + "gas_fee_cap", gasFeeCap.String(), // todo: convert to gwei + "blob_fee_cap", blobFeeCap.String(), // todo: convert to gwei ) // sign tx newTx, err = r.Sign(newTx) @@ -1275,7 +1254,6 @@ func (r *Rollup) ReSubmitTx(resend bool, tx *ethtypes.Transaction) (*ethtypes.Tr } func (r *Rollup) IsStaker() (bool, error) { - isStaker, err := r.Staking.IsStaker(nil, r.WalletAddr()) if err != nil { return false, fmt.Errorf("call IsStaker err :%v", err) @@ -1284,7 +1262,6 @@ func (r *Rollup) IsStaker() (bool, error) { } func (r *Rollup) EstimateGas(from, to common.Address, data []byte, feecap *big.Int, tip *big.Int) (uint64, error) { - gas, err := r.L1Client.EstimateGas(context.Background(), ethereum.CallMsg{ From: from, To: &to, diff --git a/tx-submitter/services/rollup_test.go b/tx-submitter/services/rollup_test.go index b8045b4ab..150aee080 100644 --- a/tx-submitter/services/rollup_test.go +++ b/tx-submitter/services/rollup_test.go @@ -115,7 +115,6 @@ func TestGetGasTipAndCap(t *testing.T) { r = NewRollup(context.Background(), nil, nil, l1Mock, nil, nil, nil, nil, nil, common.Address{}, nil, config, nil, nil, nil, nil, nil) _, _, _, err = r.GetGasTipAndCap() require.ErrorContains(t, err, "tip is too high") - } func TestReSubmitTx(t *testing.T) { @@ -151,5 +150,4 @@ func TestReSubmitTx(t *testing.T) { tx, err := r.ReSubmitTx(false, oldTx) require.NoError(t, err) require.EqualValues(t, config.MinTip, tx.GasTipCap().Uint64()) - } diff --git a/tx-submitter/services/rotator.go b/tx-submitter/services/rotator.go index c99884049..fbed403ea 100644 --- a/tx-submitter/services/rotator.go +++ b/tx-submitter/services/rotator.go @@ -43,7 +43,6 @@ func (r *Rotator) StartEventIndexer() { // UpdateState updates the state of the rotator // updated by event listener in the future func (r *Rotator) UpdateState(clients []iface.L2Client, l1Staking iface.IL1Staking) error { - epochUpdateTime, err := GetEpochUpdateTime(r.l2GovAddr, clients) if err != nil { log.Error("failed to get epoch update time", "err", err) @@ -108,7 +107,6 @@ func (r *Rotator) UpdateState(clients []iface.L2Client, l1Staking iface.IL1Staki // GetCurrentSubmitter returns the current sequencer that should be submitting func (r *Rotator) CurrentSubmitter(clients []iface.L2Client, l1Staking iface.IL1Staking) (*common.Address, error) { - err := r.UpdateState(clients, l1Staking) if err != nil { return nil, fmt.Errorf("update state err: %w", err) @@ -126,7 +124,6 @@ func (r *Rotator) CurrentSubmitter(clients []iface.L2Client, l1Staking iface.IL1 seqIdx := sec / r.epoch.Int64() % int64(len(r.GetSequencerSet())) return &r.GetSubmitterSet()[seqIdx], nil - } func (r *Rotator) SetSubmitterSet(newSet []common.Address) { @@ -134,6 +131,7 @@ func (r *Rotator) SetSubmitterSet(newSet []common.Address) { defer r.mu.Unlock() r.submitterSet = newSet } + func (r *Rotator) GetSubmitterSet() []common.Address { r.mu.Lock() defer r.mu.Unlock() @@ -150,5 +148,4 @@ func (r *Rotator) GetSequencerSet() []common.Address { r.mu.Lock() defer r.mu.Unlock() return r.sequencerSet - } diff --git a/tx-submitter/services/utils.go b/tx-submitter/services/utils.go index e8e185b42..ca00f0416 100644 --- a/tx-submitter/services/utils.go +++ b/tx-submitter/services/utils.go @@ -17,9 +17,11 @@ const ( ) // new = old * (100 + priceBump) / 100 -var priceBumpPercent = big.NewInt(100 + priceBump) -var blobPriceBumpPercent = big.NewInt(100 + blobPriceBump) -var oneHundred = big.NewInt(100) +var ( + priceBumpPercent = big.NewInt(100 + priceBump) + blobPriceBumpPercent = big.NewInt(100 + blobPriceBump) + oneHundred = big.NewInt(100) +) var blobCommitmentVersionKZG uint8 = 0x01 @@ -45,7 +47,6 @@ func calcThresholdValue(x *big.Int, isBlobTx bool) *big.Int { } func calcFee(receipt *types.Receipt) float64 { - if receipt == nil || receipt.EffectiveGasPrice == nil { return 0 } @@ -57,7 +58,6 @@ func calcFee(receipt *types.Receipt) float64 { if receipt.BlobGasPrice != nil { blobfee = new(big.Int).Mul(big.NewInt(int64(receipt.BlobGasUsed)), receipt.BlobGasPrice) } - } fee := new(big.Int).Add(calldatafee, blobfee) @@ -71,5 +71,4 @@ func ToEtherFloat(weiAmt *big.Int) float64 { etherAmt := new(big.Rat).SetFrac(weiAmt, big.NewInt(params.Ether)) fEtherAmt, _ := etherAmt.Float64() return fEtherAmt - } diff --git a/tx-submitter/types/batch_cache.go b/tx-submitter/types/batch_cache.go index 7e6794f1d..d769c8243 100644 --- a/tx-submitter/types/batch_cache.go +++ b/tx-submitter/types/batch_cache.go @@ -24,6 +24,7 @@ func (b *BatchCache) Get(batchIndex uint64) (*eth.RPCRollupBatch, bool) { batch, ok := b.batchCache[batchIndex] return batch, ok } + func (b *BatchCache) Set(batchIndex uint64, batch *eth.RPCRollupBatch) { b.m.Lock() defer b.m.Unlock() diff --git a/tx-submitter/types/batch_cache_test.go b/tx-submitter/types/batch_cache_test.go index f07d6411e..f0e434d4e 100644 --- a/tx-submitter/types/batch_cache_test.go +++ b/tx-submitter/types/batch_cache_test.go @@ -7,7 +7,6 @@ import ( ) func TestBatchCache(t *testing.T) { - cache := NewBatchCache() cache.Set(1, nil) _, ok := cache.Get(1) @@ -17,5 +16,4 @@ func TestBatchCache(t *testing.T) { require.False(t, ok) _, ok = cache.Get(2) require.False(t, ok) - } diff --git a/tx-submitter/utils/config.go b/tx-submitter/utils/config.go index 31bd9c9ea..06e1d21ad 100644 --- a/tx-submitter/utils/config.go +++ b/tx-submitter/utils/config.go @@ -87,7 +87,7 @@ type Config struct { MaxTip uint64 MinTip uint64 MaxBaseFee uint64 - //max txs in pendingpool + // max txs in pendingpool MaxTxsInPendingPool uint64 // external sign diff --git a/tx-submitter/utils/utils.go b/tx-submitter/utils/utils.go index bcfc02051..50913ebda 100644 --- a/tx-submitter/utils/utils.go +++ b/tx-submitter/utils/utils.go @@ -58,7 +58,6 @@ func ParseParentBatchIndex(calldata []byte) uint64 { // ParseL1Mempool parses the L1 mempool and returns the transactions. func ParseL1Mempool(rpc *rpc.Client, addr common.Address) ([]*types.Transaction, error) { - var result map[string]map[string]*types.Transaction err := rpc.Call(&result, "txpool_contentFrom", addr) if err != nil { @@ -82,11 +81,9 @@ func ParseL1Mempool(rpc *rpc.Client, addr common.Address) ([]*types.Transaction, } return txs, nil - } func ParseMempoolLatestBatchIndex(id []byte, txs []*types.Transaction) uint64 { - var res uint64 for _, tx := range txs { if bytes.Equal(tx.Data()[:4], id) { @@ -98,7 +95,6 @@ func ParseMempoolLatestBatchIndex(id []byte, txs []*types.Transaction) uint64 { } return res + 1 - } func ParseBusinessInfo(tx *types.Transaction, a *abi.ABI) []interface{} { @@ -174,7 +170,6 @@ func ParseNonce(s string) (uint64, uint64, error) { } func ParseL1MessageCnt(blockContexts hexutil.Bytes) uint64 { - var l1msgcnt uint64 blockNum := binary.BigEndian.Uint16(blockContexts[:2]) remainingBz := blockContexts[2:]