From fdae9233aff36de604b9a160a7bc105ca870cc62 Mon Sep 17 00:00:00 2001 From: Jiwon Date: Wed, 11 Oct 2023 10:28:15 +0900 Subject: [PATCH] Merge pull request #2168 from planetarium/feat/disallowed-accounts [Feature] Add access control service interface --- .../IAccessControlService.cs | 9 ++++++ Lib9c.Policy/NCStagePolicy.cs | 30 ++++--------------- 2 files changed, 14 insertions(+), 25 deletions(-) create mode 100644 Lib9c.Policy/AccessControlService/IAccessControlService.cs diff --git a/Lib9c.Policy/AccessControlService/IAccessControlService.cs b/Lib9c.Policy/AccessControlService/IAccessControlService.cs new file mode 100644 index 0000000000..4bbb032430 --- /dev/null +++ b/Lib9c.Policy/AccessControlService/IAccessControlService.cs @@ -0,0 +1,9 @@ +using Libplanet.Crypto; + +namespace Nekoyume.Blockchain +{ + public interface IAccessControlService + { + public bool IsAccessDenied(Address address); + } +} diff --git a/Lib9c.Policy/NCStagePolicy.cs b/Lib9c.Policy/NCStagePolicy.cs index dac09c7ad1..dec62b5687 100644 --- a/Lib9c.Policy/NCStagePolicy.cs +++ b/Lib9c.Policy/NCStagePolicy.cs @@ -15,31 +15,9 @@ public class NCStagePolicy : IStagePolicy private readonly VolatileStagePolicy _impl; private readonly ConcurrentDictionary> _txs; private readonly int _quotaPerSigner; + private IAccessControlService? _accessControlService; - private static readonly ImmutableHashSet
_bannedAccounts = new[] - { - new Address("de96aa7702a7a1fd18ee0f84a5a0c7a2c28ec840"), - new Address("153281c93274bEB9726A03C33d3F19a8D78ad805"), - new Address("7035AA8B7F9fB5db026fb843CbB21C03dd278502"), - new Address("52393Ea89DF0E58152cbFE673d415159aa7B9dBd"), - new Address("2D1Db6dBF1a013D648Efd16d85B4079dCF88B4CC"), - new Address("dE30E00917B583305f14aD21Eafc70f1b183b779"), - new Address("B892052f1E10bf700143dd9bEcd81E31CD7f7095"), - - new Address("C0a90FC489738A1153F793A3272A91913aF3956b"), - new Address("b8D7bD4394980dcc2579019C39bA6b41cb6424E1"), - new Address("555221D1CEA826C55929b8A559CA929574f7C6B3"), - new Address("B892052f1E10bf700143dd9bEcd81E31CD7f7095"), - // v100351 - new Address("0xd7e1b90dea34108fb2d3a6ac7dbf3f33bae2c77d"), - // v200060 - new Address("3FadCb61827E4B70eBAFAF61E2c02fc2711FBb5A"), - new Address("7655122899Ccd2cC87B38A35D7158c9516504119"), - new Address("3165fda4aAE0362EFFd8Ae6e8674AA49381b4485"), - new Address("CAFC88175f88973d01e6A9479b31eC0beb020b8a"), - }.ToImmutableHashSet(); - - public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner) + public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner, IAccessControlService? accessControlService = null) { if (quotaPerSigner < 1) { @@ -52,6 +30,8 @@ public NCStagePolicy(TimeSpan txLifeTime, int quotaPerSigner) _impl = (txLifeTime == default) ? new VolatileStagePolicy() : new VolatileStagePolicy(txLifeTime); + + _accessControlService = accessControlService; } public Transaction Get(BlockChain blockChain, TxId id, bool filtered = true) @@ -97,7 +77,7 @@ public IEnumerable Iterate(BlockChain blockChain, bool filtered = t public bool Stage(BlockChain blockChain, Transaction transaction) { - if (_bannedAccounts.Contains(transaction.Signer)) + if (_accessControlService != null && _accessControlService.IsAccessDenied(transaction.Signer)) { return false; }