jump_table.go 23 KB

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