Skip to content

Commit

Permalink
Linter and other unpushed stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanIliev545 committed Jan 22, 2024
1 parent 55f68ae commit 3949823
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
3 changes: 1 addition & 2 deletions go/enclave/evm/evm_facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func executeTransaction(
l1Gas := big.NewInt(0)
hasL1Cost := l1cost.Cmp(big.NewInt(0)) != 0

// If a transaction has to be published on the l1, it will have an l1 cost
if hasL1Cost {
l1Gas.Div(l1cost, header.BaseFee) // TotalCost/CostPerGas = Gas
l1Gas.Add(l1Gas, big.NewInt(1)) // Cover from leftover from the division
Expand All @@ -149,7 +150,6 @@ func executeTransaction(
// and pay it to the coinbase of the batch
statedb.SubBalance(msg.From, l1cost)
statedb.AddBalance(header.Coinbase, l1cost)

}

// Create a new context to be used in the EVM environment
Expand All @@ -163,7 +163,6 @@ func executeTransaction(
statedb.SubBalance(header.Coinbase, l1cost)
statedb.AddBalance(msg.From, l1cost)
}

return receipt, err
}

Expand Down
3 changes: 3 additions & 0 deletions go/enclave/gas/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func (o *oracle) EstimateL1CostForMsg(args *gethapi.TransactionArgs, block *type
encoded = append(encoded, *args.Data...)
}

// We get the non zero gas cost per byte of calldata, and multiply it by the fixed bytes
// of a transaction. Then we take the data of a transaction and calculate the l1 gas used for it.
// Both are added together and multiplied by the base fee to give us the final cost for the message.
nonZeroGas := big.NewInt(int64(params.TxDataNonZeroGasEIP2028))
overhead := big.NewInt(0).Mul(big.NewInt(150), nonZeroGas)
l1Gas := CalculateL1GasUsed(encoded, overhead)
Expand Down
10 changes: 0 additions & 10 deletions go/enclave/nodetype/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,6 @@ func (s *sequencer) createGenesisBatch(block *common.L1Block) error {
return nil
}

type SortableTransactions types.Transactions

func (c SortableTransactions) Len() int { return len(c) }
func (c SortableTransactions) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
func (c SortableTransactions) Less(i, j int) bool {
return c[i].Nonce() < c[j].Nonce()
}

func (s *sequencer) createNewHeadBatch(l1HeadBlock *common.L1Block, skipBatchIfEmpty bool) error {
headBatchSeq := s.batchRegistry.HeadBatchSeq()
if headBatchSeq == nil {
Expand Down Expand Up @@ -244,8 +236,6 @@ func (s *sequencer) createNewHeadBatch(l1HeadBlock *common.L1Block, skipBatchIfE
}
}

sort.Sort(SortableTransactions(transactions))

sequencerNo, err := s.storage.FetchCurrentSequencerNo()
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions integration/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ func PrefundWallets(ctx context.Context, faucetWallet wallet.Wallet, faucetClien
To: &destAddr,
}

tx := faucetClient.EstimateGasAndGasPrice(txData)
tx := faucetClient.EstimateGasAndGasPrice(txData) // nolint: contextcheck

Check failure on line 108 in integration/common/utils.go

View workflow job for this annotation

GitHub Actions / lint

directive `// nolint: contextcheck` should be written without leading space as `//nolint: contextcheck` (nolintlint)
signedTx, err := faucetWallet.SignTransaction(tx)
if err != nil {
panic(err)
}

err = faucetClient.SendTransaction(ctx, signedTx)
if err != nil {
var txJson []byte
txJson, _ = signedTx.MarshalJSON()
panic(fmt.Sprintf("could not transfer from faucet for tx %s. Cause: %s", string(txJson[:]), err))
var txJSON []byte
txJSON, _ = signedTx.MarshalJSON()
panic(fmt.Sprintf("could not transfer from faucet for tx %s. Cause: %s", string(txJSON[:]), err))
}

txHashes[idx] = signedTx.Hash()
Expand Down

0 comments on commit 3949823

Please sign in to comment.