Skip to content

Commit f4deb5b

Browse files
committed
Revert "Fix gosec"
This reverts commit 179ab16.
1 parent 1e6f1f6 commit f4deb5b

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

blockstm/scheduler.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ func (s *Scheduler) Done() bool {
6666
}
6767

6868
func (s *Scheduler) DecreaseValidationIdx(target TxnIndex) {
69-
StoreMin(&s.validation_idx, uint64(target)) //nolint:gosec // index conversion safe
69+
StoreMin(&s.validation_idx, uint64(target))
7070
s.decrease_cnt.Add(1)
7171
}
7272

7373
func (s *Scheduler) CheckDone() {
7474
observed_cnt := s.decrease_cnt.Load()
75-
if s.execution_idx.Load() >= uint64(s.block_size) && //nolint:gosec // block size conversion safe
76-
s.validation_idx.Load() >= uint64(s.block_size) && //nolint:gosec // block size conversion safe
75+
if s.execution_idx.Load() >= uint64(s.block_size) &&
76+
s.validation_idx.Load() >= uint64(s.block_size) &&
7777
s.num_active_tasks.Load() == 0 {
7878
if observed_cnt == s.decrease_cnt.Load() {
7979
s.done_marker.Store(true)
@@ -102,7 +102,7 @@ func (s *Scheduler) TryIncarnate(idx TxnIndex) TxnVersion {
102102
//
103103
// Invariant `num_active_tasks`: increased if a valid task is returned.
104104
func (s *Scheduler) NextVersionToExecute() TxnVersion {
105-
if s.execution_idx.Load() >= uint64(s.block_size) { //nolint:gosec // block size conversion safe
105+
if s.execution_idx.Load() >= uint64(s.block_size) {
106106
s.CheckDone()
107107
return InvalidTxnVersion
108108
}
@@ -116,15 +116,15 @@ func (s *Scheduler) NextVersionToExecute() TxnVersion {
116116
//
117117
// Invariant `num_active_tasks`: increased if a valid task is returned.
118118
func (s *Scheduler) NextVersionToValidate() TxnVersion {
119-
if s.validation_idx.Load() >= uint64(s.block_size) { //nolint:gosec // block size conversion safe
119+
if s.validation_idx.Load() >= uint64(s.block_size) {
120120
s.CheckDone()
121121
return InvalidTxnVersion
122122
}
123123
IncrAtomic(&s.num_active_tasks)
124124
idx_to_validate := FetchIncr(&s.validation_idx)
125-
if idx_to_validate < uint64(s.block_size) { //nolint:gosec // block size conversion safe
125+
if idx_to_validate < uint64(s.block_size) {
126126
if ok, incarnation := s.txn_status[idx_to_validate].IsExecuted(); ok {
127-
return TxnVersion{TxnIndex(idx_to_validate), incarnation} //nolint:gosec // index conversion safe
127+
return TxnVersion{TxnIndex(idx_to_validate), incarnation}
128128
}
129129
}
130130

@@ -178,8 +178,7 @@ func (s *Scheduler) FinishExecution(version TxnVersion, wroteNewPath bool) (TxnV
178178

179179
deps := s.txn_dependency[version.Index].Swap(nil)
180180
s.ResumeDependencies(deps)
181-
// otherwise index already small enough
182-
if s.validation_idx.Load() > uint64(version.Index) { //nolint:gosec // index conversion safe
181+
if s.validation_idx.Load() > uint64(version.Index) { // otherwise index already small enough
183182
if !wroteNewPath {
184183
// schedule validation for current tx only, don't decrease num_active_tasks
185184
return version, TaskKindValidation
@@ -201,7 +200,7 @@ func (s *Scheduler) FinishValidation(txn TxnIndex, aborted bool) (TxnVersion, Ta
201200
if aborted {
202201
s.txn_status[txn].SetReadyStatus()
203202
s.DecreaseValidationIdx(txn + 1)
204-
if s.execution_idx.Load() > uint64(txn) { //nolint:gosec // index conversion safe
203+
if s.execution_idx.Load() > uint64(txn) {
205204
return s.TryIncarnate(txn), TaskKindExecution
206205
}
207206
}

store/gaskv/store.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (gs *GStore[V]) Get(key []byte) (value V) {
7070

7171
// TODO overflow-safe math?
7272
gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(len(key)), types.GasReadPerByteDesc)
73-
gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(gs.valueLen(value)), types.GasReadPerByteDesc) //nolint:gosec // fix this with the above as well
73+
gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(gs.valueLen(value)), types.GasReadPerByteDesc)
7474

7575
return value
7676
}
@@ -82,7 +82,7 @@ func (gs *GStore[V]) Set(key []byte, value V) {
8282
gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostFlat, types.GasWriteCostFlatDesc)
8383
// TODO overflow-safe math?
8484
gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(len(key)), types.GasWritePerByteDesc)
85-
gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(gs.valueLen(value)), types.GasWritePerByteDesc) //nolint:gosec // fix this with the above as well
85+
gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(gs.valueLen(value)), types.GasWritePerByteDesc)
8686
gs.parent.Set(key, value)
8787
}
8888

@@ -203,7 +203,7 @@ func (gi *gasIterator[V]) consumeSeekGas() {
203203
value := gi.Value()
204204

205205
gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(key)), types.GasValuePerByteDesc)
206-
gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(gi.valueLen(value)), types.GasValuePerByteDesc) //nolint:gosec // fix this with the above as well
206+
gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(gi.valueLen(value)), types.GasValuePerByteDesc)
207207
}
208208
gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, types.GasIterNextCostFlatDesc)
209209
}

x/bank/keeper/virtual.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (k BaseSendKeeper) addVirtualCoins(ctx context.Context, addr sdk.AccAddress
9191
// bytes containing account address followed by the txn index
9292
key := make([]byte, len(addr)+8)
9393
copy(key, addr)
94-
binary.BigEndian.PutUint64(key[len(addr):], uint64(sdkCtx.TxIndex())) // nolint:gosec // index conversion safe
94+
binary.BigEndian.PutUint64(key[len(addr):], uint64(sdkCtx.TxIndex()))
9595

9696
var coins sdk.Coins
9797
value := store.Get(key)
@@ -108,7 +108,7 @@ func (k BaseSendKeeper) subVirtualCoins(ctx context.Context, addr sdk.AccAddress
108108

109109
key := make([]byte, len(addr)+8)
110110
copy(key, addr)
111-
binary.BigEndian.PutUint64(key[len(addr):], uint64(sdkCtx.TxIndex())) // nolint:gosec // index conversion safe
111+
binary.BigEndian.PutUint64(key[len(addr):], uint64(sdkCtx.TxIndex()))
112112

113113
value := store.Get(key)
114114
if value == nil {

0 commit comments

Comments
 (0)