Skip to content

Commit bf0105b

Browse files
authored
Merge pull request #11287 from vegaprotocol/feature/ratelimit
chore: remove old rate limit from processor
2 parents 13b93fb + 3a758d9 commit bf0105b

File tree

5 files changed

+5
-259
lines changed

5 files changed

+5
-259
lines changed

core/processor/abci.go

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import (
4040
"code.vegaprotocol.io/vega/core/idgeneration"
4141
"code.vegaprotocol.io/vega/core/netparams"
4242
"code.vegaprotocol.io/vega/core/pow"
43-
"code.vegaprotocol.io/vega/core/processor/ratelimit"
4443
"code.vegaprotocol.io/vega/core/snapshot"
4544
"code.vegaprotocol.io/vega/core/teams"
4645
"code.vegaprotocol.io/vega/core/txn"
@@ -211,7 +210,6 @@ type App struct {
211210
log *logging.Logger
212211
cancelFn func()
213212
stopBlockchain func() error
214-
rates *ratelimit.Rates
215213

216214
// service injection
217215
assets Assets
@@ -306,15 +304,11 @@ func NewApp(log *logging.Logger,
306304
app := &App{
307305
abci: abci.New(codec),
308306

309-
log: log,
310-
vegaPaths: vegaPaths,
311-
cfg: config,
312-
cancelFn: cancelFn,
313-
stopBlockchain: stopBlockchain,
314-
rates: ratelimit.New(
315-
config.Ratelimit.Requests,
316-
config.Ratelimit.PerNBlocks,
317-
),
307+
log: log,
308+
vegaPaths: vegaPaths,
309+
cfg: config,
310+
cancelFn: cancelFn,
311+
stopBlockchain: stopBlockchain,
318312
assets: assets,
319313
banking: banking,
320314
broker: broker,
@@ -1048,7 +1042,6 @@ func (app *App) OnBeginBlock(blockHeight uint64, blockHash string, blockTime tim
10481042
app.blockCtx = ctx
10491043
now := blockTime
10501044
app.time.SetTimeNow(ctx, now)
1051-
app.rates.NextBlock()
10521045
app.currentTimestamp = app.time.GetTimeNow()
10531046
app.previousTimestamp = app.time.GetTimeLastBatch()
10541047
app.log.Debug("ABCI service BEGIN completed",
@@ -1330,10 +1323,6 @@ func (app *App) OnCheckTx(ctx context.Context, _ *tmtypes.RequestCheckTx, tx abc
13301323
return ctx, &resp
13311324
}
13321325

1333-
// Check ratelimits
1334-
// FIXME(): temporary disable all rate limiting
1335-
_, isval := app.limitPubkey(tx.PubKeyHex())
1336-
13371326
gasWanted, err := app.gastimator.CalcGasWantedForTx(tx)
13381327
if err != nil { // this error means the transaction couldn't be parsed
13391328
app.log.Error("error getting gas estimate", logging.Error(err))
@@ -1347,30 +1336,9 @@ func (app *App) OnCheckTx(ctx context.Context, _ *tmtypes.RequestCheckTx, tx abc
13471336
app.log.Debug("transaction passed checkTx", logging.String("tid", tx.GetPoWTID()), logging.String("command", tx.Command().String()))
13481337
}
13491338

1350-
if isval {
1351-
return ctx, &resp
1352-
}
1353-
13541339
return ctx, &resp
13551340
}
13561341

1357-
// limitPubkey returns whether a request should be rate limited or not.
1358-
func (app *App) limitPubkey(pk string) (limit bool, isValidator bool) {
1359-
// Do not rate limit validators nodes.
1360-
if app.top.IsValidatorVegaPubKey(pk) {
1361-
return false, true
1362-
}
1363-
1364-
key := ratelimit.Key(pk).String()
1365-
if !app.rates.Allow(key) {
1366-
app.log.Debug("Rate limit exceeded", logging.String("key", key))
1367-
return true, false
1368-
}
1369-
1370-
app.log.Debug("RateLimit allowance", logging.String("key", key), logging.Int("count", app.rates.Count(key)))
1371-
return false, false
1372-
}
1373-
13741342
func (app *App) canSubmitTx(tx abci.Tx) (err error) {
13751343
defer func() {
13761344
if err != nil {

core/processor/config.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package processor
1717

1818
import (
19-
"code.vegaprotocol.io/vega/core/processor/ratelimit"
2019
"code.vegaprotocol.io/vega/libs/config/encoding"
2120
"code.vegaprotocol.io/vega/logging"
2221
)
@@ -37,7 +36,6 @@ type Config struct {
3736
LogOrderSubmitDebug encoding.Bool `long:"log-order-submit-debug"`
3837
LogOrderAmendDebug encoding.Bool `long:"log-order-amend-debug"`
3938
LogOrderCancelDebug encoding.Bool `long:"log-order-cancel-debug"`
40-
Ratelimit ratelimit.Config `group:"Ratelimit" namespace:"ratelimit"`
4139
KeepCheckpointsMax uint `long:"keep-checkpoints-max"`
4240
SnapshotDebug Snapshot `group:"SnapshotDebug" namespace:"snapshotdebug"`
4341
}
@@ -48,7 +46,6 @@ func NewDefaultConfig() Config {
4846
return Config{
4947
Level: encoding.LogLevel{Level: logging.InfoLevel},
5048
LogOrderSubmitDebug: true,
51-
Ratelimit: ratelimit.NewDefaultConfig(),
5249
KeepCheckpointsMax: 20,
5350
SnapshotDebug: Snapshot{
5451
DevEnabled: false,

core/processor/ratelimit/config.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

core/processor/ratelimit/ratelimit.go

Lines changed: 0 additions & 89 deletions
This file was deleted.

core/processor/ratelimit/ratelimit_test.go

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)