Exemplo n.º 1
0
        public void Regression_mainnet_226522()
        {
            _blockNumber = 1;
            Address        deployed       = Address.OfContract(TestItem.AddressC, 0);
            StorageAddress storageAddress = new StorageAddress(deployed, 1);

            byte[] deployedCode = new byte[106]; // cost is * 200

            byte[] initCode = Prepare.EvmCode
                              .PushData(1)
                              .PushData(1)
                              .Op(Instruction.SSTORE)
                              .PushData(0)
                              .PushData(1)
                              .Op(Instruction.SSTORE) // here we reset storage so we would get refund of 15000 gas
                              .ForInitOf(deployedCode).Done;

            byte[] createCode = Prepare.EvmCode
                                .Create(initCode, 0)
                                .PushData(0)
                                .Op(Instruction.SSTORE)
                                .Done;

            TestState.CreateAccount(TestItem.AddressC, 1.Ether());
            Keccak createCodeHash = TestState.UpdateCode(createCode);

            TestState.UpdateCodeHash(TestItem.AddressC, createCodeHash, Spec);

            byte[] code = Prepare.EvmCode
                          .Call(TestItem.AddressC, 32000 + 20003 + 20000 + 5000 + 500 + 0) // not enough
                          .Done;

            var receipt = Execute(code);

            byte[] result = Storage.Get(storageAddress);
            Assert.AreEqual(new byte[] { 0 }, result, "storage reverted");
            Assert.AreEqual(83136, receipt.GasSpent, "with refund");

            byte[] returnData = Storage.Get(new StorageAddress(TestItem.AddressC, 0));
            Assert.AreEqual(deployed.Bytes, returnData, "address returned");
        }
Exemplo n.º 2
0
        public void ReportStorageChange(StorageAddress storageAddress, byte[] before, byte[] after)
        {
            Dictionary <UInt256, ParityStateChange <byte[]> > storage = null;

            if (!_trace.StateChanges.ContainsKey(storageAddress.Address))
            {
                _trace.StateChanges[storageAddress.Address] = new ParityAccountStateChange();
            }

            storage = _trace.StateChanges[storageAddress.Address].Storage;
            if (storage == null)
            {
                storage = _trace.StateChanges[storageAddress.Address].Storage = new Dictionary <UInt256, ParityStateChange <byte[]> >();
            }

            if (storage.ContainsKey(storageAddress.Index))
            {
                before = storage[storageAddress.Index].Before ?? before;
            }

            storage[storageAddress.Index] = new ParityStateChange <byte[]>(before, after);
        }
Exemplo n.º 3
0
 public void ReportStorageChange(StorageAddress storageAddress, byte[] before, byte[] after)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 4
0
 public void ReportStorageChange(StorageAddress storageAddress, byte[] before, byte[] after)
 {
     _currentTxTracer.ReportStorageChange(storageAddress, before, after);
 }
Exemplo n.º 5
0
 public void ReportStorageChange(StorageAddress storageAddress, byte[] before, byte[] after) => throw new InvalidOperationException(ErrorMessage);
Exemplo n.º 6
0
 protected void AssertStorage(StorageAddress storageAddress, BigInteger expectedValue)
 {
     byte[] actualValue = Storage.Get(storageAddress);
     Assert.AreEqual(expectedValue.ToBigEndianByteArray(), actualValue, $"storage {storageAddress}");
 }
Exemplo n.º 7
0
        private void txt_StorageAddress_ButtonCustomClick(object sender, EventArgs e)
        {
            StorageAddress sd = new StorageAddress(this);

            sd.ShowDialog();
        }