jump_table.go 26 KB

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