jump_table.go 28 KB

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