jump_table.go 29 KB

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