jump_table.go 26 KB

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