jump_table.go 22 KB

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