jump_table.go 25 KB

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