jump_table.go 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155
  1. // Copyright 2015 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package vm
  17. import (
  18. "github.com/ethereum/go-ethereum/params"
  19. )
  20. type (
  21. executionFunc func(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error)
  22. gasFunc func(*EVM, *Contract, *Stack, *Memory, uint64) (uint64, error) // last parameter is the requested memory size as a uint64
  23. // memorySizeFunc returns the required size, and whether the operation overflowed a uint64
  24. memorySizeFunc func(*Stack) (size uint64, overflow bool)
  25. )
  26. type operation struct {
  27. // execute is the operation function
  28. execute executionFunc
  29. constantGas uint64
  30. dynamicGas gasFunc
  31. // minStack tells how many stack items are required
  32. minStack int
  33. // maxStack specifies the max length the stack can have for this operation
  34. // to not overflow the stack.
  35. maxStack int
  36. // memorySize returns the memory size required for the operation
  37. memorySize memorySizeFunc
  38. halts bool // indicates whether the operation should halt further execution
  39. jumps bool // indicates whether the program counter should not increment
  40. writes bool // determines whether this a state modifying operation
  41. valid bool // indication whether the retrieved operation is valid and known
  42. reverts bool // determines whether the operation reverts state (implicitly halts)
  43. returns bool // determines whether the operations sets the return data content
  44. }
  45. var (
  46. frontierInstructionSet = newFrontierInstructionSet()
  47. homesteadInstructionSet = newHomesteadInstructionSet()
  48. tangerineWhistleInstructionSet = newTangerineWhistleInstructionSet()
  49. spuriousDragonInstructionSet = newSpuriousDragonInstructionSet()
  50. byzantiumInstructionSet = newByzantiumInstructionSet()
  51. constantinopleInstructionSet = newConstantinopleInstructionSet()
  52. istanbulInstructionSet = newIstanbulInstructionSet()
  53. )
  54. // JumpTable contains the EVM opcodes supported at a given fork.
  55. type JumpTable [256]operation
  56. // newIstanbulInstructionSet returns the frontier, homestead
  57. // byzantium, contantinople and petersburg instructions.
  58. func newIstanbulInstructionSet() JumpTable {
  59. instructionSet := newConstantinopleInstructionSet()
  60. enable1344(&instructionSet) // ChainID opcode - https://eips.ethereum.org/EIPS/eip-1344
  61. enable1884(&instructionSet) // Reprice reader opcodes - https://eips.ethereum.org/EIPS/eip-1884
  62. enable2200(&instructionSet) // Net metered SSTORE - https://eips.ethereum.org/EIPS/eip-2200
  63. return instructionSet
  64. }
  65. // newConstantinopleInstructionSet returns the frontier, homestead
  66. // byzantium and contantinople instructions.
  67. func newConstantinopleInstructionSet() JumpTable {
  68. instructionSet := newByzantiumInstructionSet()
  69. instructionSet[SHL] = operation{
  70. execute: opSHL,
  71. constantGas: GasFastestStep,
  72. minStack: minStack(2, 1),
  73. maxStack: maxStack(2, 1),
  74. valid: true,
  75. }
  76. instructionSet[SHR] = operation{
  77. execute: opSHR,
  78. constantGas: GasFastestStep,
  79. minStack: minStack(2, 1),
  80. maxStack: maxStack(2, 1),
  81. valid: true,
  82. }
  83. instructionSet[SAR] = operation{
  84. execute: opSAR,
  85. constantGas: GasFastestStep,
  86. minStack: minStack(2, 1),
  87. maxStack: maxStack(2, 1),
  88. valid: true,
  89. }
  90. instructionSet[EXTCODEHASH] = operation{
  91. execute: opExtCodeHash,
  92. constantGas: params.ExtcodeHashGasConstantinople,
  93. minStack: minStack(1, 1),
  94. maxStack: maxStack(1, 1),
  95. valid: true,
  96. }
  97. instructionSet[CREATE2] = operation{
  98. execute: opCreate2,
  99. constantGas: params.Create2Gas,
  100. dynamicGas: gasCreate2,
  101. minStack: minStack(4, 1),
  102. maxStack: maxStack(4, 1),
  103. memorySize: memoryCreate2,
  104. valid: true,
  105. writes: true,
  106. returns: true,
  107. }
  108. return instructionSet
  109. }
  110. // newByzantiumInstructionSet returns the frontier, homestead and
  111. // byzantium instructions.
  112. func newByzantiumInstructionSet() JumpTable {
  113. instructionSet := newSpuriousDragonInstructionSet()
  114. instructionSet[STATICCALL] = operation{
  115. execute: opStaticCall,
  116. constantGas: params.CallGasEIP150,
  117. dynamicGas: gasStaticCall,
  118. minStack: minStack(6, 1),
  119. maxStack: maxStack(6, 1),
  120. memorySize: memoryStaticCall,
  121. valid: true,
  122. returns: true,
  123. }
  124. instructionSet[RETURNDATASIZE] = operation{
  125. execute: opReturnDataSize,
  126. constantGas: GasQuickStep,
  127. minStack: minStack(0, 1),
  128. maxStack: maxStack(0, 1),
  129. valid: true,
  130. }
  131. instructionSet[RETURNDATACOPY] = operation{
  132. execute: opReturnDataCopy,
  133. constantGas: GasFastestStep,
  134. dynamicGas: gasReturnDataCopy,
  135. minStack: minStack(3, 0),
  136. maxStack: maxStack(3, 0),
  137. memorySize: memoryReturnDataCopy,
  138. valid: true,
  139. }
  140. instructionSet[REVERT] = operation{
  141. execute: opRevert,
  142. dynamicGas: gasRevert,
  143. minStack: minStack(2, 0),
  144. maxStack: maxStack(2, 0),
  145. memorySize: memoryRevert,
  146. valid: true,
  147. reverts: true,
  148. returns: true,
  149. }
  150. return instructionSet
  151. }
  152. // EIP 158 a.k.a Spurious Dragon
  153. func newSpuriousDragonInstructionSet() JumpTable {
  154. instructionSet := newTangerineWhistleInstructionSet()
  155. instructionSet[EXP].dynamicGas = gasExpEIP158
  156. return instructionSet
  157. }
  158. // EIP 150 a.k.a Tangerine Whistle
  159. func newTangerineWhistleInstructionSet() JumpTable {
  160. instructionSet := newHomesteadInstructionSet()
  161. instructionSet[BALANCE].constantGas = params.BalanceGasEIP150
  162. instructionSet[EXTCODESIZE].constantGas = params.ExtcodeSizeGasEIP150
  163. instructionSet[SLOAD].constantGas = params.SloadGasEIP150
  164. instructionSet[EXTCODECOPY].constantGas = params.ExtcodeCopyBaseEIP150
  165. instructionSet[CALL].constantGas = params.CallGasEIP150
  166. instructionSet[CALLCODE].constantGas = params.CallGasEIP150
  167. instructionSet[DELEGATECALL].constantGas = params.CallGasEIP150
  168. return instructionSet
  169. }
  170. // newHomesteadInstructionSet returns the frontier and homestead
  171. // instructions that can be executed during the homestead phase.
  172. func newHomesteadInstructionSet() JumpTable {
  173. instructionSet := newFrontierInstructionSet()
  174. instructionSet[DELEGATECALL] = operation{
  175. execute: opDelegateCall,
  176. dynamicGas: gasDelegateCall,
  177. constantGas: params.CallGasFrontier,
  178. minStack: minStack(6, 1),
  179. maxStack: maxStack(6, 1),
  180. memorySize: memoryDelegateCall,
  181. valid: true,
  182. returns: true,
  183. }
  184. return instructionSet
  185. }
  186. // newFrontierInstructionSet returns the frontier instructions
  187. // that can be executed during the frontier phase.
  188. func newFrontierInstructionSet() JumpTable {
  189. return JumpTable{
  190. STOP: {
  191. execute: opStop,
  192. constantGas: 0,
  193. minStack: minStack(0, 0),
  194. maxStack: maxStack(0, 0),
  195. halts: true,
  196. valid: true,
  197. },
  198. ADD: {
  199. execute: opAdd,
  200. constantGas: GasFastestStep,
  201. minStack: minStack(2, 1),
  202. maxStack: maxStack(2, 1),
  203. valid: true,
  204. },
  205. MUL: {
  206. execute: opMul,
  207. constantGas: GasFastStep,
  208. minStack: minStack(2, 1),
  209. maxStack: maxStack(2, 1),
  210. valid: true,
  211. },
  212. SUB: {
  213. execute: opSub,
  214. constantGas: GasFastestStep,
  215. minStack: minStack(2, 1),
  216. maxStack: maxStack(2, 1),
  217. valid: true,
  218. },
  219. DIV: {
  220. execute: opDiv,
  221. constantGas: GasFastStep,
  222. minStack: minStack(2, 1),
  223. maxStack: maxStack(2, 1),
  224. valid: true,
  225. },
  226. SDIV: {
  227. execute: opSdiv,
  228. constantGas: GasFastStep,
  229. minStack: minStack(2, 1),
  230. maxStack: maxStack(2, 1),
  231. valid: true,
  232. },
  233. MOD: {
  234. execute: opMod,
  235. constantGas: GasFastStep,
  236. minStack: minStack(2, 1),
  237. maxStack: maxStack(2, 1),
  238. valid: true,
  239. },
  240. SMOD: {
  241. execute: opSmod,
  242. constantGas: GasFastStep,
  243. minStack: minStack(2, 1),
  244. maxStack: maxStack(2, 1),
  245. valid: true,
  246. },
  247. ADDMOD: {
  248. execute: opAddmod,
  249. constantGas: GasMidStep,
  250. minStack: minStack(3, 1),
  251. maxStack: maxStack(3, 1),
  252. valid: true,
  253. },
  254. MULMOD: {
  255. execute: opMulmod,
  256. constantGas: GasMidStep,
  257. minStack: minStack(3, 1),
  258. maxStack: maxStack(3, 1),
  259. valid: true,
  260. },
  261. EXP: {
  262. execute: opExp,
  263. dynamicGas: gasExpFrontier,
  264. minStack: minStack(2, 1),
  265. maxStack: maxStack(2, 1),
  266. valid: true,
  267. },
  268. SIGNEXTEND: {
  269. execute: opSignExtend,
  270. constantGas: GasFastStep,
  271. minStack: minStack(2, 1),
  272. maxStack: maxStack(2, 1),
  273. valid: true,
  274. },
  275. LT: {
  276. execute: opLt,
  277. constantGas: GasFastestStep,
  278. minStack: minStack(2, 1),
  279. maxStack: maxStack(2, 1),
  280. valid: true,
  281. },
  282. GT: {
  283. execute: opGt,
  284. constantGas: GasFastestStep,
  285. minStack: minStack(2, 1),
  286. maxStack: maxStack(2, 1),
  287. valid: true,
  288. },
  289. SLT: {
  290. execute: opSlt,
  291. constantGas: GasFastestStep,
  292. minStack: minStack(2, 1),
  293. maxStack: maxStack(2, 1),
  294. valid: true,
  295. },
  296. SGT: {
  297. execute: opSgt,
  298. constantGas: GasFastestStep,
  299. minStack: minStack(2, 1),
  300. maxStack: maxStack(2, 1),
  301. valid: true,
  302. },
  303. EQ: {
  304. execute: opEq,
  305. constantGas: GasFastestStep,
  306. minStack: minStack(2, 1),
  307. maxStack: maxStack(2, 1),
  308. valid: true,
  309. },
  310. ISZERO: {
  311. execute: opIszero,
  312. constantGas: GasFastestStep,
  313. minStack: minStack(1, 1),
  314. maxStack: maxStack(1, 1),
  315. valid: true,
  316. },
  317. AND: {
  318. execute: opAnd,
  319. constantGas: GasFastestStep,
  320. minStack: minStack(2, 1),
  321. maxStack: maxStack(2, 1),
  322. valid: true,
  323. },
  324. XOR: {
  325. execute: opXor,
  326. constantGas: GasFastestStep,
  327. minStack: minStack(2, 1),
  328. maxStack: maxStack(2, 1),
  329. valid: true,
  330. },
  331. OR: {
  332. execute: opOr,
  333. constantGas: GasFastestStep,
  334. minStack: minStack(2, 1),
  335. maxStack: maxStack(2, 1),
  336. valid: true,
  337. },
  338. NOT: {
  339. execute: opNot,
  340. constantGas: GasFastestStep,
  341. minStack: minStack(1, 1),
  342. maxStack: maxStack(1, 1),
  343. valid: true,
  344. },
  345. BYTE: {
  346. execute: opByte,
  347. constantGas: GasFastestStep,
  348. minStack: minStack(2, 1),
  349. maxStack: maxStack(2, 1),
  350. valid: true,
  351. },
  352. SHA3: {
  353. execute: opSha3,
  354. constantGas: params.Sha3Gas,
  355. dynamicGas: gasSha3,
  356. minStack: minStack(2, 1),
  357. maxStack: maxStack(2, 1),
  358. memorySize: memorySha3,
  359. valid: true,
  360. },
  361. ADDRESS: {
  362. execute: opAddress,
  363. constantGas: GasQuickStep,
  364. minStack: minStack(0, 1),
  365. maxStack: maxStack(0, 1),
  366. valid: true,
  367. },
  368. BALANCE: {
  369. execute: opBalance,
  370. constantGas: params.BalanceGasFrontier,
  371. minStack: minStack(1, 1),
  372. maxStack: maxStack(1, 1),
  373. valid: true,
  374. },
  375. ORIGIN: {
  376. execute: opOrigin,
  377. constantGas: GasQuickStep,
  378. minStack: minStack(0, 1),
  379. maxStack: maxStack(0, 1),
  380. valid: true,
  381. },
  382. CALLER: {
  383. execute: opCaller,
  384. constantGas: GasQuickStep,
  385. minStack: minStack(0, 1),
  386. maxStack: maxStack(0, 1),
  387. valid: true,
  388. },
  389. CALLVALUE: {
  390. execute: opCallValue,
  391. constantGas: GasQuickStep,
  392. minStack: minStack(0, 1),
  393. maxStack: maxStack(0, 1),
  394. valid: true,
  395. },
  396. CALLDATALOAD: {
  397. execute: opCallDataLoad,
  398. constantGas: GasFastestStep,
  399. minStack: minStack(1, 1),
  400. maxStack: maxStack(1, 1),
  401. valid: true,
  402. },
  403. CALLDATASIZE: {
  404. execute: opCallDataSize,
  405. constantGas: GasQuickStep,
  406. minStack: minStack(0, 1),
  407. maxStack: maxStack(0, 1),
  408. valid: true,
  409. },
  410. CALLDATACOPY: {
  411. execute: opCallDataCopy,
  412. constantGas: GasFastestStep,
  413. dynamicGas: gasCallDataCopy,
  414. minStack: minStack(3, 0),
  415. maxStack: maxStack(3, 0),
  416. memorySize: memoryCallDataCopy,
  417. valid: true,
  418. },
  419. CODESIZE: {
  420. execute: opCodeSize,
  421. constantGas: GasQuickStep,
  422. minStack: minStack(0, 1),
  423. maxStack: maxStack(0, 1),
  424. valid: true,
  425. },
  426. CODECOPY: {
  427. execute: opCodeCopy,
  428. constantGas: GasFastestStep,
  429. dynamicGas: gasCodeCopy,
  430. minStack: minStack(3, 0),
  431. maxStack: maxStack(3, 0),
  432. memorySize: memoryCodeCopy,
  433. valid: true,
  434. },
  435. GASPRICE: {
  436. execute: opGasprice,
  437. constantGas: GasQuickStep,
  438. minStack: minStack(0, 1),
  439. maxStack: maxStack(0, 1),
  440. valid: true,
  441. },
  442. EXTCODESIZE: {
  443. execute: opExtCodeSize,
  444. constantGas: params.ExtcodeSizeGasFrontier,
  445. minStack: minStack(1, 1),
  446. maxStack: maxStack(1, 1),
  447. valid: true,
  448. },
  449. EXTCODECOPY: {
  450. execute: opExtCodeCopy,
  451. constantGas: params.ExtcodeCopyBaseFrontier,
  452. dynamicGas: gasExtCodeCopy,
  453. minStack: minStack(4, 0),
  454. maxStack: maxStack(4, 0),
  455. memorySize: memoryExtCodeCopy,
  456. valid: true,
  457. },
  458. BLOCKHASH: {
  459. execute: opBlockhash,
  460. constantGas: GasExtStep,
  461. minStack: minStack(1, 1),
  462. maxStack: maxStack(1, 1),
  463. valid: true,
  464. },
  465. COINBASE: {
  466. execute: opCoinbase,
  467. constantGas: GasQuickStep,
  468. minStack: minStack(0, 1),
  469. maxStack: maxStack(0, 1),
  470. valid: true,
  471. },
  472. TIMESTAMP: {
  473. execute: opTimestamp,
  474. constantGas: GasQuickStep,
  475. minStack: minStack(0, 1),
  476. maxStack: maxStack(0, 1),
  477. valid: true,
  478. },
  479. NUMBER: {
  480. execute: opNumber,
  481. constantGas: GasQuickStep,
  482. minStack: minStack(0, 1),
  483. maxStack: maxStack(0, 1),
  484. valid: true,
  485. },
  486. DIFFICULTY: {
  487. execute: opDifficulty,
  488. constantGas: GasQuickStep,
  489. minStack: minStack(0, 1),
  490. maxStack: maxStack(0, 1),
  491. valid: true,
  492. },
  493. GASLIMIT: {
  494. execute: opGasLimit,
  495. constantGas: GasQuickStep,
  496. minStack: minStack(0, 1),
  497. maxStack: maxStack(0, 1),
  498. valid: true,
  499. },
  500. POP: {
  501. execute: opPop,
  502. constantGas: GasQuickStep,
  503. minStack: minStack(1, 0),
  504. maxStack: maxStack(1, 0),
  505. valid: true,
  506. },
  507. MLOAD: {
  508. execute: opMload,
  509. constantGas: GasFastestStep,
  510. dynamicGas: gasMLoad,
  511. minStack: minStack(1, 1),
  512. maxStack: maxStack(1, 1),
  513. memorySize: memoryMLoad,
  514. valid: true,
  515. },
  516. MSTORE: {
  517. execute: opMstore,
  518. constantGas: GasFastestStep,
  519. dynamicGas: gasMStore,
  520. minStack: minStack(2, 0),
  521. maxStack: maxStack(2, 0),
  522. memorySize: memoryMStore,
  523. valid: true,
  524. },
  525. MSTORE8: {
  526. execute: opMstore8,
  527. constantGas: GasFastestStep,
  528. dynamicGas: gasMStore8,
  529. memorySize: memoryMStore8,
  530. minStack: minStack(2, 0),
  531. maxStack: maxStack(2, 0),
  532. valid: true,
  533. },
  534. SLOAD: {
  535. execute: opSload,
  536. constantGas: params.SloadGasFrontier,
  537. minStack: minStack(1, 1),
  538. maxStack: maxStack(1, 1),
  539. valid: true,
  540. },
  541. SSTORE: {
  542. execute: opSstore,
  543. dynamicGas: gasSStore,
  544. minStack: minStack(2, 0),
  545. maxStack: maxStack(2, 0),
  546. valid: true,
  547. writes: true,
  548. },
  549. JUMP: {
  550. execute: opJump,
  551. constantGas: GasMidStep,
  552. minStack: minStack(1, 0),
  553. maxStack: maxStack(1, 0),
  554. jumps: true,
  555. valid: true,
  556. },
  557. JUMPI: {
  558. execute: opJumpi,
  559. constantGas: GasSlowStep,
  560. minStack: minStack(2, 0),
  561. maxStack: maxStack(2, 0),
  562. jumps: true,
  563. valid: true,
  564. },
  565. PC: {
  566. execute: opPc,
  567. constantGas: GasQuickStep,
  568. minStack: minStack(0, 1),
  569. maxStack: maxStack(0, 1),
  570. valid: true,
  571. },
  572. MSIZE: {
  573. execute: opMsize,
  574. constantGas: GasQuickStep,
  575. minStack: minStack(0, 1),
  576. maxStack: maxStack(0, 1),
  577. valid: true,
  578. },
  579. GAS: {
  580. execute: opGas,
  581. constantGas: GasQuickStep,
  582. minStack: minStack(0, 1),
  583. maxStack: maxStack(0, 1),
  584. valid: true,
  585. },
  586. JUMPDEST: {
  587. execute: opJumpdest,
  588. constantGas: params.JumpdestGas,
  589. minStack: minStack(0, 0),
  590. maxStack: maxStack(0, 0),
  591. valid: true,
  592. },
  593. PUSH1: {
  594. execute: opPush1,
  595. constantGas: GasFastestStep,
  596. minStack: minStack(0, 1),
  597. maxStack: maxStack(0, 1),
  598. valid: true,
  599. },
  600. PUSH2: {
  601. execute: makePush(2, 2),
  602. constantGas: GasFastestStep,
  603. minStack: minStack(0, 1),
  604. maxStack: maxStack(0, 1),
  605. valid: true,
  606. },
  607. PUSH3: {
  608. execute: makePush(3, 3),
  609. constantGas: GasFastestStep,
  610. minStack: minStack(0, 1),
  611. maxStack: maxStack(0, 1),
  612. valid: true,
  613. },
  614. PUSH4: {
  615. execute: makePush(4, 4),
  616. constantGas: GasFastestStep,
  617. minStack: minStack(0, 1),
  618. maxStack: maxStack(0, 1),
  619. valid: true,
  620. },
  621. PUSH5: {
  622. execute: makePush(5, 5),
  623. constantGas: GasFastestStep,
  624. minStack: minStack(0, 1),
  625. maxStack: maxStack(0, 1),
  626. valid: true,
  627. },
  628. PUSH6: {
  629. execute: makePush(6, 6),
  630. constantGas: GasFastestStep,
  631. minStack: minStack(0, 1),
  632. maxStack: maxStack(0, 1),
  633. valid: true,
  634. },
  635. PUSH7: {
  636. execute: makePush(7, 7),
  637. constantGas: GasFastestStep,
  638. minStack: minStack(0, 1),
  639. maxStack: maxStack(0, 1),
  640. valid: true,
  641. },
  642. PUSH8: {
  643. execute: makePush(8, 8),
  644. constantGas: GasFastestStep,
  645. minStack: minStack(0, 1),
  646. maxStack: maxStack(0, 1),
  647. valid: true,
  648. },
  649. PUSH9: {
  650. execute: makePush(9, 9),
  651. constantGas: GasFastestStep,
  652. minStack: minStack(0, 1),
  653. maxStack: maxStack(0, 1),
  654. valid: true,
  655. },
  656. PUSH10: {
  657. execute: makePush(10, 10),
  658. constantGas: GasFastestStep,
  659. minStack: minStack(0, 1),
  660. maxStack: maxStack(0, 1),
  661. valid: true,
  662. },
  663. PUSH11: {
  664. execute: makePush(11, 11),
  665. constantGas: GasFastestStep,
  666. minStack: minStack(0, 1),
  667. maxStack: maxStack(0, 1),
  668. valid: true,
  669. },
  670. PUSH12: {
  671. execute: makePush(12, 12),
  672. constantGas: GasFastestStep,
  673. minStack: minStack(0, 1),
  674. maxStack: maxStack(0, 1),
  675. valid: true,
  676. },
  677. PUSH13: {
  678. execute: makePush(13, 13),
  679. constantGas: GasFastestStep,
  680. minStack: minStack(0, 1),
  681. maxStack: maxStack(0, 1),
  682. valid: true,
  683. },
  684. PUSH14: {
  685. execute: makePush(14, 14),
  686. constantGas: GasFastestStep,
  687. minStack: minStack(0, 1),
  688. maxStack: maxStack(0, 1),
  689. valid: true,
  690. },
  691. PUSH15: {
  692. execute: makePush(15, 15),
  693. constantGas: GasFastestStep,
  694. minStack: minStack(0, 1),
  695. maxStack: maxStack(0, 1),
  696. valid: true,
  697. },
  698. PUSH16: {
  699. execute: makePush(16, 16),
  700. constantGas: GasFastestStep,
  701. minStack: minStack(0, 1),
  702. maxStack: maxStack(0, 1),
  703. valid: true,
  704. },
  705. PUSH17: {
  706. execute: makePush(17, 17),
  707. constantGas: GasFastestStep,
  708. minStack: minStack(0, 1),
  709. maxStack: maxStack(0, 1),
  710. valid: true,
  711. },
  712. PUSH18: {
  713. execute: makePush(18, 18),
  714. constantGas: GasFastestStep,
  715. minStack: minStack(0, 1),
  716. maxStack: maxStack(0, 1),
  717. valid: true,
  718. },
  719. PUSH19: {
  720. execute: makePush(19, 19),
  721. constantGas: GasFastestStep,
  722. minStack: minStack(0, 1),
  723. maxStack: maxStack(0, 1),
  724. valid: true,
  725. },
  726. PUSH20: {
  727. execute: makePush(20, 20),
  728. constantGas: GasFastestStep,
  729. minStack: minStack(0, 1),
  730. maxStack: maxStack(0, 1),
  731. valid: true,
  732. },
  733. PUSH21: {
  734. execute: makePush(21, 21),
  735. constantGas: GasFastestStep,
  736. minStack: minStack(0, 1),
  737. maxStack: maxStack(0, 1),
  738. valid: true,
  739. },
  740. PUSH22: {
  741. execute: makePush(22, 22),
  742. constantGas: GasFastestStep,
  743. minStack: minStack(0, 1),
  744. maxStack: maxStack(0, 1),
  745. valid: true,
  746. },
  747. PUSH23: {
  748. execute: makePush(23, 23),
  749. constantGas: GasFastestStep,
  750. minStack: minStack(0, 1),
  751. maxStack: maxStack(0, 1),
  752. valid: true,
  753. },
  754. PUSH24: {
  755. execute: makePush(24, 24),
  756. constantGas: GasFastestStep,
  757. minStack: minStack(0, 1),
  758. maxStack: maxStack(0, 1),
  759. valid: true,
  760. },
  761. PUSH25: {
  762. execute: makePush(25, 25),
  763. constantGas: GasFastestStep,
  764. minStack: minStack(0, 1),
  765. maxStack: maxStack(0, 1),
  766. valid: true,
  767. },
  768. PUSH26: {
  769. execute: makePush(26, 26),
  770. constantGas: GasFastestStep,
  771. minStack: minStack(0, 1),
  772. maxStack: maxStack(0, 1),
  773. valid: true,
  774. },
  775. PUSH27: {
  776. execute: makePush(27, 27),
  777. constantGas: GasFastestStep,
  778. minStack: minStack(0, 1),
  779. maxStack: maxStack(0, 1),
  780. valid: true,
  781. },
  782. PUSH28: {
  783. execute: makePush(28, 28),
  784. constantGas: GasFastestStep,
  785. minStack: minStack(0, 1),
  786. maxStack: maxStack(0, 1),
  787. valid: true,
  788. },
  789. PUSH29: {
  790. execute: makePush(29, 29),
  791. constantGas: GasFastestStep,
  792. minStack: minStack(0, 1),
  793. maxStack: maxStack(0, 1),
  794. valid: true,
  795. },
  796. PUSH30: {
  797. execute: makePush(30, 30),
  798. constantGas: GasFastestStep,
  799. minStack: minStack(0, 1),
  800. maxStack: maxStack(0, 1),
  801. valid: true,
  802. },
  803. PUSH31: {
  804. execute: makePush(31, 31),
  805. constantGas: GasFastestStep,
  806. minStack: minStack(0, 1),
  807. maxStack: maxStack(0, 1),
  808. valid: true,
  809. },
  810. PUSH32: {
  811. execute: makePush(32, 32),
  812. constantGas: GasFastestStep,
  813. minStack: minStack(0, 1),
  814. maxStack: maxStack(0, 1),
  815. valid: true,
  816. },
  817. DUP1: {
  818. execute: makeDup(1),
  819. constantGas: GasFastestStep,
  820. minStack: minDupStack(1),
  821. maxStack: maxDupStack(1),
  822. valid: true,
  823. },
  824. DUP2: {
  825. execute: makeDup(2),
  826. constantGas: GasFastestStep,
  827. minStack: minDupStack(2),
  828. maxStack: maxDupStack(2),
  829. valid: true,
  830. },
  831. DUP3: {
  832. execute: makeDup(3),
  833. constantGas: GasFastestStep,
  834. minStack: minDupStack(3),
  835. maxStack: maxDupStack(3),
  836. valid: true,
  837. },
  838. DUP4: {
  839. execute: makeDup(4),
  840. constantGas: GasFastestStep,
  841. minStack: minDupStack(4),
  842. maxStack: maxDupStack(4),
  843. valid: true,
  844. },
  845. DUP5: {
  846. execute: makeDup(5),
  847. constantGas: GasFastestStep,
  848. minStack: minDupStack(5),
  849. maxStack: maxDupStack(5),
  850. valid: true,
  851. },
  852. DUP6: {
  853. execute: makeDup(6),
  854. constantGas: GasFastestStep,
  855. minStack: minDupStack(6),
  856. maxStack: maxDupStack(6),
  857. valid: true,
  858. },
  859. DUP7: {
  860. execute: makeDup(7),
  861. constantGas: GasFastestStep,
  862. minStack: minDupStack(7),
  863. maxStack: maxDupStack(7),
  864. valid: true,
  865. },
  866. DUP8: {
  867. execute: makeDup(8),
  868. constantGas: GasFastestStep,
  869. minStack: minDupStack(8),
  870. maxStack: maxDupStack(8),
  871. valid: true,
  872. },
  873. DUP9: {
  874. execute: makeDup(9),
  875. constantGas: GasFastestStep,
  876. minStack: minDupStack(9),
  877. maxStack: maxDupStack(9),
  878. valid: true,
  879. },
  880. DUP10: {
  881. execute: makeDup(10),
  882. constantGas: GasFastestStep,
  883. minStack: minDupStack(10),
  884. maxStack: maxDupStack(10),
  885. valid: true,
  886. },
  887. DUP11: {
  888. execute: makeDup(11),
  889. constantGas: GasFastestStep,
  890. minStack: minDupStack(11),
  891. maxStack: maxDupStack(11),
  892. valid: true,
  893. },
  894. DUP12: {
  895. execute: makeDup(12),
  896. constantGas: GasFastestStep,
  897. minStack: minDupStack(12),
  898. maxStack: maxDupStack(12),
  899. valid: true,
  900. },
  901. DUP13: {
  902. execute: makeDup(13),
  903. constantGas: GasFastestStep,
  904. minStack: minDupStack(13),
  905. maxStack: maxDupStack(13),
  906. valid: true,
  907. },
  908. DUP14: {
  909. execute: makeDup(14),
  910. constantGas: GasFastestStep,
  911. minStack: minDupStack(14),
  912. maxStack: maxDupStack(14),
  913. valid: true,
  914. },
  915. DUP15: {
  916. execute: makeDup(15),
  917. constantGas: GasFastestStep,
  918. minStack: minDupStack(15),
  919. maxStack: maxDupStack(15),
  920. valid: true,
  921. },
  922. DUP16: {
  923. execute: makeDup(16),
  924. constantGas: GasFastestStep,
  925. minStack: minDupStack(16),
  926. maxStack: maxDupStack(16),
  927. valid: true,
  928. },
  929. SWAP1: {
  930. execute: makeSwap(1),
  931. constantGas: GasFastestStep,
  932. minStack: minSwapStack(2),
  933. maxStack: maxSwapStack(2),
  934. valid: true,
  935. },
  936. SWAP2: {
  937. execute: makeSwap(2),
  938. constantGas: GasFastestStep,
  939. minStack: minSwapStack(3),
  940. maxStack: maxSwapStack(3),
  941. valid: true,
  942. },
  943. SWAP3: {
  944. execute: makeSwap(3),
  945. constantGas: GasFastestStep,
  946. minStack: minSwapStack(4),
  947. maxStack: maxSwapStack(4),
  948. valid: true,
  949. },
  950. SWAP4: {
  951. execute: makeSwap(4),
  952. constantGas: GasFastestStep,
  953. minStack: minSwapStack(5),
  954. maxStack: maxSwapStack(5),
  955. valid: true,
  956. },
  957. SWAP5: {
  958. execute: makeSwap(5),
  959. constantGas: GasFastestStep,
  960. minStack: minSwapStack(6),
  961. maxStack: maxSwapStack(6),
  962. valid: true,
  963. },
  964. SWAP6: {
  965. execute: makeSwap(6),
  966. constantGas: GasFastestStep,
  967. minStack: minSwapStack(7),
  968. maxStack: maxSwapStack(7),
  969. valid: true,
  970. },
  971. SWAP7: {
  972. execute: makeSwap(7),
  973. constantGas: GasFastestStep,
  974. minStack: minSwapStack(8),
  975. maxStack: maxSwapStack(8),
  976. valid: true,
  977. },
  978. SWAP8: {
  979. execute: makeSwap(8),
  980. constantGas: GasFastestStep,
  981. minStack: minSwapStack(9),
  982. maxStack: maxSwapStack(9),
  983. valid: true,
  984. },
  985. SWAP9: {
  986. execute: makeSwap(9),
  987. constantGas: GasFastestStep,
  988. minStack: minSwapStack(10),
  989. maxStack: maxSwapStack(10),
  990. valid: true,
  991. },
  992. SWAP10: {
  993. execute: makeSwap(10),
  994. constantGas: GasFastestStep,
  995. minStack: minSwapStack(11),
  996. maxStack: maxSwapStack(11),
  997. valid: true,
  998. },
  999. SWAP11: {
  1000. execute: makeSwap(11),
  1001. constantGas: GasFastestStep,
  1002. minStack: minSwapStack(12),
  1003. maxStack: maxSwapStack(12),
  1004. valid: true,
  1005. },
  1006. SWAP12: {
  1007. execute: makeSwap(12),
  1008. constantGas: GasFastestStep,
  1009. minStack: minSwapStack(13),
  1010. maxStack: maxSwapStack(13),
  1011. valid: true,
  1012. },
  1013. SWAP13: {
  1014. execute: makeSwap(13),
  1015. constantGas: GasFastestStep,
  1016. minStack: minSwapStack(14),
  1017. maxStack: maxSwapStack(14),
  1018. valid: true,
  1019. },
  1020. SWAP14: {
  1021. execute: makeSwap(14),
  1022. constantGas: GasFastestStep,
  1023. minStack: minSwapStack(15),
  1024. maxStack: maxSwapStack(15),
  1025. valid: true,
  1026. },
  1027. SWAP15: {
  1028. execute: makeSwap(15),
  1029. constantGas: GasFastestStep,
  1030. minStack: minSwapStack(16),
  1031. maxStack: maxSwapStack(16),
  1032. valid: true,
  1033. },
  1034. SWAP16: {
  1035. execute: makeSwap(16),
  1036. constantGas: GasFastestStep,
  1037. minStack: minSwapStack(17),
  1038. maxStack: maxSwapStack(17),
  1039. valid: true,
  1040. },
  1041. LOG0: {
  1042. execute: makeLog(0),
  1043. dynamicGas: makeGasLog(0),
  1044. minStack: minStack(2, 0),
  1045. maxStack: maxStack(2, 0),
  1046. memorySize: memoryLog,
  1047. valid: true,
  1048. writes: true,
  1049. },
  1050. LOG1: {
  1051. execute: makeLog(1),
  1052. dynamicGas: makeGasLog(1),
  1053. minStack: minStack(3, 0),
  1054. maxStack: maxStack(3, 0),
  1055. memorySize: memoryLog,
  1056. valid: true,
  1057. writes: true,
  1058. },
  1059. LOG2: {
  1060. execute: makeLog(2),
  1061. dynamicGas: makeGasLog(2),
  1062. minStack: minStack(4, 0),
  1063. maxStack: maxStack(4, 0),
  1064. memorySize: memoryLog,
  1065. valid: true,
  1066. writes: true,
  1067. },
  1068. LOG3: {
  1069. execute: makeLog(3),
  1070. dynamicGas: makeGasLog(3),
  1071. minStack: minStack(5, 0),
  1072. maxStack: maxStack(5, 0),
  1073. memorySize: memoryLog,
  1074. valid: true,
  1075. writes: true,
  1076. },
  1077. LOG4: {
  1078. execute: makeLog(4),
  1079. dynamicGas: makeGasLog(4),
  1080. minStack: minStack(6, 0),
  1081. maxStack: maxStack(6, 0),
  1082. memorySize: memoryLog,
  1083. valid: true,
  1084. writes: true,
  1085. },
  1086. CREATE: {
  1087. execute: opCreate,
  1088. constantGas: params.CreateGas,
  1089. dynamicGas: gasCreate,
  1090. minStack: minStack(3, 1),
  1091. maxStack: maxStack(3, 1),
  1092. memorySize: memoryCreate,
  1093. valid: true,
  1094. writes: true,
  1095. returns: true,
  1096. },
  1097. CALL: {
  1098. execute: opCall,
  1099. constantGas: params.CallGasFrontier,
  1100. dynamicGas: gasCall,
  1101. minStack: minStack(7, 1),
  1102. maxStack: maxStack(7, 1),
  1103. memorySize: memoryCall,
  1104. valid: true,
  1105. returns: true,
  1106. },
  1107. CALLCODE: {
  1108. execute: opCallCode,
  1109. constantGas: params.CallGasFrontier,
  1110. dynamicGas: gasCallCode,
  1111. minStack: minStack(7, 1),
  1112. maxStack: maxStack(7, 1),
  1113. memorySize: memoryCall,
  1114. valid: true,
  1115. returns: true,
  1116. },
  1117. RETURN: {
  1118. execute: opReturn,
  1119. dynamicGas: gasReturn,
  1120. minStack: minStack(2, 0),
  1121. maxStack: maxStack(2, 0),
  1122. memorySize: memoryReturn,
  1123. halts: true,
  1124. valid: true,
  1125. },
  1126. SELFDESTRUCT: {
  1127. execute: opSuicide,
  1128. dynamicGas: gasSelfdestruct,
  1129. minStack: minStack(1, 0),
  1130. maxStack: maxStack(1, 0),
  1131. halts: true,
  1132. valid: true,
  1133. writes: true,
  1134. },
  1135. }
  1136. }