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