public void Setup()
        {
            _svc = new Nethermind.Network.Test.Builders.SerializationBuilder()
                   .With(new UserOperationsMessageSerializer()).TestObject;

            NetworkDiagTracer.IsEnabled = true;

            _session = Substitute.For <ISession>();
            Node node = new(TestItem.PublicKeyA, new IPEndPoint(IPAddress.Broadcast, 30303));

            _session.Node.Returns(node);
            _userOperationPools = new Dictionary <Address, IUserOperationPool>();
            UserOperationBroadcaster      _broadcaster = new UserOperationBroadcaster(NullLogger.Instance);
            AccountAbstractionPeerManager _peerManager = new AccountAbstractionPeerManager(_userOperationPools, _broadcaster, NullLogger.Instance);
            ITimerFactory timerFactory = Substitute.For <ITimerFactory>();

            _handler = new AaProtocolHandler(
                _session,
                _svc,
                new NodeStatsManager(timerFactory, LimboLogs.Instance),
                _userOperationPools,
                _peerManager,
                LimboLogs.Instance);
            _handler.Init();

            AccountAbstractionRpcModule aaRpcModule = new(_userOperationPools, new Address[] {});
Ejemplo n.º 2
0
            protected override BlockProcessor CreateBlockProcessor()
            {
                // Address.TryParse(_accountAbstractionConfig.EntryPointContractAddress, out Address? entryPointContractAddress);
                IList <Address> entryPointContractAddresses        = new List <Address>();
                IList <string>  _entryPointContractAddressesString = _accountAbstractionConfig.GetEntryPointAddresses().ToList();

                foreach (string _addressString in _entryPointContractAddressesString)
                {
                    bool parsed = Address.TryParse(
                        _addressString,
                        out Address? entryPointContractAddress);
                    entryPointContractAddresses.Add(entryPointContractAddress !);
                }

                EntryPointAddresses = entryPointContractAddresses.ToArray();
                Address.TryParse(_accountAbstractionConfig.Create2FactoryAddress, out Address? create2FactoryAddress);
                BlockValidator = CreateBlockValidator();
                BlockProcessor blockProcessor = new(
                    SpecProvider,
                    BlockValidator,
                    NoBlockRewards.Instance,
                    new BlockProcessor.BlockValidationTransactionsExecutor(TxProcessor, State),
                    State,
                    Storage,
                    ReceiptStorage,
                    NullWitnessCollector.Instance,
                    LogManager);

                var parser = new AbiDefinitionParser();

                parser.RegisterAbiTypeFactory(new AbiTuple <UserOperationAbi>());
                var json = parser.LoadContract(typeof(EntryPoint));

                EntryPointContractAbi = parser.Parse(json);

                foreach (Address entryPoint in entryPointContractAddresses)
                {
                    UserOperationTxBuilder[entryPoint] = new UserOperationTxBuilder(
                        EntryPointContractAbi,
                        Signer,
                        entryPoint !,
                        SpecProvider,
                        State);
                }

                foreach (Address entryPoint in entryPointContractAddresses)
                {
                    UserOperationSimulator[entryPoint] = new(
                        UserOperationTxBuilder[entryPoint],
                        State,
                        StateReader,
                        EntryPointContractAbi,
                        create2FactoryAddress !,
                        entryPoint !,
                        SpecProvider,
                        BlockTree,
                        DbProvider,
                        ReadOnlyTrieStore,
                        Timestamper,
                        LogManager);
                }

                IUserOperationBroadcaster broadcaster = new UserOperationBroadcaster(LogManager.GetClassLogger());

                foreach (Address entryPoint in entryPointContractAddresses)
                {
                    UserOperationPool[entryPoint] = new UserOperationPool(
                        _accountAbstractionConfig,
                        BlockTree,
                        entryPoint !,
                        LogManager.GetClassLogger(),
                        new PaymasterThrottler(),
                        LogFinder,
                        Signer,
                        State,
                        Timestamper,
                        UserOperationSimulator[entryPoint],
                        new UserOperationSortedPool(
                            _accountAbstractionConfig.UserOperationPoolSize,
                            new CompareUserOperationsByDecreasingGasPrice(),
                            LogManager,
                            _accountAbstractionConfig.MaximumUserOperationPerSender),
                        broadcaster,
                        SpecProvider.ChainId);
                }

                return(blockProcessor);
            }