예제 #1
0
        public void transient_storage_performance_test()
        {
            Stopwatch stopwatch     = new Stopwatch();
            long      blockGasLimit = 30000000;
            long      numOfOps      = (long)(blockGasLimit * .95) / (GasCostOf.TLoad + GasCostOf.TStore + GasCostOf.VeryLow * 4);
            Prepare   prepare       = Prepare.EvmCode;

            for (long i = 0; i < numOfOps; i++)
            {
                prepare.StoreDataInTransientStorage(1, 8);
                prepare.LoadDataFromTransientStorage(1);
                prepare.Op(Instruction.POP);
            }

            byte[] code = prepare.Done;

            stopwatch.Start();
            TestAllTracerWithOutput result = Execute(MainnetSpecProvider.ShanghaiBlockNumber, blockGasLimit, code, blockGasLimit);

            Assert.AreEqual(StatusCode.Success, result.StatusCode);
            stopwatch.Stop();
            Assert.IsTrue(stopwatch.ElapsedMilliseconds < 5000);
        }
예제 #2
0
        public void Blockhash_times_256_no_loop()
        {
            Rlp     rlp             = BuildHeader();
            Prepare bytecodeBuilder = Prepare.EvmCode
                                      .PushData(0)
                                      .PushData(1);

            for (int i = 0; i < 256; i++)
            {
                bytecodeBuilder.Op(Instruction.ADD)
                .Op(Instruction.BLOCKHASH)
                .PushData(1);
            }

            byte[] bytecode = bytecodeBuilder.Done;

            (Block block, Transaction transaction) = PrepareTx(
                BlockNumber, 1000000, bytecode, rlp.Bytes, 0);

            CallOutputTracer callOutputTracer = new CallOutputTracer();

            _processor.Execute(transaction, block.Header, callOutputTracer);
            callOutputTracer.GasSpent.Should().BeLessThan(21000 + 9600 + 20000);
        }