mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-24 20:47:16 +00:00
413 lines
41 KiB
Go
413 lines
41 KiB
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"encoding/hex"
|
||
|
"fmt"
|
||
|
"github.com/holiman/uint256"
|
||
|
"github.com/ledgerwatch/turbo-geth/common"
|
||
|
"github.com/ledgerwatch/turbo-geth/core/vm"
|
||
|
"log"
|
||
|
"math/big"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
func testGenCfg() {
|
||
|
args := os.Args
|
||
|
if len(args) == 4 {
|
||
|
fmt.Printf("%v\n", args[3])
|
||
|
absIntTest(args[3])
|
||
|
print("Finished running on program from command line.")
|
||
|
return
|
||
|
}
|
||
|
cfg0Test0()
|
||
|
cfg0Test1()
|
||
|
dfTest0()
|
||
|
dfTest1()
|
||
|
dfTest2()
|
||
|
dfTest3()
|
||
|
absIntTest1() //- PASSES (should not be able to resolve all to concrete jumps)
|
||
|
absIntTest2() //PASSES
|
||
|
absIntTest3()
|
||
|
absIntTestSimple00() //- PASSES
|
||
|
absIntTestRequires00() //- PASSES
|
||
|
absIntTestCall01() // - PASSES
|
||
|
absIntTestDiv00()
|
||
|
absIntTestEcrecoverLoop02() //- PASSES
|
||
|
absIntTestStorageVar03() // - PASSES
|
||
|
absIntTestStaticLoop00() //- PASSES
|
||
|
absIntTestPrivateFunction01() //- PASS
|
||
|
absIntTestPrivateFunction02() //- PASS
|
||
|
absIntTestStaticLoop01() // //- PASS
|
||
|
absIntTestDepositContract() //FAILS - Imprecision
|
||
|
absIntTestDepositContract2()
|
||
|
}
|
||
|
|
||
|
func cfg0Test0() {
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x1, 0x0}
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func cfg0Test1() {
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x2, byte(vm.PUSH1), 0x0, byte(vm.JUMP), 0x0}
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func dfTest0() {
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x2, byte(vm.PUSH1), 0x0, 0x0}
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func dfTest1() {
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x2, byte(vm.PUSH1), 0x0, byte(vm.JUMP), 0x0}
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func dfTest2() {
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x2, byte(vm.PUSH1), 0x6, byte(vm.JUMP), 0x0}
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func dfTest3() {
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.JUMP), 0x0}
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
//should fail to find concrete jump
|
||
|
func absIntTest1() {
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.JUMP), 0x0}
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
//should fail to find concrete jump
|
||
|
func absIntTest2() {
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = []byte{byte(vm.PUSH1), 0x0, byte(vm.JUMP), 0x0}
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTest3() {
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = []byte{byte(vm.PUSH1), 0x1,
|
||
|
byte(vm.PUSH1), 0x55,
|
||
|
byte(vm.MLOAD),
|
||
|
byte(vm.LT),
|
||
|
byte(vm.PUSH1), 0x0, //jump destination
|
||
|
byte(vm.JUMPI),
|
||
|
byte(vm.STOP)}
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTest(s string) {
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestSimple00() {
|
||
|
/*
|
||
|
pragma solidity ^0.6.0;
|
||
|
contract simple00 {
|
||
|
function execute() public returns (uint) {
|
||
|
return 5;
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
const s = "6080604052348015600f57600080fd5b506004361060285760003560e01c80636146195414602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000600590509056fea2646970667358221220e2d6ab235a595eb0ea85f8cc9c54b34e1b4fb7b8f0446851d77e72e6d973b15364736f6c634300060c0033"
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestDiv00() {
|
||
|
/*
|
||
|
pragma solidity ^0.6.0;
|
||
|
contract div00 {
|
||
|
function execute(uint i) pure public returns (uint) {
|
||
|
return 3 / i;
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
const s = "6080604052348015600f57600080fd5b506004361060285760003560e01c8063fe0d94c114602d575b600080fd5b605660048036036020811015604157600080fd5b8101908080359060200190929190505050606c565b6040518082815260200191505060405180910390f35b600081600381607757fe5b04905091905056fea2646970667358221220b094fe68fc0d94f35a01aa902290c8244fecb2ad6d1e773d7be369553fd8d48264736f6c63430006060033"
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestRequires00() {
|
||
|
/*
|
||
|
pragma solidity 0.4.24;
|
||
|
contract requires00 {
|
||
|
function execute(uint256 a0) public returns (address) {
|
||
|
require(a0 > 0);
|
||
|
return 5;
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
const s = "608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063fe0d94c1146044575b600080fd5b348015604f57600080fd5b50606c6004803603810190808035906020019092919050505060ae565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000808211151560bd57600080fd5b600590509190505600a165627a7a723058206e2f5feea3d6988c01bdd0e633ee0b3ee25e22144b361f39e79d525ce072ae7b0029"
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestCall01() {
|
||
|
/*
|
||
|
pragma solidity 0.5.0;
|
||
|
contract call01 {
|
||
|
uint public nonce;
|
||
|
|
||
|
function execute(bool condition, uint gasLimit, uint value, bytes memory data, address destination) public {
|
||
|
require(condition);
|
||
|
nonce = nonce + 1;
|
||
|
bool success = false;
|
||
|
assembly { success := call(gasLimit, destination, value, add(data, 0x20), mload(data), 0, 0) }
|
||
|
require(success);
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
const s = "60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806361fa2d7114610051578063affed0e014610159575b600080fd5b34801561005d57600080fd5b50610157600480360360a081101561007457600080fd5b810190808035151590602001909291908035906020019092919080359060200190929190803590602001906401000000008111156100b157600080fd5b8201836020820111156100c357600080fd5b803590602001918460018302840111640100000000831117156100e557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610184565b005b34801561016557600080fd5b5061016e6101c4565b6040518082815260200191505060405180910390f35b84151561019057600080fd5b600160005401600081905550600080905060008084516020860187868af190508015156101bc57600080fd5b505050505050565b6000548156fea165627a7a723058206ad69eb8bdde0a17439a080093eb09b7f9cb9f2c8ecc602773db3599cde132f10029"
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestEcrecoverLoop02() {
|
||
|
/*
|
||
|
pragma solidity 0.5.0;
|
||
|
contract ecrecoverloop02 {
|
||
|
function execute(bytes32 hash, bytes memory data,
|
||
|
uint8[2] memory sigV, bytes32[2] memory sigR, bytes32[2] memory sigS) pure public {
|
||
|
for (uint i = 0; i < 2; i++) {
|
||
|
address recovered = ecrecover(hash, sigV[i], sigR[i], sigS[i]);
|
||
|
require(recovered > address(0));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
const s = "608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633543d4b214610046575b600080fd5b34801561005257600080fd5b506101da600480360361010081101561006a57600080fd5b81019080803590602001909291908035906020019064010000000081111561009157600080fd5b8201836020820111156100a357600080fd5b803590602001918460018302840111640100000000831117156100c557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929080604001906002806020026040519081016040528092919082600260200280828437600081840152601f19601f820116905080830192505050505050919291929080604001906002806020026040519081016040528092919082600260200280828437600081840152601f19601f820116905080830192505050505050919291929080604001906002806020026040519081016040528092919082600260200280828437600081840152601f19601f82011690508083019250505050505091929192905050506101dc565b005b60008090505b60028110156102d557600060018786846002811015156101fe57fe5b6020020151868560028110151561021157fe5b6020020151868660028110151561022457fe5b602002015160405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015610280573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161115156102c757600080fd5b5080806001019150506101e2565b50505050505056fea165627a7a723058200e559ecf0b4ed3978069fd9e401adb4043ef711a33a5926f0e081d7bcdf08bb80029"
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestStorageVar03() {
|
||
|
/*
|
||
|
pragma solidity 0.5.0;
|
||
|
contract storagevar03 {
|
||
|
uint private n;
|
||
|
|
||
|
function execute() public returns(uint) {
|
||
|
n = 5;
|
||
|
require(false);
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
const s = "608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806361461954146044575b600080fd5b348015604f57600080fd5b506056606c565b6040518082815260200191505060405180910390f35b6000600560008190555060001515608257600080fd5b9056fea165627a7a723058206c2e2e763fa3e914d5806ac22d4cf3bd0ff53cd57740965d5e5d05934668a9110029"
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestStaticLoop00() {
|
||
|
/*
|
||
|
pragma solidity 0.5.0;
|
||
|
contract staticloop00 {
|
||
|
function execute(uint a0) pure external returns(uint256) {
|
||
|
uint sum = a0;
|
||
|
require (a0 < 10);
|
||
|
for (uint i = 0; i < 3; i++) {
|
||
|
sum += i;
|
||
|
}
|
||
|
return sum;
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
const s = "608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063fe0d94c1146044575b600080fd5b348015604f57600080fd5b50607960048036036020811015606457600080fd5b8101908080359060200190929190505050608f565b6040518082815260200191505060405180910390f35b600080829050600a8310151560a357600080fd5b60008090505b600381101560c2578082019150808060010191505060a9565b508091505091905056fea165627a7a72305820e9eae4d836605e8f28df860b8f590e6cd933ddcbf111d99767c764aa99f093900029"
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestStaticLoop01() {
|
||
|
/*
|
||
|
pragma solidity 0.5.0;
|
||
|
contract staticloop00 {
|
||
|
function execute(uint a0) pure external returns(uint256) {
|
||
|
uint sum = a0;
|
||
|
for (uint i = 0; i < 1; i++) {
|
||
|
sum += i;
|
||
|
}
|
||
|
return sum;
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
const s = "6080604052348015600f57600080fd5b506004361060285760003560e01c8063fe0d94c114602d575b600080fd5b605660048036036020811015604157600080fd5b8101908080359060200190929190505050606c565b6040518082815260200191505060405180910390f35b60008082905060008090505b6001811015609157808201915080806001019150506078565b508091505091905056fea26469706673582212206a12d74a991e3b9cbf04e5abed951fe8a0042780f7a9fe889fd798624b44be1264736f6c63430006060033"
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestPrivateFunction01() {
|
||
|
/*
|
||
|
pragma solidity ^0.6.6;
|
||
|
contract PrivateFunction {
|
||
|
function f(uint a0) pure private {
|
||
|
require (a0 < 10);
|
||
|
}
|
||
|
function execute(uint a0) pure external returns(uint256) {
|
||
|
f(a0);
|
||
|
a0 = a0 + 1;
|
||
|
f(a0);
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
const s = "6080604052348015600f57600080fd5b506004361060285760003560e01c8063fe0d94c114602d575b600080fd5b605660048036036020811015604157600080fd5b8101908080359060200190929190505050606c565b6040518082815260200191505060405180910390f35b60006075826087565b6001820191506082826087565b919050565b600a8110609357600080fd5b5056fea26469706673582212201621427408bf92a9a07dd10d32e63a8421461a0778eeaba88b9fd84e3769b5ca64736f6c63430006060033"
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestPrivateFunction02() {
|
||
|
/*
|
||
|
pragma solidity 0.6.12;
|
||
|
contract DepositContract {
|
||
|
function get_deposit_root(bytes32 node) external view returns (uint64) {
|
||
|
return to_little_endian_64();
|
||
|
}
|
||
|
function get_deposit_count() external view returns (uint64) {
|
||
|
return to_little_endian_64();
|
||
|
}
|
||
|
function to_little_endian_64() internal pure returns (uint64) {
|
||
|
return 15;
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
const s = "6080604052348015600f57600080fd5b506004361060325760003560e01c8063621fd130146037578063da36c6a314605d575b600080fd5b603d60a6565b604051808267ffffffffffffffff16815260200191505060405180910390f35b608660048036036020811015607157600080fd5b810190808035906020019092919050505060b3565b604051808267ffffffffffffffff16815260200191505060405180910390f35b600060ae60c2565b905090565b600060bb60c2565b9050919050565b6000600f90509056fea264697066735822122002e819f5f340845231359a0b3bc4134fb1daff9c5397e4c6d3101e54d0cdee0b64736f6c634300060c0033"
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestDepositContract() {
|
||
|
const s = "60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
func absIntTestDepositContract2() {
|
||
|
const s = "60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100b4578063621fd130146101e1578063c5f2892f14610271575b600080fd5b34801561005057600080fd5b5061009c6004803603602081101561006757600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916906020019092919050505061029c565b60405180821515815260200191505060405180910390f35b6101df600480360360808110156100ca57600080fd5b81019080803590602001906401000000008111156100e757600080fd5b8201836020820111156100f957600080fd5b8035906020019184600183028401116401000000008311171561011b57600080fd5b90919293919293908035906020019064010000000081111561013c57600080fd5b82018360208201111561014e57600080fd5b8035906020019184600183028401116401000000008311171561017057600080fd5b90919293919293908035906020019064010000000081111561019157600080fd5b8201836020820111156101a357600080fd5b803590602001918460018302840111640100000000831117156101c557600080fd5b90919293919293908035906020019092919050505061036e565b005b3480156101ed57600080fd5b506101f6610fad565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561023657808201518184015260208101905061021b565b50505050905090810190601f1680156102635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561027d57600080fd5b50610286610fbf565b6040518082815260200191505060405180910390f35b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061036757507f85640907000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b603087879050146103ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806116bb6026913960400191505060405180910390fd5b60208585905014610426576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806116526036913960400191505060405180910390fd5b60608383905014610482576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061172e6029913960400191505060405180910390fd5b670de0b6b3a76400003410156104e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806117086026913960400191505060405180910390fd5b6000633b9aca0034816104f257fe5b0614610549576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806116886033913960400191505060405180910390fd5b6000633b9aca00348161055857fe5b04905067ffffffffffffffff80168111156105be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806116e16027913960400191505060405180910390fd5b60606105c9826112e3565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105fe6020546112e3565b60405180806020018060200180602001806020018060200186810386528e8e82818152602001925080828437600081840152601f19601f82011690508083019250505086810385528c8c82818152602001925080828437600081840152601f19601f82011690508083019250505086810384528a818151815260200191508051906020019080838360005b838110156106a4578082015181840152602081019050610689565b50505050905090810190601f1680156106d15780820380516001836020036101000a031916815260200191505b508681038352898982818152602001925080828437600081840152601f19601f820116905080830192505050868103825287818151815260200191508051906020019080838360005b8381101561073557808201518184015260208101905061071a565b50505050905090810190601f1680156107625780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b6040516020018084848082843780830192505050826fffffffffffffffffffffffffffffffff1916815260100193505050506040516020818303038152906040526040518082805190602001908083835b602083106107f957805182526020820191506020810190506020830392506107d6565
|
||
|
decoded, err := hex.DecodeString(s)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, false)
|
||
|
contract.Code = decoded
|
||
|
vm.AbsIntCfgHarness(contract)
|
||
|
}
|
||
|
|
||
|
/////////////////////////////////////////////////////
|
||
|
|
||
|
type dummyAccount struct{}
|
||
|
|
||
|
func (dummyAccount) SubBalance(amount *big.Int) {}
|
||
|
func (dummyAccount) AddBalance(amount *big.Int) {}
|
||
|
func (dummyAccount) SetAddress(common.Address) {}
|
||
|
func (dummyAccount) Value() *big.Int { return nil }
|
||
|
func (dummyAccount) SetBalance(*big.Int) {}
|
||
|
func (dummyAccount) SetNonce(uint64) {}
|
||
|
func (dummyAccount) Balance() *big.Int { return nil }
|
||
|
func (dummyAccount) Address() common.Address { return common.Address{} }
|
||
|
func (dummyAccount) ReturnGas(*big.Int) {}
|
||
|
func (dummyAccount) SetCode(common.Hash, []byte) {}
|
||
|
func (dummyAccount) ForEachStorage(cb func(key, value common.Hash) bool) {}
|
||
|
|
||
|
/*
|
||
|
func testGenCfg() error {
|
||
|
env := vm.NewEVM(vm.Context{BlockNumber: big.NewInt(1)}, &dummyStatedb{}, params.TestChainConfig,
|
||
|
vm.Config{
|
||
|
EVMInterpreter: "SaInterpreter",
|
||
|
}, nil)
|
||
|
|
||
|
contract := vm.NewContract(dummyAccount{}, dummyAccount{}, uint256.NewInt(), 10000, vm.NewDestsCache(50000))
|
||
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x1, 0x0}
|
||
|
//contract.Code = []byte{byte(vm.ADD), 0x1, 0x1, 0x0}
|
||
|
|
||
|
jt := newIstanbulInstructionSet()
|
||
|
vm.ToCfg0(contract)
|
||
|
//_, err := env.Interpreter().Run(contract, []byte{}, false)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
print("Done")
|
||
|
return nil
|
||
|
}*/
|