Skip to content

Commit f59ad6b

Browse files
Deprecate banned accounts functionality now that CAP-0077 is active (#5426)
Resolves stellar/stellar-core-internal#702
2 parents 100cc38 + 2912ba4 commit f59ad6b

30 files changed

Lines changed: 115 additions & 1247 deletions

docs/software/commands.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -291,27 +291,16 @@ Most commands return their results in JSON format.
291291
* **bans**
292292
List current active bans
293293

294-
* **banaccounts**
295-
Manages the persistent list of banned accounts. Banned accounts are stored in
296-
the database and survive restarts. Any transaction whose source account,
297-
operation source account, fee-bump fee source, or (for Soroban transactions)
298-
write footprint account entry matches a banned address will be rejected from
299-
the transaction queue.
300-
* `banaccounts`<br>
301-
Lists the currently banned account addresses as a JSON array.<br>
302-
* `banaccounts?accountids=G_ADDRESS1,G_ADDRESS2,...`<br>
303-
Adds the specified addresses to the persistent ban list. Existing bans are
304-
preserved (additive).<br>
305-
306-
Note: The `FILTERED_G_ADDRESSES` configuration option is deprecated. Any
307-
addresses configured there will be automatically migrated to the persistent
308-
ban list on startup.
309-
310-
* **unbanaccounts**
311-
* `unbanaccounts`<br>
312-
Clears all banned accounts.<br>
313-
* `unbanaccounts?accountids=G_ADDRESS1,G_ADDRESS2,...`<br>
314-
Removes the specified addresses from the persistent ban list.<br>
294+
* **banaccounts** (deprecated)
295+
Account banning has been removed; this endpoint is kept for backwards
296+
compatibility and only returns a deprecation warning. See
297+
[CAP-0077](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0077.md)
298+
for a more robust alternative. The `FILTERED_G_ADDRESSES` configuration
299+
option is likewise deprecated and has no effect.
300+
301+
* **unbanaccounts** (deprecated)
302+
Account banning has been removed; this endpoint is kept for backwards
303+
compatibility and only returns a deprecation warning.
315304

316305
* **checkdb**
317306
Triggers the instance to perform a background check of the database's state.
@@ -399,10 +388,9 @@ Most commands return their results in JSON format.
399388
* "FILTERED" - transaction rejected because it contains an operation type that Stellar Core filters out. See Stellar Core configuration `EXCLUDE_TRANSACTIONS_CONTAINING_OPERATION_TYPE` for more details.
400389

401390
Optional parameters:
402-
* `force=true` - bypasses banned account filtering (see `banaccounts`),
403-
allowing the transaction into the mempool even if its source account or
404-
fee source is on the ban list. Other filtering (operation type, Soroban
405-
key filtering) still applies. Example: `tx?blob=Base64&force=true`
391+
* `force=true` - deprecated and has no effect (it used to bypass
392+
banned account filtering, which has been removed). Accepted for
393+
backwards compatibility; the response includes a deprecation warning.
406394

407395
* **upgrades**
408396
* `upgrades?mode=get`<br>

src/database/Database.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "database/DatabaseConnectionString.h"
88
#include "database/DatabaseTypeSpecificOperation.h"
99
#include "main/Application.h"
10-
#include "main/BannedAccountsPersistor.h"
1110
#include "main/Config.h"
1211
#include "overlay/StellarXDR.h"
1312
#include "util/Decoder.h"
@@ -309,8 +308,13 @@ Database::applyMiscSchemaUpgrade(unsigned long vers)
309308
getRawMiscSession() << "DETACH DATABASE source_db";
310309
return;
311310
case 2:
312-
// Add banned accounts table for persistent account filtering.
313-
BannedAccountsPersistor::maybeDropAndCreateNew(mMiscSession.session());
311+
getRawMiscSession() << "DROP TABLE IF EXISTS bannedaccounts;";
312+
getRawMiscSession() << "CREATE TABLE bannedaccounts (accountid "
313+
"VARCHAR(56) PRIMARY KEY);";
314+
break;
315+
case 3:
316+
// The account banning feature was removed; drop its table.
317+
getRawMiscSession() << "DROP TABLE IF EXISTS bannedaccounts;";
314318
break;
315319
default:
316320
throw std::runtime_error("Unknown DB schema version");
@@ -407,12 +411,17 @@ Database::applySchemaUpgrade(unsigned long vers)
407411
// for Postgres and in-memory SQLite, create in the main DB.
408412
if (!canUseMiscDB())
409413
{
410-
BannedAccountsPersistor::maybeDropAndCreateNew(getRawSession());
414+
getRawSession() << "DROP TABLE IF EXISTS bannedaccounts;";
415+
getRawSession() << "CREATE TABLE bannedaccounts (accountid "
416+
"VARCHAR(56) PRIMARY KEY);";
411417
}
412418
break;
413419
case 28:
414420
migrateLedgerHeadersToStoreState(*this);
415421
break;
422+
case 29:
423+
getRawSession() << "DROP TABLE IF EXISTS bannedaccounts;";
424+
break;
416425

417426
default:
418427
throw std::runtime_error("Unknown DB schema version");

src/database/Database.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class Application;
2929

3030
// smallest schema version supported
3131
static constexpr unsigned long MIN_SCHEMA_VERSION = 25;
32-
static constexpr unsigned long SCHEMA_VERSION = 28;
32+
static constexpr unsigned long SCHEMA_VERSION = 29;
3333
static constexpr unsigned long FIRST_MAIN_VERSION_WITH_MISC = 26;
3434
// Misc schema version 0 means no misc table exists yet
3535
static constexpr unsigned long MIN_MISC_SCHEMA_VERSION = 0;
36-
static constexpr unsigned long MISC_SCHEMA_VERSION = 2;
36+
static constexpr unsigned long MISC_SCHEMA_VERSION = 3;
3737

3838
/**
3939
* Helper class for borrowing a SOCI prepared statement handle into a local

src/database/test/DatabaseTests.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "ledger/test/LedgerTestUtils.h"
1313
#include "lib/util/stdrandom.h"
1414
#include "main/Application.h"
15-
#include "main/BannedAccountsPersistor.h"
1615
#include "main/Config.h"
1716
#include "main/PersistentState.h"
1817
#include "overlay/BanManager.h"
@@ -715,10 +714,6 @@ TEST_CASE("schema parity across DB backends", "[db][schematest]")
715714
TmpDir tmpDir("schema-parity-test");
716715
Config cfg1 = getTestConfig(0, Config::TESTDB_BUCKET_DB_PERSISTENT);
717716
cfg1.DATABASE = SecretValue{"sqlite3://" + tmpDir.getName() + "/test.db"};
718-
// Use non-empty FILTERED_G_ADDRESSES to test migration as well
719-
cfg1.FILTERED_G_ADDRESSES = {
720-
"GBO7VUL2TOKPWFAWKATIW7K3QYA7WQ63VDY5CAE6AFUUX6BHZBOC2WXC",
721-
"GATDQL767ZM2JQTBEG4BQ5WKOQNGAGWZDUN4GYT2UINPEU3RT2UAMVZH"};
722717

723718
VirtualClock clock1;
724719
Application::pointer app1 = createTestApplication(clock1, cfg1);
@@ -744,9 +739,6 @@ TEST_CASE("schema parity across DB backends", "[db][schematest]")
744739

745740
// ---- PostgreSQL: compare tables and row counts ----
746741
Config cfg2 = getTestConfig(1, Config::TESTDB_POSTGRESQL);
747-
cfg2.FILTERED_G_ADDRESSES = {
748-
"GBO7VUL2TOKPWFAWKATIW7K3QYA7WQ63VDY5CAE6AFUUX6BHZBOC2WXC",
749-
"GATDQL767ZM2JQTBEG4BQ5WKOQNGAGWZDUN4GYT2UINPEU3RT2UAMVZH"};
750742

751743
VirtualClock clock2;
752744
Application::pointer app2 = createTestApplication(clock2, cfg2);

src/herder/Herder.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,10 @@ class Herder
150150
// generator, and therefore can skip certain expensive validity checks
151151
virtual TransactionQueue::AddResult
152152
recvTransaction(TransactionFrameBasePtr tx, bool submittedFromSelf,
153-
bool force = false, bool isLoadgenTx = false) = 0;
153+
bool isLoadgenTx = false) = 0;
154154
#else
155155
virtual TransactionQueue::AddResult
156-
recvTransaction(TransactionFrameBasePtr tx, bool submittedFromSelf,
157-
bool force = false) = 0;
156+
recvTransaction(TransactionFrameBasePtr tx, bool submittedFromSelf) = 0;
158157
#endif
159158
virtual void peerDoesntHave(stellar::MessageType type,
160159
uint256 const& itemID, Peer::pointer peer) = 0;
@@ -225,9 +224,6 @@ class Herder
225224
// gets the upgrades that are scheduled by this node
226225
virtual std::string getUpgradesJson() = 0;
227226

228-
// Override the filtered accounts at runtime using pre-parsed AccountIDs.
229-
virtual void setFilteredAccounts(std::set<AccountID> const& accounts) = 0;
230-
231227
virtual void forceSCPStateIntoSyncWithLastClosedLedger() = 0;
232228

233229
// helper function to craft an SCPValue

src/herder/HerderImpl.cpp

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,7 @@ HerderImpl::emitEnvelope(SCPEnvelope const& envelope)
629629
}
630630

631631
TransactionQueue::AddResult
632-
HerderImpl::recvTransaction(TransactionFrameBasePtr tx, bool submittedFromSelf,
633-
bool force
632+
HerderImpl::recvTransaction(TransactionFrameBasePtr tx, bool submittedFromSelf
634633
#ifdef BUILD_TESTS
635634
,
636635
bool isLoadgenTx
@@ -672,7 +671,7 @@ HerderImpl::recvTransaction(TransactionFrameBasePtr tx, bool submittedFromSelf,
672671
}
673672
else if (!tx->isSoroban())
674673
{
675-
result = mTransactionQueue.tryAdd(tx, submittedFromSelf, force
674+
result = mTransactionQueue.tryAdd(tx, submittedFromSelf
676675
#ifdef BUILD_TESTS
677676
,
678677
isLoadgenTx
@@ -681,7 +680,7 @@ HerderImpl::recvTransaction(TransactionFrameBasePtr tx, bool submittedFromSelf,
681680
}
682681
else if (mSorobanTransactionQueue)
683682
{
684-
result = mSorobanTransactionQueue->tryAdd(tx, submittedFromSelf, force
683+
result = mSorobanTransactionQueue->tryAdd(tx, submittedFromSelf
685684
#ifdef BUILD_TESTS
686685
,
687686
isLoadgenTx
@@ -1864,16 +1863,6 @@ HerderImpl::getUpgradesJson()
18641863
return mUpgrades.getParameters().toDebugJson(ledgerView);
18651864
}
18661865

1867-
void
1868-
HerderImpl::setFilteredAccounts(std::set<AccountID> const& accounts)
1869-
{
1870-
mTransactionQueue.setFilteredAccounts(accounts);
1871-
if (mSorobanTransactionQueue)
1872-
{
1873-
mSorobanTransactionQueue->setFilteredAccounts(accounts);
1874-
}
1875-
}
1876-
18771866
void
18781867
HerderImpl::forceSCPStateIntoSyncWithLastClosedLedger()
18791868
{
@@ -2552,8 +2541,6 @@ HerderImpl::maybeSetupSorobanQueue(uint32_t protocolVersion)
25522541
TRANSACTION_QUEUE_BAN_LEDGERS,
25532542
mApp.getConfig().SOROBAN_TRANSACTION_QUEUE_SIZE_MULTIPLIER,
25542543
recomputeKeysToFilter(protocolVersion));
2555-
setFilteredAccounts(
2556-
mApp.getBannedAccountsPersistor().getBannedAccounts());
25572544
}
25582545
}
25592546
else if (mSorobanTransactionQueue)
@@ -2627,22 +2614,6 @@ HerderImpl::start()
26272614
restoreUpgrades();
26282615
startTxSetGCTimer();
26292616
startCheckForDeadNodesInterval();
2630-
2631-
auto& bap = mApp.getBannedAccountsPersistor();
2632-
if (!mApp.getConfig().FILTERED_G_ADDRESSES.empty())
2633-
{
2634-
CLOG_WARNING(
2635-
Herder,
2636-
"FILTERED_G_ADDRESSES is deprecated and will be removed in a "
2637-
"future release. The current {} address(es) will be stored in the "
2638-
"database. You can safely remove FILTERED_G_ADDRESSES from the "
2639-
"config. Use 'banaccounts'/'unbanaccounts' HTTP commands to manage "
2640-
"banned accounts going forward.",
2641-
mApp.getConfig().FILTERED_G_ADDRESSES.size());
2642-
bap.addBannedAccounts(mApp.getConfig().FILTERED_G_ADDRESSES);
2643-
}
2644-
2645-
setFilteredAccounts(bap.getBannedAccounts());
26462617
}
26472618

26482619
void

src/herder/HerderImpl.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ class HerderImpl : public Herder
101101
#ifdef BUILD_TESTS
102102
TransactionQueue::AddResult
103103
recvTransaction(TransactionFrameBasePtr tx, bool submittedFromSelf,
104-
bool force = false, bool isLoadgenTx = false) override;
104+
bool isLoadgenTx = false) override;
105105
#else
106-
TransactionQueue::AddResult recvTransaction(TransactionFrameBasePtr tx,
107-
bool submittedFromSelf,
108-
bool force = false) override;
106+
TransactionQueue::AddResult
107+
recvTransaction(TransactionFrameBasePtr tx,
108+
bool submittedFromSelf) override;
109109
#endif
110110

111111
EnvelopeStatus recvSCPEnvelope(SCPEnvelope const& envelope) override;
@@ -195,8 +195,6 @@ class HerderImpl : public Herder
195195
void setUpgrades(Upgrades::UpgradeParameters const& upgrades) override;
196196
std::string getUpgradesJson() override;
197197

198-
void setFilteredAccounts(std::set<AccountID> const& accounts) override;
199-
200198
void forceSCPStateIntoSyncWithLastClosedLedger() override;
201199

202200
bool resolveNodeID(std::string const& s, PublicKey& retKey) override;

src/herder/TransactionQueue.cpp

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,10 @@ TransactionQueue::TransactionQueue(Application& app, uint32 pendingDepth,
109109
app.getConfig().EXCLUDE_TRANSACTIONS_CONTAINING_OPERATION_TYPE;
110110
mFilteredTypes.insert(filteredTypes.begin(), filteredTypes.end());
111111

112-
for (auto const& addr : app.getConfig().FILTERED_G_ADDRESSES)
113-
{
114-
mFilteredAccounts.emplace(KeyUtils::fromStrKey<PublicKey>(addr));
115-
}
116-
117112
mBroadcastSeed =
118113
rand_uniform<uint64>(0, std::numeric_limits<uint64>::max());
119114
}
120115

121-
void
122-
TransactionQueue::setFilteredAccounts(std::set<AccountID> const& accounts)
123-
{
124-
mFilteredAccounts = accounts;
125-
}
126-
127116
ClassicTransactionQueue::ClassicTransactionQueue(Application& app,
128117
uint32 pendingDepth,
129118
uint32 banDepth,
@@ -153,9 +142,7 @@ ClassicTransactionQueue::ClassicTransactionQueue(Application& app,
153142
app.getMetrics().NewCounter(
154143
{"herder", "pending-txs", "not-included-due-to-low-fee-count"}),
155144
app.getMetrics().NewCounter(
156-
{"herder", "pending-txs", "filtered-due-to-fp-keys"}),
157-
app.getMetrics().NewCounter(
158-
{"herder", "pending-txs", "filtered-due-to-account-keys"}));
145+
{"herder", "pending-txs", "filtered-due-to-fp-keys"}));
159146
mBroadcastOpCarryover.resize(1,
160147
Resource::makeEmpty(NUM_CLASSIC_TX_RESOURCES));
161148
}
@@ -315,8 +302,7 @@ TransactionQueue::sourceAccountPending(AccountID const& accountID) const
315302
TransactionQueue::AddResult
316303
TransactionQueue::canAdd(
317304
TransactionFrameBasePtr tx, AccountStates::iterator& stateIter,
318-
std::vector<std::pair<TransactionFrameBasePtr, bool>>& txsToEvict,
319-
bool force
305+
std::vector<std::pair<TransactionFrameBasePtr, bool>>& txsToEvict
320306
#ifdef BUILD_TESTS
321307
,
322308
bool isLoadgenTx
@@ -338,12 +324,6 @@ TransactionQueue::canAdd(
338324
mQueueMetrics->mTxsFilteredDueToFootprintKeys.inc();
339325
return AddResult(TransactionQueue::AddResultCode::ADD_STATUS_FILTERED);
340326
}
341-
if (!force && !tx->validateAccountFilterForFlooding(mFilteredAccounts))
342-
{
343-
mQueueMetrics->mTxsFilteredDueToAccountKeys.inc();
344-
return AddResult(TransactionQueue::AddResultCode::ADD_STATUS_FILTERED);
345-
}
346-
347327
int64_t newFullFee = tx->getFullFee();
348328
if (newFullFee < 0 || tx->getInclusionFee() < 0)
349329
{
@@ -673,8 +653,7 @@ TransactionQueue::findAllAssetPairsInvolvedInPaymentLoops(
673653
}
674654

675655
TransactionQueue::AddResult
676-
TransactionQueue::tryAdd(TransactionFrameBasePtr tx, bool submittedFromSelf,
677-
bool force
656+
TransactionQueue::tryAdd(TransactionFrameBasePtr tx, bool submittedFromSelf
678657
#ifdef BUILD_TESTS
679658
,
680659
bool isLoadgenTx
@@ -692,7 +671,7 @@ TransactionQueue::tryAdd(TransactionFrameBasePtr tx, bool submittedFromSelf,
692671
AccountStates::iterator stateIter;
693672

694673
std::vector<std::pair<TransactionFrameBasePtr, bool>> txsToEvict;
695-
auto res = canAdd(tx, stateIter, txsToEvict, force
674+
auto res = canAdd(tx, stateIter, txsToEvict
696675
#ifdef BUILD_TESTS
697676
,
698677
isLoadgenTx
@@ -1122,9 +1101,7 @@ SorobanTransactionQueue::SorobanTransactionQueue(
11221101
app.getMetrics().NewCounter({"herder", "pending-soroban-txs",
11231102
"not-included-due-to-low-fee-count"}),
11241103
app.getMetrics().NewCounter(
1125-
{"herder", "pending-soroban-txs", "filtered-due-to-fp-keys"}),
1126-
app.getMetrics().NewCounter(
1127-
{"herder", "pending-soroban-txs", "filtered-due-to-account-keys"}));
1104+
{"herder", "pending-soroban-txs", "filtered-due-to-fp-keys"}));
11281105
mBroadcastOpCarryover.resize(1, Resource::makeEmptySoroban());
11291106
mKeysToFilter = keysToFilter;
11301107
}

0 commit comments

Comments
 (0)