jump_table.go 23 KB

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