jump_table.go 22 KB

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