Skip to content

Commit

Permalink
Fix goimports whitespace issues & gosimple
Browse files Browse the repository at this point in the history
  • Loading branch information
hbandura committed Oct 2, 2023
1 parent 6adacb3 commit eb32682
Show file tree
Hide file tree
Showing 24 changed files with 110 additions and 107 deletions.
11 changes: 5 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ linters:
- misspell
# - staticcheck
- unconvert
- typecheck
# - typecheck
# - unused
- staticcheck
- bidichk
- durationcheck
- exportloopref
- whitespace
# - bidichk
# - durationcheck
# - exportloopref
# - whitespace

# - gosec
# - errcheck
Expand Down
2 changes: 1 addition & 1 deletion cmd/devp2p/internal/ethtest/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/celo-org/celo-blockchain/params"
)

//var faucetAddr = common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7")
// var faucetAddr = common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7")
var faucetKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")

func (s *Suite) sendSuccessfulTxs(t *utesting.T, isCelo67 bool) error {
Expand Down
3 changes: 2 additions & 1 deletion cmd/ethkey/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func getPassphrase(ctx *cli.Context, confirmation bool) string {
// that can be safely used to calculate a signature from.
//
// The hash is calulcated as
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
//
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
//
// This gives context to the signed message and prevents signing of transactions.
func signHash(data []byte) []byte {
Expand Down
5 changes: 3 additions & 2 deletions consensus/istanbul/announce/val_enode_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@ func (vet *ValidatorEnodeDB) UpdateQueryEnodeStats(valEnodeEntries []*istanbul.A
// upsert will update or insert a validator enode entry given that the existing entry
// is older (determined by the version) than the new one
// TODO - In addition to modifying the val_enode_db, this function also will disconnect
// and/or connect the corresponding validator connenctions. The validator connections
// should be managed be a separate thread (see https://github.com/celo-org/celo-blockchain/issues/607)
//
// and/or connect the corresponding validator connenctions. The validator connections
// should be managed be a separate thread (see https://github.com/celo-org/celo-blockchain/issues/607)
func (vet *ValidatorEnodeDB) upsert(valEnodeEntries []*istanbul.AddressEntry,
onNewEntry func(batch *leveldb.Batch, entry db.GenericEntry) error,
onUpdatedEntry func(batch *leveldb.Batch, existingEntry db.GenericEntry, newEntry db.GenericEntry) error) error {
Expand Down
2 changes: 1 addition & 1 deletion consensus/istanbul/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var DefaultConfig = &Config{
LoadTestCSVFile: "", // disable by default
}

//ApplyParamsChainConfigToConfig applies the istanbul config values from params.chainConfig to the istanbul.Config config
// ApplyParamsChainConfigToConfig applies the istanbul config values from params.chainConfig to the istanbul.Config config
func ApplyParamsChainConfigToConfig(chainConfig *params.ChainConfig, config *Config) error {
if chainConfig.Istanbul.Epoch != 0 {
if chainConfig.Istanbul.Epoch < MinEpochSize {
Expand Down
6 changes: 3 additions & 3 deletions consensus/istanbul/core/backlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func (c *core) checkMessage(msgCode uint64, msgView *istanbul.View) error {

// MsgBacklog represent a backlog of future messages
// It works by:
// - allowing storing messages with "store()"
// - call eventListener when a backlog message becomes "present"
// - updates its notion of time/state with updateState()
// - allowing storing messages with "store()"
// - call eventListener when a backlog message becomes "present"
// - updates its notion of time/state with updateState()
type MsgBacklog interface {
// store atttemps to store the message in the backlog
// it might not do so, if the message is too far in the future
Expand Down
7 changes: 4 additions & 3 deletions consensus/istanbul/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ func (s State) String() string {
}

// Cmp compares s and y and returns:
// -1 if s is the previous state of y
// 0 if s and y are the same state
// +1 if s is the next state of y
//
// -1 if s is the previous state of y
// 0 if s and y are the same state
// +1 if s is the next state of y
func (s State) Cmp(y State) int {
if uint64(s) < uint64(y) {
return -1
Expand Down
3 changes: 2 additions & 1 deletion consensus/istanbul/proxy/proxy_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (
// proxySet defines the set of proxies that the validator is aware of and
// validator/proxy assignments.
// WARNING: None of this object's functions are threadsafe, so it's
// the user's responsibility to ensure that.
//
// the user's responsibility to ensure that.
type proxySet struct {
proxiesByID map[enode.ID]*Proxy // all proxies known by this node, whether or not they are peered
valAssignments *valAssignments // the mappings of proxy<->remote validators
Expand Down
6 changes: 4 additions & 2 deletions consensus/istanbul/proxy/validator_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import (
// If a validator is assigned to a nil proxy, then that means that it's
// not assigned yet.
// WARNING: None of this object's functions are threadsafe, so it's
// the user's responsibility to ensure that.
//
// the user's responsibility to ensure that.
type valAssignments struct {
valToProxy map[common.Address]*enode.ID // map of validator address -> proxy assignment ID
proxyToVals map[enode.ID]map[common.Address]struct{} // map of proxy ID to set of validator addresses
Expand Down Expand Up @@ -126,7 +127,8 @@ func (h hasher) Sum64(data []byte) uint64 {
// Validator <-> proxy pairings are recalculated every time a proxy or validator
// is added/removed
// WARNING: None of this object's functions are threadsafe, so it's
// the user's responsibility to ensure that.
//
// the user's responsibility to ensure that.
type consistentHashingPolicy struct {
c *consistent.Consistent // used for consistent hashing
logger log.Logger
Expand Down
7 changes: 4 additions & 3 deletions consensus/istanbul/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ func (v *View) String() string {
}

// Cmp compares v and y and returns:
// -1 if v < y
// 0 if v == y
// +1 if v > y
//
// -1 if v < y
// 0 if v == y
// +1 if v > y
func (v *View) Cmp(y *View) int {
if v.Sequence.Cmp(y.Sequence) != 0 {
return v.Sequence.Cmp(y.Sequence)
Expand Down
24 changes: 11 additions & 13 deletions consensus/istanbul/uptime/autofix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import (
"github.com/stretchr/testify/assert"
)

func copy(b *builder) *builder {
func copyBuilder(b *builder) *builder {
h := make([]*types.Header, len(b.headersAdded))
for i, hd := range b.headersAdded {
h[i] = hd
}
copy(h, b.headersAdded)
return &builder{
epoch: b.epoch,
epochSize: b.epochSize,
Expand Down Expand Up @@ -72,7 +70,7 @@ func TestAddOnFirstOfEpoch(t *testing.T) {
computeV: computeV,
computeE: computeE,
}
b2 := copy(b) // copy of builder, for the compute test
b2 := copyBuilder(b) // copy of builder, for the compute test
assert.True(t, istanbul.IsFirstBlockOfEpoch(101, 100))
provider := &headers{t: t, epochSize: 100, reqs: []headersReq{}}
af := NewAutoFixBuilder(b, provider)
Expand Down Expand Up @@ -107,7 +105,7 @@ func TestAddManyFirstOfEpoch(t *testing.T) {
computeV: computeV,
computeE: computeE,
}
b2 := copy(b) // copy of builder, for the compute test
b2 := copyBuilder(b) // copy of builder, for the compute test
assert.True(t, istanbul.IsFirstBlockOfEpoch(101, 100))
last := header(105)
providerResult := []*types.Header{header(101), header(102), header(103), header(104), header(105)}
Expand Down Expand Up @@ -137,7 +135,7 @@ func TestContinueSequentialAdd(t *testing.T) {
computeV: computeV,
computeE: computeE,
}
b2 := copy(b) // copy of builder, for the compute test
b2 := copyBuilder(b) // copy of builder, for the compute test
assert.True(t, istanbul.IsFirstBlockOfEpoch(101, 100))
provider := &headers{t: t, epochSize: 100, reqs: []headersReq{}}
af := NewAutoFixBuilder(b, provider)
Expand Down Expand Up @@ -169,7 +167,7 @@ func TestSequentialAddFork(t *testing.T) {
computeV: computeV,
computeE: computeE,
}
b2 := copy(b) // copy of builder, for the compute test
b2 := copyBuilder(b) // copy of builder, for the compute test
assert.True(t, istanbul.IsFirstBlockOfEpoch(101, 100))
last := header(103)
providerResult := []*types.Header{header(101), header(102), last}
Expand Down Expand Up @@ -204,7 +202,7 @@ func TestRewind(t *testing.T) {
computeV: computeV,
computeE: computeE,
}
b2 := copy(b) // copy of builder, for the compute test
b2 := copyBuilder(b) // copy of builder, for the compute test
assert.True(t, istanbul.IsFirstBlockOfEpoch(101, 100))
last := header(102)
providerResult := []*types.Header{header(101), header(102)}
Expand Down Expand Up @@ -238,7 +236,7 @@ func TestDoNothing(t *testing.T) {
computeV: computeV,
computeE: computeE,
}
b2 := copy(b) // copy of builder, for the compute test
b2 := copyBuilder(b) // copy of builder, for the compute test
assert.True(t, istanbul.IsFirstBlockOfEpoch(101, 100))
provider := &headers{t: t, epochSize: 100, reqs: []headersReq{}}
af := NewAutoFixBuilder(b, provider)
Expand Down Expand Up @@ -268,7 +266,7 @@ func TestSameHeightRebuild(t *testing.T) {
computeV: computeV,
computeE: computeE,
}
b2 := copy(b) // copy of builder, for the compute test
b2 := copyBuilder(b) // copy of builder, for the compute test
assert.True(t, istanbul.IsFirstBlockOfEpoch(101, 100))
providerResult := []*types.Header{header(101), header(102), last}
provider := &headers{t: t, epochSize: 100, reqs: []headersReq{
Expand Down Expand Up @@ -299,7 +297,7 @@ func TestAdvance(t *testing.T) {
computeV: computeV,
computeE: computeE,
}
b2 := copy(b)
b2 := copyBuilder(b)
assert.True(t, istanbul.IsFirstBlockOfEpoch(101, 100))
last := header(106)
providerResult := []*types.Header{pivot, header(104), header(105), header(106)}
Expand Down Expand Up @@ -334,7 +332,7 @@ func TestAdvanceFork(t *testing.T) {
computeV: computeV,
computeE: computeE,
}
b2 := copy(b)
b2 := copyBuilder(b)
assert.True(t, istanbul.IsFirstBlockOfEpoch(101, 100))
last := header(106)
providerResult1 := []*types.Header{forkPivot, header(104), header(105), header(106)}
Expand Down
5 changes: 1 addition & 4 deletions consensus/istanbul/uptime/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ type Uptime struct {

func (u *Uptime) Copy() *Uptime {
entriesCopy := make([]UptimeEntry, len(u.Entries))
for i := 0; i < len(u.Entries); i++ {
// UptimeEntry is not a pointer, copy.
entriesCopy[i] = u.Entries[i]
}
copy(entriesCopy, u.Entries)
return &Uptime{
// No need to copy the header
LatestHeader: u.LatestHeader,
Expand Down
7 changes: 3 additions & 4 deletions contracts/config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ type VersionInfo struct {

// Cmp compares x and y and returns:
//
// -1 if x < y
// 0 if x == y
// +1 if x > y
//
// -1 if x < y
// 0 if x == y
// +1 if x > y
func cmp(x uint64, y uint64) int {
if x < y {
return -1
Expand Down
1 change: 0 additions & 1 deletion core/rawdb/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ modified the items added to the freezer must be considered final (I.E, no
chance of a re-org) currently that is ensured by only freezing blocks at least
90000 behind the head block. This 90000 threshold is referred to as the
'FullImmutabilityThreshold'.
*/
package rawdb
1 change: 1 addition & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func (st *StateTransition) payFees(espresso bool) error {
// For native token(CELO) as feeCurrency:
// - Pre-Espresso: it ensures balance >= GasPrice * gas + gatewayFee (1)
// - Post-Espresso: it ensures balance >= GasFeeCap * gas + value + gatewayFee (2)
//
// For non-native tokens(cUSD, cEUR, ...) as feeCurrency:
// - Pre-Espresso: it ensures balance > GasPrice * gas + gatewayFee (3)
// - Post-Espresso: it ensures balance >= GasFeeCap * gas + gatewayFee (4)
Expand Down
1 change: 1 addition & 0 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,7 @@ func (pool *TxPool) demoteUnexecutables() {
// For native token(CELO) as feeCurrency:
// - Pre-Espresso: it ensures balance >= GasPrice * gas + value + gatewayFee (1)
// - Post-Espresso: it ensures balance >= GasFeeCap * gas + value + gatewayFee (2)
//
// For non-native tokens(cUSD, cEUR, ...) as feeCurrency:
// - Pre-Espresso: it ensures balance > GasPrice * gas + gatewayFee (3)
// - Post-Espresso: it ensures balance >= GasFeeCap * gas + gatewayFee (4)
Expand Down
3 changes: 2 additions & 1 deletion core/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,8 @@ func TestTransactionGapFilling(t *testing.T) {
// When we change TestChangeConfig to enable Donut this test will need:
// (a) to set pool.donut = false at its start (so we can add unprotected transactions)
// (b) different functions to generate protected vs unprotected transactions, since we will
// need to update transaction() and the others to use replay protection
//
// need to update transaction() and the others to use replay protection
func TestPoolReAcceptingUnprotectedTxsFromEspresso(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion core/vm/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
return
}
if common.Bytes2Hex(res) != test.Expected {
bench.Error(fmt.Sprintf("Expected %v, got %v", test.Expected, common.Bytes2Hex(res)))
bench.Errorf("Expected %v, got %v", test.Expected, common.Bytes2Hex(res))
return
}
})
Expand Down
Loading

0 comments on commit eb32682

Please sign in to comment.