public void event_hash_is_valid()
        {
            AbiDefinitionParser parser          = new AbiDefinitionParser();
            AbiDefinition       abiDefinition   = parser.Parse(File.ReadAllText("contracts/validator_registration.json"));
            DepositContract     depositContract = new DepositContract(abiDefinition, new AbiEncoder(), Address.Zero);

            depositContract.DepositEventHash.Should().Be(new Keccak("0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"));
        }
        public void Can_load_contract(Type contractType)
        {
            var parser     = new AbiDefinitionParser();
            var json       = parser.LoadContract(contractType);
            var contract   = parser.Parse(json);
            var serialized = parser.Serialize(contract);

            JToken.Parse(serialized).Should().ContainSubtree(json);
        }
        public void can_make_deposit()
        {
            AbiDefinitionParser parser          = new AbiDefinitionParser();
            AbiDefinition       abiDefinition   = parser.Parse(File.ReadAllText("contracts/validator_registration.json"));
            DepositContract     depositContract = new DepositContract(abiDefinition, new AbiEncoder(), Address.Zero);
            Transaction         transaction     = depositContract.Deposit(TestItem.AddressA, new byte[42], new byte[32], new byte[96], new byte[32]);

            transaction.Data.Should().HaveCount(484);
        }
Exemple #4
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);
            }
Exemple #5
0
            protected override BlockProcessor CreateBlockProcessor()
            {
                Address.TryParse(_accountAbstractionConfig.EntryPointContractAddress, out Address? entryPointContractAddress);
                Address.TryParse(_accountAbstractionConfig.Create2FactoryAddress, out Address? create2FactoryAddress);
                EntryPointAddress = entryPointContractAddress !;

                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);

                UserOperationTxBuilder = new UserOperationTxBuilder(
                    EntryPointContractAbi,
                    Signer,
                    entryPointContractAddress !,
                    SpecProvider,
                    State);

                UserOperationSimulator = new(
                    UserOperationTxBuilder,
                    State,
                    StateReader,
                    EntryPointContractAbi,
                    create2FactoryAddress !,
                    entryPointContractAddress !,
                    SpecProvider,
                    BlockTree,
                    DbProvider,
                    ReadOnlyTrieStore,
                    Timestamper,
                    LogManager);

                UserOperationPool = new UserOperationPool(
                    _accountAbstractionConfig,
                    BlockTree,
                    entryPointContractAddress !,
                    LogManager.GetClassLogger(),
                    new PaymasterThrottler(),
                    LogFinder,
                    Signer,
                    State,
                    Timestamper,
                    UserOperationSimulator,
                    new UserOperationSortedPool(
                        _accountAbstractionConfig.UserOperationPoolSize,
                        new CompareUserOperationsByDecreasingGasPrice(),
                        LogManager,
                        _accountAbstractionConfig.MaximumUserOperationPerSender),
                    SpecProvider.ChainId);

                return(blockProcessor);
            }