public void Throws_on_theoretical_contract_crash() { var contractAddress = Address.OfContract(_senderPublicKey.ToKvmAddress(), 0); _stateProvider.CreateAccount(contractAddress, 1000.Kat()); var codeHash = _stateProvider.UpdateCode(Bytes.FromHexString("0x01")); _stateProvider.UpdateCodeHash(contractAddress, codeHash, _specProvider.GenesisSpec); _stateProvider.Commit(_specProvider.GenesisSpec); var delta = EntryUtils.PrepareSingleContractEntryDelta(null, _senderPublicKey, 0, "0x60016000526001601FF300"); delta.PublicEntries[0].GasLimit = 1_000_000L; delta.PublicEntries[0].ReceiverAddress = ByteString.Empty; delta.PublicEntries[0].Signature = delta.PublicEntries[0] .GenerateSignature(_cryptoContext, _senderPrivateKey, _signingContext); var tracer = Substitute.For <ITxTracer>(); tracer.IsTracingReceipt.Returns(true); _executor.Execute(delta, tracer); tracer.Received().MarkAsFailed(contractAddress, 1_000_000L, Arg.Any <byte[]>(), null); }
/** * @TODO this should extend file system based tests and resolve tests via autofac container */ public DeltaExecutorTests() { _specProvider = new CatalystSpecProvider(); _stateProvider = new StateProvider(new StateDb(), new StateDb(), LimboLogs.Instance); var storageProvider = new StorageProvider(new StateDb(), _stateProvider, LimboLogs.Instance); IKvm virtualMachine = new KatVirtualMachine(_stateProvider, storageProvider, new StateUpdateHashProvider(), _specProvider, LimboLogs.Instance); var logger = Substitute.For <ILogger>(); logger.IsEnabled(Arg.Any <LogEventLevel>()).Returns(true); _senderPrivateKey = _cryptoContext.GeneratePrivateKey(); _senderPublicKey = _senderPrivateKey.GetPublicKey(); _recipient = _cryptoContext.GeneratePrivateKey().GetPublicKey(); _poorSender = _cryptoContext.GeneratePrivateKey().GetPublicKey(); _stateProvider.CreateAccount(_poorSender.ToKvmAddress(), 0.Kat()); _stateProvider.CreateAccount(_senderPublicKey.ToKvmAddress(), 1000.Kat()); _stateProvider.CreateAccount(Address.Zero, 1000.Kat()); _stateProvider.Commit(_specProvider.GenesisSpec); _executor = new DeltaExecutor(_specProvider, _stateProvider, storageProvider, virtualMachine, new FfiWrapper(), logger); _signingContext = new SigningContext { NetworkType = NetworkType.Devnet, SignatureType = SignatureType.TransactionPublic }; }
public void Can_collect_stats() { MemDb memDb = new MemDb(); IDb stateDb = memDb; TrieStore trieStore = new TrieStore(stateDb, new MemoryLimit(0.MB()), Persist.EveryBlock, LimboLogs.Instance); StateProvider stateProvider = new StateProvider(trieStore, stateDb, LimboLogs.Instance); StorageProvider storageProvider = new StorageProvider(trieStore, stateProvider, LimboLogs.Instance); stateProvider.CreateAccount(TestItem.AddressA, 1); Keccak codeHash = stateProvider.UpdateCode(new byte[] { 1, 2, 3 }); stateProvider.UpdateCodeHash(TestItem.AddressA, codeHash, Istanbul.Instance); stateProvider.CreateAccount(TestItem.AddressB, 1); Keccak codeHash2 = stateProvider.UpdateCode(new byte[] { 1, 2, 3, 4 }); stateProvider.UpdateCodeHash(TestItem.AddressB, codeHash2, Istanbul.Instance); for (int i = 0; i < 1000; i++) { StorageCell storageCell = new StorageCell(TestItem.AddressA, (UInt256)i); storageProvider.Set(storageCell, new byte[] { (byte)i }); } storageProvider.Commit(); stateProvider.Commit(Istanbul.Instance); storageProvider.CommitTrees(0); stateProvider.CommitTree(0); storageProvider.CommitTrees(1); stateProvider.CommitTree(1); memDb.Delete(codeHash2); // missing code Keccak storageKey = new Keccak("0x345e54154080bfa9e8f20c99d7a0139773926479bc59e5b4f830ad94b6425332"); memDb.Delete(storageKey); // deletes some storage trieStore.ClearCache(); TrieStatsCollector statsCollector = new TrieStatsCollector(stateDb, LimboLogs.Instance); stateProvider.Accept(statsCollector, stateProvider.StateRoot); var stats = statsCollector.Stats; stats.CodeCount.Should().Be(1); stats.MissingCode.Should().Be(1); stats.NodesCount.Should().Be(1348); stats.StateBranchCount.Should().Be(1); stats.StateExtensionCount.Should().Be(1); stats.AccountCount.Should().Be(2); stats.StorageCount.Should().Be(1343); stats.StorageBranchCount.Should().Be(337); stats.StorageExtensionCount.Should().Be(12); stats.StorageLeafCount.Should().Be(994); stats.MissingStorage.Should().Be(1); }
private void AddAccount(StateProvider stateProvider, Address account, UInt256 initialBalance) { stateProvider.CreateAccount(account, initialBalance); stateProvider.Commit(MuirGlacier.Instance, null); stateProvider.CommitTree(); _dbProvider.StateDb.Commit(); }
public void Restore_update_restore() { StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(_address1, 0); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.Restore(4); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.Restore(4); Assert.AreEqual((UInt256)4, provider.GetBalance(_address1)); }
public void GlobalSetup() { ByteCode = Bytes.FromHexString(Environment.GetEnvironmentVariable("NETH.BENCHMARK.BYTECODE") ?? string.Empty); Console.WriteLine($"Running benchmark for bytecode {ByteCode?.ToHexString()}"); TrieStore trieStore = new(new MemDb(), new OneLoggerLogManager(NullLogger.Instance)); IKeyValueStore codeDb = new MemDb(); _stateProvider = new StateProvider(trieStore, codeDb, new OneLoggerLogManager(NullLogger.Instance)); _stateProvider.CreateAccount(Address.Zero, 1000.Ether()); _stateProvider.Commit(_spec); _storageProvider = new StorageProvider(trieStore, _stateProvider, new OneLoggerLogManager(NullLogger.Instance)); _worldState = new WorldState(_stateProvider, _storageProvider); _virtualMachine = new VirtualMachine(_blockhashProvider, MainnetSpecProvider.Instance, LimboLogs.Instance); _environment = new ExecutionEnvironment { ExecutingAccount = Address.Zero, CodeSource = Address.Zero, Caller = Address.Zero, CodeInfo = new CodeInfo(ByteCode), Value = 0, TransferValue = 0, TxExecutionContext = new TxExecutionContext(_header, Address.Zero, 0) }; _evmState = new EvmState(long.MaxValue, _environment, ExecutionType.Transaction, true, _worldState.TakeSnapshot(), false); }
public void GlobalSetup() { ISnapshotableDb codeDb = new StateDb(); ISnapshotableDb stateDb = new StateDb(); IDb blockInfoDb = new MemDb(10, 5); ISpecProvider specProvider = MainNetSpecProvider.Instance; IReleaseSpec spec = MainNetSpecProvider.Instance.GenesisSpec; StateProvider stateProvider = new StateProvider(stateDb, codeDb, LimboLogs.Instance); stateProvider.CreateAccount(Address.Zero, 1000.Ether()); stateProvider.Commit(spec); StorageProvider storageProvider = new StorageProvider(stateDb, stateProvider, LimboLogs.Instance); StateReader stateReader = new StateReader(stateDb, codeDb, LimboLogs.Instance); ChainLevelInfoRepository chainLevelInfoRepository = new ChainLevelInfoRepository(blockInfoDb); BlockTree blockTree = new BlockTree(new MemDb(), new MemDb(), blockInfoDb, chainLevelInfoRepository, specProvider, NullTxPool.Instance, LimboLogs.Instance); _blockhashProvider = new BlockhashProvider(blockTree, LimboLogs.Instance); _virtualMachine = new VirtualMachine(stateProvider, storageProvider, _blockhashProvider, specProvider, LimboLogs.Instance); Block genesisBlock = Build.A.Block.Genesis.TestObject; blockTree.SuggestBlock(genesisBlock); Block block1 = Build.A.Block.WithParent(genesisBlock).WithNumber(1).TestObject; blockTree.SuggestBlock(block1); TransactionProcessor transactionProcessor = new TransactionProcessor(MainNetSpecProvider.Instance, stateProvider, storageProvider, _virtualMachine, LimboLogs.Instance); BlockProcessor blockProcessor = new BlockProcessor(specProvider, AlwaysValidBlockValidator.Instance, new RewardCalculator(specProvider), transactionProcessor, stateDb, codeDb, new MemDb(), stateProvider, storageProvider, NullTxPool.Instance, NullReceiptStorage.Instance, LimboLogs.Instance); BlockchainProcessor blockchainProcessor = new BlockchainProcessor( blockTree, blockProcessor, new TxSignaturesRecoveryStep(new EthereumEcdsa(specProvider, LimboLogs.Instance), NullTxPool.Instance, LimboLogs.Instance), LimboLogs.Instance, false, false); blockchainProcessor.Process(genesisBlock, ProcessingOptions.None, NullBlockTracer.Instance); blockchainProcessor.Process(block1, ProcessingOptions.None, NullBlockTracer.Instance); BlockchainBridge bridge = new BlockchainBridge( stateReader, stateProvider, storageProvider, blockTree, NullTxPool.Instance, NullReceiptStorage.Instance, NullFilterStore.Instance, NullFilterManager.Instance, new DevWallet(new WalletConfig(), LimboLogs.Instance), transactionProcessor, new EthereumEcdsa(MainNetSpecProvider.Instance, LimboLogs.Instance)); _ethModule = new EthModule(LimboLogs.Instance, bridge); }
public async Task Can_ask_about_storage_in_parallel() { StorageCell storageCell = new StorageCell(_address1, UInt256.One); IReleaseSpec spec = MuirGlacier.Instance; MemDb stateDb = new MemDb(); TrieStore trieStore = new TrieStore(stateDb, Logger); StateProvider provider = new StateProvider(trieStore, new MemDb(), Logger); StorageProvider storageProvider = new StorageProvider(trieStore, provider, Logger); void UpdateStorageValue(byte[] newValue) { storageProvider.Set(storageCell, newValue); } void AddOneToBalance() { provider.AddToBalance(_address1, 1, spec); } void CommitEverything() { storageProvider.Commit(); storageProvider.CommitTrees(0); provider.Commit(spec); provider.CommitTree(0); } provider.CreateAccount(_address1, 1); CommitEverything(); AddOneToBalance(); UpdateStorageValue(new byte[] { 1 }); CommitEverything(); Keccak stateRoot0 = provider.StateRoot; AddOneToBalance(); UpdateStorageValue(new byte[] { 2 }); CommitEverything(); Keccak stateRoot1 = provider.StateRoot; AddOneToBalance(); UpdateStorageValue(new byte[] { 3 }); CommitEverything(); Keccak stateRoot2 = provider.StateRoot; AddOneToBalance(); UpdateStorageValue(new byte[] { 4 }); CommitEverything(); Keccak stateRoot3 = provider.StateRoot; StateReader reader = new StateReader(new TrieStore(stateDb, LimboLogs.Instance), Substitute.For <IDb>(), Logger); Task a = StartStorageTask(reader, stateRoot0, storageCell, new byte[] { 1 }); Task b = StartStorageTask(reader, stateRoot1, storageCell, new byte[] { 2 }); Task c = StartStorageTask(reader, stateRoot2, storageCell, new byte[] { 3 }); Task d = StartStorageTask(reader, stateRoot3, storageCell, new byte[] { 4 }); await Task.WhenAll(a, b, c, d); }
private static void InitializeTestState(GeneralStateTest test, StateProvider stateProvider, IStorageProvider storageProvider, ISpecProvider specProvider) { foreach (KeyValuePair <Address, AccountState> accountState in test.Pre) { foreach (KeyValuePair <UInt256, byte[]> storageItem in accountState.Value.Storage) { storageProvider.Set(new StorageCell(accountState.Key, storageItem.Key), storageItem.Value.WithoutLeadingZeros().ToArray()); } stateProvider.CreateAccount(accountState.Key, accountState.Value.Balance); Keccak codeHash = stateProvider.UpdateCode(accountState.Value.Code); stateProvider.UpdateCodeHash(accountState.Key, codeHash, specProvider.GenesisSpec); stateProvider.SetNonce(accountState.Key, accountState.Value.Nonce); } storageProvider.Commit(); stateProvider.Commit(specProvider.GenesisSpec); storageProvider.CommitTrees(0); stateProvider.CommitTree(0); storageProvider.Reset(); stateProvider.Reset(); }
public void GlobalSetup() { ByteCode = Bytes.FromHexString(Environment.GetEnvironmentVariable("NETH.BENCHMARK.BYTECODE")); Console.WriteLine($"Running benchmark for bytecode {ByteCode?.ToHexString()}"); IDb codeDb = new StateDb(); ISnapshotableDb stateDb = new StateDb(); _stateProvider = new StateProvider(stateDb, codeDb, LimboLogs.Instance); _stateProvider.CreateAccount(Address.Zero, 1000.Ether()); _stateProvider.Commit(_spec); _storageProvider = new StorageProvider(stateDb, _stateProvider, LimboLogs.Instance); _virtualMachine = new VirtualMachine(_stateProvider, _storageProvider, _blockhashProvider, MainnetSpecProvider.Instance, LimboLogs.Instance); _environment = new ExecutionEnvironment(); _environment.ExecutingAccount = Address.Zero; _environment.CodeSource = Address.Zero; _environment.Originator = Address.Zero; _environment.Sender = Address.Zero; _environment.CodeInfo = new CodeInfo(ByteCode); _environment.GasPrice = 0; _environment.Value = 0; _environment.TransferValue = 0; _environment.CurrentBlock = _header; _evmState = new EvmState(long.MaxValue, _environment, ExecutionType.Transaction, false, true, false); }
public void GlobalSetup() { TrieStore trieStore = new(new MemDb(), new OneLoggerLogManager(NullLogger.Instance)); IKeyValueStore codeDb = new MemDb(); _stateProvider = new StateProvider(trieStore, codeDb, new OneLoggerLogManager(NullLogger.Instance)); _stateProvider.CreateAccount(Address.Zero, 1000.Ether()); _stateProvider.Commit(_spec); _storageProvider = new StorageProvider(trieStore, _stateProvider, new OneLoggerLogManager(NullLogger.Instance)); _worldState = new WorldState(_stateProvider, _storageProvider); Console.WriteLine(MuirGlacier.Instance); _virtualMachine = new VirtualMachine(_blockhashProvider, MainnetSpecProvider.Instance, new OneLoggerLogManager(NullLogger.Instance)); _environment = new ExecutionEnvironment { ExecutingAccount = Address.Zero, CodeSource = Address.Zero, Caller = Address.Zero, CodeInfo = new CodeInfo(Bytecode), Value = 0, TransferValue = 0, TxExecutionContext = new TxExecutionContext(_header, Address.Zero, 0) }; _evmState = new EvmState(100_000_000L, _environment, ExecutionType.Transaction, true, _worldState.TakeSnapshot(), false); }
public void Non_existing() { StorageCell storageCell = new StorageCell(_address1, UInt256.One); IReleaseSpec spec = MuirGlacier.Instance; MemDb stateDb = new MemDb(); TrieStore trieStore = new TrieStore(stateDb, Logger); StateProvider provider = new StateProvider(trieStore, new MemDb(), Logger); StorageProvider storageProvider = new StorageProvider(trieStore, provider, Logger); void CommitEverything() { storageProvider.Commit(); storageProvider.CommitTrees(0); provider.Commit(spec); provider.CommitTree(0); } provider.CreateAccount(_address1, 1); storageProvider.Set(storageCell, new byte[] { 1 }); CommitEverything(); Keccak stateRoot0 = provider.StateRoot; StateReader reader = new StateReader(new TrieStore(stateDb, LimboLogs.Instance), Substitute.For <IDb>(), Logger); Keccak storageRoot = reader.GetStorageRoot(stateRoot0, _address1); reader.GetStorage(storageRoot, storageCell.Index + 1).Should().BeEquivalentTo(new byte[] { 0 }); reader.GetStorage(Keccak.EmptyTreeHash, storageCell.Index + 1).Should().BeEquivalentTo(new byte[] { 0 }); }
public void Is_empty_account() { StateProvider provider = new StateProvider(new TrieStore(new MemDb(), Logger), _codeDb, Logger); provider.CreateAccount(_address1, 0); provider.Commit(Frontier.Instance); Assert.True(provider.IsEmptyAccount(_address1)); }
public void Is_empty_account() { StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(_address1, 0); provider.Commit(Frontier.Instance); Assert.True(provider.IsEmptyAccount(_address1)); }
public void Disables_Eip158_for_system_transactions() { _stateProvider.CreateAccount(TestItem.PrivateKeyA.Address, 0.Ether()); _stateProvider.Commit(_specProvider.GetSpec(1)); var blockNumber = MainNetSpecProvider.SpuriousDragonBlockNumber + 1; Transaction tx = Build.A.SystemTransaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA, blockNumber) .WithGasPrice(0) .WithValue(0) .TestObject; Block block = Build.A.Block.WithNumber(blockNumber).WithTransactions(tx).TestObject; BlockReceiptsTracer tracer = BuildTracer(block, tx, false, false); Execute(tracer, tx, block); _stateProvider.AccountExists(tx.SenderAddress).Should().BeTrue(); }
public void GlobalSetup() { IDb codeDb = new StateDb(); ISnapshotableDb stateDb = new StateDb(); _stateProvider = new StateProvider(stateDb, codeDb, new OneLoggerLogManager(NullLogger.Instance)); _stateProvider.CreateAccount(Address.Zero, 1000.Ether()); _stateProvider.Commit(_spec); EvmState evmState = new EvmState(1, default, default, true, true);
public void Can_collect_stats() { StateProvider provider = new StateProvider(new TrieStore(new MemDb(), Logger), _codeDb, Logger); provider.CreateAccount(TestItem.AddressA, 1.Ether()); provider.Commit(MuirGlacier.Instance); provider.CommitTree(0); var stats = provider.CollectStats(_codeDb, Logger); stats.AccountCount.Should().Be(1); }
public void Can_dump_state() { StateProvider provider = new StateProvider(new TrieStore(new MemDb(), Logger), _codeDb, Logger); provider.CreateAccount(TestItem.AddressA, 1.Ether()); provider.Commit(MuirGlacier.Instance); provider.CommitTree(0); string state = provider.DumpState(); state.Should().NotBeEmpty(); }
public void Can_collect_stats() { StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(TestItem.AddressA, 1.Ether()); provider.Commit(MuirGlacier.Instance); provider.CommitTree(); var stats = provider.CollectStats(); stats.AccountCount.Should().Be(1); }
public void Can_dump_state() { StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(TestItem.AddressA, 1.Ether()); provider.Commit(MuirGlacier.Instance); provider.CommitTree(); string state = provider.DumpState(); state.Should().NotBeEmpty(); }
public void Can_accepts_visitors() { StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(TestItem.AddressA, 1.Ether()); provider.Commit(MuirGlacier.Instance); provider.CommitTree(); TrieStatsCollector visitor = new TrieStatsCollector(new MemDb(), LimboLogs.Instance); provider.Accept(visitor, provider.StateRoot); }
public void Does_not_require_recalculation_after_reset() { StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(TestItem.AddressA, 5); Action action = () => { var x = provider.StateRoot; }; action.Should().Throw <InvalidOperationException>(); provider.Reset(); action.Should().NotThrow <InvalidOperationException>(); }
public void Eip_158_zero_value_transfer_deletes() { StateTree tree = new StateTree(new MemDb()); StateProvider frontierProvider = new StateProvider(tree, Substitute.For <IDb>(), Logger); frontierProvider.CreateAccount(_address1, 0); frontierProvider.Commit(Frontier.Instance); StateProvider provider = new StateProvider(tree, Substitute.For <IDb>(), Logger); provider.AddToBalance(_address1, 0, SpuriousDragon.Instance); provider.Commit(SpuriousDragon.Instance); Assert.False(provider.AccountExists(_address1)); }
public void Does_not_require_recalculation_after_reset() { StateProvider provider = new StateProvider(new TrieStore(new MemDb(), Logger), _codeDb, Logger); provider.CreateAccount(TestItem.AddressA, 5); Action action = () => { _ = provider.StateRoot; }; action.Should().Throw <InvalidOperationException>(); provider.Reset(); action.Should().NotThrow <InvalidOperationException>(); }
public void Keep_in_cache() { StateProvider provider = new StateProvider(new StateTree(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(_address1, 0); provider.Commit(Frontier.Instance); provider.GetBalance(_address1); provider.UpdateBalance(_address1, 1, Frontier.Instance); provider.Restore(-1); provider.UpdateBalance(_address1, 1, Frontier.Instance); provider.Restore(-1); provider.UpdateBalance(_address1, 1, Frontier.Instance); provider.Restore(-1); Assert.AreEqual(new BigInteger(0), provider.GetBalance(_address1)); }
public void Keep_in_cache() { StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(_address1, 0); provider.Commit(Frontier.Instance); provider.GetBalance(_address1); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.Restore(-1); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.Restore(-1); provider.AddToBalance(_address1, 1, Frontier.Instance); provider.Restore(-1); Assert.AreEqual(UInt256.Zero, provider.GetBalance(_address1)); }
public void Setup() { StateDb stateDb = new StateDb(); _stateProvider = new StateProvider(stateDb, new MemDb(), LimboLogs.Instance); _stateProvider.CreateAccount(TestItem.AddressA, 1.Ether()); _stateProvider.Commit(_specProvider.GenesisSpec); _stateProvider.CommitTree(); StorageProvider storageProvider = new StorageProvider(stateDb, _stateProvider, LimboLogs.Instance); VirtualMachine virtualMachine = new VirtualMachine(_stateProvider, storageProvider, Substitute.For <IBlockhashProvider>(), _specProvider, LimboLogs.Instance); _transactionProcessor = new TransactionProcessor(_specProvider, _stateProvider, storageProvider, virtualMachine, LimboLogs.Instance); _ethereumEcdsa = new EthereumEcdsa(_specProvider.ChainId, LimboLogs.Instance); }
public void Eip_158_touch_zero_value_system_account_is_not_deleted() { StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); var systemUser = Address.SystemUser; provider.CreateAccount(systemUser, 0); provider.Commit(Homestead.Instance); var releaseSpec = new ReleaseSpec() { IsEip158Enabled = true }; provider.UpdateCodeHash(systemUser, Keccak.OfAnEmptyString, releaseSpec); provider.Commit(releaseSpec); provider.GetAccount(systemUser).Should().NotBeNull(); }
public void Eip_158_zero_value_transfer_deletes() { var trieStore = new TrieStore(new MemDb(), Logger); StateProvider frontierProvider = new StateProvider(trieStore, _codeDb, Logger); frontierProvider.CreateAccount(_address1, 0); frontierProvider.Commit(Frontier.Instance); frontierProvider.CommitTree(0); StateProvider provider = new StateProvider(trieStore, _codeDb, Logger); provider.StateRoot = frontierProvider.StateRoot; provider.AddToBalance(_address1, 0, SpuriousDragon.Instance); provider.Commit(SpuriousDragon.Instance); Assert.False(provider.AccountExists(_address1)); _codeDb = Substitute.For <IDb>(); }
public void Touch_empty_trace_does_not_throw() { ParityLikeTxTracer tracer = new ParityLikeTxTracer(Build.A.Block.TestObject, null, ParityTraceTypes.StateDiff); StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(_address1, 0); Account account = provider.GetAccount(_address1); Assert.True(account.IsEmpty); provider.Commit(Frontier.Instance); // commit empty account (before the empty account fix in Spurious Dragon) Assert.True(provider.AccountExists(_address1)); provider.Reset(); // clear all caches provider.GetBalance(_address1); // justcache provider.AddToBalance(_address1, 0, SpuriousDragon.Instance); // touch Assert.DoesNotThrow(() => provider.Commit(SpuriousDragon.Instance, tracer)); }