Skip to content

Commit

Permalink
Merge pull request ethereum#226 from OffchainLabs/cara-lint-fixes
Browse files Browse the repository at this point in the history
lint fixes from @CaraWang
  • Loading branch information
PlasmaPower authored Jun 14, 2023
2 parents dcd0ff9 + 19b0249 commit ea9af6b
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 21 deletions.
8 changes: 3 additions & 5 deletions arbitrum/apibackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func CreateFallbackClient(fallbackClientUrl string, fallbackClientTimeout time.D
var fallbackClient types.FallbackClient
var err error
fallbackClient, err = rpc.Dial(fallbackClientUrl)
if fallbackClient == nil || err != nil {
if err != nil {
return nil, fmt.Errorf("failed creating fallback connection: %w", err)
}
if fallbackClientTimeout != 0 {
Expand Down Expand Up @@ -160,7 +160,7 @@ func (a *APIBackend) SyncProgressMap() map[string]interface{} {
func (a *APIBackend) SyncProgress() ethereum.SyncProgress {
progress := a.sync.SyncProgressMap()

if progress == nil || len(progress) == 0 {
if len(progress) == 0 {
return ethereum.SyncProgress{}
}
return ethereum.SyncProgress{
Expand All @@ -179,7 +179,6 @@ func (a *APIBackend) FeeHistory(
newestBlock rpc.BlockNumber,
rewardPercentiles []float64,
) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {

if core.GetArbOSSpeedLimitPerSecond == nil {
return nil, nil, nil, nil, errors.New("ArbOS not installed")
}
Expand Down Expand Up @@ -218,7 +217,7 @@ func (a *APIBackend) FeeHistory(

// use the most recent average compute rate for all blocks
// note: while we could query this value for each block, it'd be prohibitively expensive
state, _, err := a.StateAndHeaderByNumber(ctx, rpc.BlockNumber(newestBlock))
state, _, err := a.StateAndHeaderByNumber(ctx, newestBlock)
if err != nil {
return common.Big0, nil, nil, nil, err
}
Expand Down Expand Up @@ -284,7 +283,6 @@ func (a *APIBackend) FeeHistory(
fullnessAnalogue = 1.0
}
gasUsed[block-oldestBlock] = fullnessAnalogue

}
if newestBlock == latestBlock {
basefees[blocks] = basefees[blocks-1] // guess the basefee won't change
Expand Down
6 changes: 2 additions & 4 deletions arbitrum/recordingdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ func (db *RecordingKV) Close() error {
return nil
}

func (db *RecordingKV) Release() {
return
}
func (db *RecordingKV) Release() {}

func (db *RecordingKV) GetRecordedEntries() map[common.Hash][]byte {
return db.readDbEntries
Expand Down Expand Up @@ -322,7 +320,7 @@ func (r *RecordingDatabase) GetOrRecreateState(ctx context.Context, header *type
}
err = r.addStateVerify(stateDb, block.Root())
if err != nil {
return nil, fmt.Errorf("failed commiting state for block %d : %w", blockToRecreate, err)
return nil, fmt.Errorf("failed committing state for block %d : %w", blockToRecreate, err)
}
r.dereferenceRoot(lastRoot)
lastRoot = block.Root()
Expand Down
4 changes: 3 additions & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,12 @@ func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) {
func (s *StateDB) SetBalance(addr common.Address, amount *big.Int) {
stateObject := s.GetOrNewStateObject(addr)
if stateObject != nil {
if amount == nil {
amount = big.NewInt(0)
}
prevBalance := stateObject.Balance()
s.unexpectedBalanceDelta.Add(s.unexpectedBalanceDelta, amount)
s.unexpectedBalanceDelta.Sub(s.unexpectedBalanceDelta, prevBalance)

stateObject.SetBalance(amount)
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,10 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {

// Arbitrum: record self destructs
if st.evm.Config.Debug {
for _, address := range st.evm.StateDB.GetSuicides() {
suicides := st.evm.StateDB.GetSuicides()
for i, address := range suicides {
balance := st.evm.StateDB.GetBalance(address)
st.evm.Config.Tracer.CaptureArbitrumTransfer(st.evm, &address, nil, balance, false, "selfDestruct")
st.evm.Config.Tracer.CaptureArbitrumTransfer(st.evm, &suicides[i], nil, balance, false, "selfDestruct")
}
}

Expand All @@ -477,7 +478,6 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}

func (st *StateTransition) refundGas(refundQuotient uint64) {

st.gasRemaining += st.evm.ProcessingHook.ForceRefundGas()

nonrefundable := st.evm.ProcessingHook.NonrefundableGas()
Expand Down
4 changes: 2 additions & 2 deletions core/types/transaction_marshalling.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
enc.Value = (*hexutil.Big)(itx.Value)
enc.To = tx.To()
case *ArbitrumUnsignedTx:
enc.From = (*common.Address)(&itx.From)
enc.From = &itx.From
enc.ChainID = (*hexutil.Big)(itx.ChainId)
enc.Nonce = (*hexutil.Uint64)(&itx.Nonce)
enc.Gas = (*hexutil.Uint64)(&itx.Gas)
Expand All @@ -163,7 +163,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
enc.Data = (*hexutil.Bytes)(&itx.Data)
enc.To = tx.To()
case *ArbitrumRetryTx:
enc.From = (*common.Address)(&itx.From)
enc.From = &itx.From
enc.TicketId = &itx.TicketId
enc.RefundTo = &itx.RefundTo
enc.ChainID = (*hexutil.Big)(itx.ChainId)
Expand Down
1 change: 0 additions & 1 deletion core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
}

func opGasprice(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {

// Arbitrum: provide an opportunity to remove the tip from the gas price
gasPrice := interpreter.evm.ProcessingHook.GasPriceOp(interpreter.evm)

Expand Down
2 changes: 1 addition & 1 deletion core/vm/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
// Note that reference types are actual VM data structures; make copies
// if you need to retain them beyond the current call.
type EVMLogger interface {
// Arbitrum: capture a transfer, mint, or burn that happens outside of EVM exectuion
// Arbitrum: capture a transfer, mint, or burn that happens outside of EVM execution
CaptureArbitrumTransfer(env *EVM, from, to *common.Address, value *big.Int, before bool, purpose string)
CaptureArbitrumStorageGet(key common.Hash, depth int, before bool)
CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool)
Expand Down
3 changes: 2 additions & 1 deletion eth/tracers/native/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type callFrameMarshaling struct {
}

type callTracer struct {
// Arbitrum: capture transfers occuring outside of evm execution
// Arbitrum: capture transfers occurring outside of evm execution
beforeEVMTransfers []arbitrumTransfer
afterEVMTransfers []arbitrumTransfer

Expand Down Expand Up @@ -133,6 +133,7 @@ func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (tracers.Tracer, e
// and is populated on start and end.
return &callTracer{
callstack: make([]callFrame, 1),
config: config,
beforeEVMTransfers: []arbitrumTransfer{},
afterEVMTransfers: []arbitrumTransfer{},
}, nil
Expand Down
4 changes: 2 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *EthereumAPI) FeeHistory(ctx context.Context, blockCount math.HexOrDecim
func (s *EthereumAPI) Syncing() (interface{}, error) {
progress := s.b.SyncProgressMap()

if progress == nil || len(progress) == 0 {
if len(progress) == 0 {
return false, nil
}
return progress, nil
Expand Down Expand Up @@ -1409,7 +1409,7 @@ func (s *BlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Block, inc
if err != nil {
log.Error("error trying to fill legacy l1BlockNumber", "err", err)
} else {
fields["l1BlockNumber"] = hexutil.Uint64(l1BlockNumber)
fields["l1BlockNumber"] = l1BlockNumber
}
}
return fields, err
Expand Down
3 changes: 2 additions & 1 deletion metrics/chunked_associative_array.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ package metrics
// https://github.com/dropwizard/metrics/blob/release/4.2.x/metrics-core/src/main/java/com/codahale/metrics/ChunkedAssociativeLongArray.java

import (
"github.com/gammazero/deque"
"sort"
"strconv"
"strings"

"github.com/gammazero/deque"
)

const (
Expand Down

0 comments on commit ea9af6b

Please sign in to comment.