jump_table.go 24 KB

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