EVMSchedule.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. This file is part of cpp-ethereum.
  3. cpp-ethereum is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. cpp-ethereum is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /** @file EVMSchedule.h
  15. * @author Gav <i@gavwood.com>
  16. * @author Christian <c@ethdev.com>
  17. * @date 2015
  18. */
  19. #pragma once
  20. #include <libdevcore/Common.h>
  21. namespace dev
  22. {
  23. namespace eth
  24. {
  25. struct EVMSchedule
  26. {
  27. EVMSchedule(): tierStepGas(std::array<unsigned, 8>{{0, 2, 3, 5, 8, 10, 20, 0}}) {}
  28. EVMSchedule(bool _efcd, bool _hdc, unsigned const& _txCreateGas): exceptionalFailedCodeDeposit(_efcd), haveDelegateCall(_hdc), tierStepGas(std::array<unsigned, 8>{{0, 2, 3, 5, 8, 10, 20, 0}}), txCreateGas(_txCreateGas) {}
  29. bool exceptionalFailedCodeDeposit = true;
  30. bool haveDelegateCall = true;
  31. bool eip150Mode = false;
  32. bool eip158Mode = false;
  33. unsigned stackLimit = 1024;
  34. std::array<unsigned, 8> tierStepGas;
  35. unsigned expGas = 10;
  36. unsigned expByteGas = 10;
  37. unsigned sha3Gas = 30;
  38. unsigned sha3WordGas = 6;
  39. unsigned sloadGas = 50;
  40. unsigned sstoreSetGas = 20000;
  41. unsigned sstoreResetGas = 5000;
  42. unsigned sstoreRefundGas = 15000;
  43. unsigned jumpdestGas = 1;
  44. unsigned logGas = 375;
  45. unsigned logDataGas = 8;
  46. unsigned logTopicGas = 375;
  47. unsigned createGas = 32000;
  48. unsigned callGas = 40;
  49. unsigned callStipend = 2300;
  50. unsigned callValueTransferGas = 9000;
  51. unsigned callNewAccountGas = 25000;
  52. unsigned suicideRefundGas = 24000;
  53. unsigned memoryGas = 3;
  54. unsigned quadCoeffDiv = 512;
  55. unsigned createDataGas = 200;
  56. unsigned txGas = 21000;
  57. unsigned txCreateGas = 53000;
  58. unsigned txDataZeroGas = 4;
  59. unsigned txDataNonZeroGas = 68;
  60. unsigned copyGas = 3;
  61. unsigned extcodesizeGas = 20;
  62. unsigned extcodecopyGas = 20;
  63. unsigned balanceGas = 20;
  64. unsigned suicideGas = 0;
  65. unsigned maxCodeSize = unsigned(-1);
  66. bool staticCallDepthLimit() const { return !eip150Mode; }
  67. bool suicideChargesNewAccountGas() const { return eip150Mode; }
  68. bool emptinessIsNonexistence() const { return eip158Mode; }
  69. bool zeroValueTransferChargesNewAccountGas() const { return !eip158Mode; }
  70. };
  71. static const EVMSchedule DefaultSchedule = EVMSchedule();
  72. static const EVMSchedule FrontierSchedule = EVMSchedule(false, false, 21000);
  73. static const EVMSchedule HomesteadSchedule = EVMSchedule(true, true, 53000);
  74. static const EVMSchedule EIP150Schedule = []
  75. {
  76. EVMSchedule schedule = HomesteadSchedule;
  77. schedule.eip150Mode = true;
  78. schedule.extcodesizeGas = 700;
  79. schedule.extcodecopyGas = 700;
  80. schedule.balanceGas = 400;
  81. schedule.sloadGas = 200;
  82. schedule.callGas = 700;
  83. schedule.suicideGas = 5000;
  84. schedule.maxCodeSize = 0x6000;
  85. return schedule;
  86. }();
  87. static const EVMSchedule EIP158Schedule = []
  88. {
  89. EVMSchedule schedule = EIP150Schedule;
  90. schedule.expByteGas = 50;
  91. schedule.eip158Mode = true;
  92. return schedule;
  93. }();
  94. }
  95. }