diff --git a/c/other_contracts.h b/c/other_contracts.h index 2fe2a5da..82c5d7c4 100644 --- a/c/other_contracts.h +++ b/c/other_contracts.h @@ -67,7 +67,6 @@ int recover_account(gw_context_t* ctx, return ERROR_RECOVER_ACCOUNT; } } - debug_print_data("script", script, script_len); *output = (uint8_t *)malloc(32); if (*output == NULL) { ckb_debug("malloc failed"); @@ -137,4 +136,3 @@ int eth_to_godwoken_addr(gw_context_t* ctx, } #endif /* #define OTHER_CONTRACTS_H_ */ - diff --git a/c/polyjuice.h b/c/polyjuice.h index 62c35bab..4be71ea1 100644 --- a/c/polyjuice.h +++ b/c/polyjuice.h @@ -184,7 +184,6 @@ int parse_args(struct evmc_message* msg, uint128_t* gas_price, value.bytes[31 - i] = args[offset + i]; } offset += 16; - debug_print_data("[value]", value.bytes, 32); /* args[48..52] */ uint32_t input_size = *((uint32_t*)(args + offset)); @@ -203,7 +202,6 @@ int parse_args(struct evmc_message* msg, uint128_t* gas_price, /* args[52..52+input_size] */ uint8_t* input_data = args + offset; - debug_print_data("[input_data]", input_data, input_size); int ret; evmc_address sender{0}; @@ -285,7 +283,6 @@ int load_account_code(gw_context_t* gw_ctx, uint32_t account_id, debug_print_int("[load_account_code] sys_load failed", ret); return ret; } - debug_print_data("[load_account_code] data_hash", data_hash, 32); bool is_data_hash_zero = true; for (size_t i = 0; i < 32; i++) { @@ -302,11 +299,6 @@ int load_account_code(gw_context_t* gw_ctx, uint32_t account_id, uint64_t old_code_size = *code_size; ret = gw_ctx->sys_load_data(gw_ctx, data_hash, code_size, offset, code); - debug_print_data("code data", code, *code_size > 100 ? 100 : *code_size); - if (*code_size > 100) { - ckb_debug("...data..."); - debug_print_int("[load_account_code] code_size", *code_size); - } if (ret != 0) { ckb_debug("[load_account_code] sys_load_data failed"); return ret; @@ -480,7 +472,6 @@ size_t copy_code(struct evmc_host_context* context, const evmc_address* address, context->error_code = ret; return 0; } - debug_print_data("code slice", buffer_data, buffer_size); ckb_debug("END copy_code"); return 0; } @@ -551,7 +542,6 @@ struct evmc_result call(struct evmc_host_context* context, ckb_debug("BEGIN call"); debug_print_int("msg.gas", msg->gas); debug_print_int("msg.depth", msg->depth); - debug_print_data("msg.input_data", msg->input_data, msg->input_size); debug_print_int("msg.kind", msg->kind); debug_print_data("call.sender", msg->sender.bytes, 20); debug_print_data("call.destination", msg->destination.bytes, 20); @@ -594,7 +584,6 @@ struct evmc_result call(struct evmc_host_context* context, return res; } res.status_code = EVMC_SUCCESS; - debug_print_data("output data", res.output_data, res.output_size); } else { ret = handle_message(gw_ctx, context->from_id, context->to_id, &context->destination, msg, &res); if (is_fatal_error(ret)) { @@ -634,7 +623,6 @@ void emit_log(struct evmc_host_context* context, const evmc_address* address, const uint8_t* data, size_t data_size, const evmc_bytes32 topics[], size_t topics_count) { ckb_debug("BEGIN emit_log"); - debug_print_data("log.data", data, data_size); /* output[ 0..20] = callee_contract.address output[20..24] = data_size_u32 @@ -792,7 +780,6 @@ int create_new_account(gw_context_t* ctx, debug_print_int("from_id", from_id); debug_print_int("nonce", nonce); rlp_encode_sender_and_nonce(&msg->sender, nonce, data, &data_len); - debug_print_data("rlp data", data, data_len); } else if (msg->kind == EVMC_CREATE2) { /* CREATE2 contract account script.args[36..36+20] content before hash Include: @@ -902,7 +889,6 @@ int execute_in_evmone(gw_context_t* ctx, /* Execute the code in EVM */ debug_print_int("[execute_in_evmone] code size", code_size); debug_print_int("[execute_in_evmone] input_size", msg->input_size); - debug_print_data("[execute_in_evmone] msg.input_data", msg->input_data, msg->input_size); *res = vm->execute(vm, &interface, &context, EVMC_MAX_REVISION, msg, code_data, code_size); if (res->status_code != EVMC_SUCCESS && res->status_code != EVMC_REVERT) { res->output_data = NULL; @@ -1117,7 +1103,6 @@ int handle_message(gw_context_t* ctx, memcpy(res->create_address.bytes, msg.destination.bytes, 20); } - debug_print_data("[handle_message] output data", res->output_data, res->output_size); debug_print_int("[handle_message] output size", res->output_size); debug_print_int("[handle_message] gas left", res->gas_left); uint32_t used_memory; diff --git a/c/polyjuice_utils.h b/c/polyjuice_utils.h index 8088ef74..5a50ce4a 100644 --- a/c/polyjuice_utils.h +++ b/c/polyjuice_utils.h @@ -53,8 +53,6 @@ int build_script(const uint8_t code_hash[32], const uint8_t hash_type, } memcpy(args_seg.ptr, (uint8_t*)(&args_len), 4); memcpy(args_seg.ptr + 4, args, args_len); - debug_print_data("script.args", args, args_len); - debug_print_data("script.code_hash", code_hash, 32); debug_print_int("script.hash_type", hash_type); mol_builder_t script_builder; @@ -76,7 +74,6 @@ int build_script(const uint8_t code_hash[32], const uint8_t hash_type, *script_seg = script_res.seg; - debug_print_data("script ", script_seg->ptr, script_seg->size); if (MolReader_Script_verify(script_seg, false) != MOL_OK) { ckb_debug("built an invalid script"); return FATAL_POLYJUICE; diff --git a/polyjuice-tests/fuzz/ckb_syscalls.h b/polyjuice-tests/fuzz/ckb_syscalls.h index b6d0a501..6b1d1ac8 100644 --- a/polyjuice-tests/fuzz/ckb_syscalls.h +++ b/polyjuice-tests/fuzz/ckb_syscalls.h @@ -150,7 +150,6 @@ static int inline __internal_syscall(long n, long _a0, long _a1, long _a2, // mock syscall(GW_SYS_LOG, account_id, service_flag, data_length, data, 0, 0) case GW_SYS_LOG: // TODO: @see emit_evm_result_log dbg_print("[GW_SYS_LOG] service_flag[%d] account[%d] ", (uint8_t)_a1, _a1); - // TODO: debug_print_data("GW_SYS_LOG", (uint32_t)_a3, (uint8_t *)_a2); return 0; // mock syscall(GW_SYS_PAY_FEE, payer_addr, short_addr_len, sudt_id, &amount, 0, 0) diff --git a/polyjuice-tests/src/test_cases/evm-contracts/SimpleWallet.bin b/polyjuice-tests/src/test_cases/evm-contracts/SimpleWallet.bin new file mode 100644 index 00000000..3fb50174 --- /dev/null +++ b/polyjuice-tests/src/test_cases/evm-contracts/SimpleWallet.bin @@ -0,0 +1 @@ +60806040526000600460146101000a81548160ff0219169083151502179055506000600460156101000a81548160ff02191690831515021790555034801561004657600080fd5b50612860806100566000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80637f3e71fa116100f9578063abe3219c11610097578063ebf14e1b11610071578063ebf14e1b14610c16578063ebf59f9214610c75578063fc0f392d14610c93578063fdd3a51214610c9d576101a9565b8063abe3219c14610b96578063bbed83df14610bb6578063cec1550914610bf8576101a9565b8063979f1976116100d3578063979f1976146109e65780639bf7ef6314610a14578063a0b7967b14610af5578063a44b626f14610b13576101a9565b80637f3e71fa1461096657806383dd41c61461099a57806385f132c2146109b8576101a9565b8063422e8e08116101665780636ff89db0116101405780636ff89db01461066157806371919408146107c3578063736c0d5b146108b25780637df73e271461090c576101a9565b8063422e8e081461045b57806345550a511461055457806350210b7714610643576101a9565b806301f9b313146101ae57806306661abd146102065780630dcd7a6c14610224578063158ef93e146102fb5780632aec98ac1461031b578063391252151461034f575b600080fd5b6101da600480360360208110156101c457600080fd5b8101908080359060200190929190505050610cd1565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61020e610d0d565b6040518082815260200191505060405180910390f35b6102f9600480360360c081101561023a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803590602001906401000000008111156102b557600080fd5b8201836020820111156102c757600080fd5b803590602001918460018302840111640100000000831117156102e957600080fd5b9091929391929390505050610d13565b005b610303610ea9565b60405180821515815260200191505060405180910390f35b610323610ebc565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610459600480360360c081101561036557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156103ac57600080fd5b8201836020820111156103be57600080fd5b803590602001918460018302840111640100000000831117156103e057600080fd5b909192939192939080359060200190929190803590602001909291908035906020019064010000000081111561041557600080fd5b82018360208201111561042757600080fd5b8035906020019184600183028401116401000000008311171561044957600080fd5b9091929391929390505050610ee2565b005b6105286004803603606081101561047157600080fd5b81019080803590602001909291908035906020019064010000000081111561049857600080fd5b8201836020820111156104aa57600080fd5b803590602001918460018302840111640100000000831117156104cc57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001909291905050506112c7565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106176004803603604081101561056a57600080fd5b81019080803590602001909291908035906020019064010000000081111561059157600080fd5b8201836020820111156105a357600080fd5b803590602001918460018302840111640100000000831117156105c557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506114fc565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61064b6115de565b6040518082815260200191505060405180910390f35b6107ad600480360360c081101561067757600080fd5b810190808035906020019064010000000081111561069457600080fd5b8201836020820111156106a657600080fd5b803590602001918460018302840111640100000000831117156106c857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561075557600080fd5b82018360208201111561076757600080fd5b8035906020019184600183028401116401000000008311171561078957600080fd5b909192939192939080359060200190929190803590602001909291905050506115e4565b6040518082815260200191505060405180910390f35b610886600480360360408110156107d957600080fd5b81019080803590602001909291908035906020019064010000000081111561080057600080fd5b82018360208201111561081257600080fd5b8035906020019184600183028401116401000000008311171561083457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506116af565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6108f4600480360360208110156108c857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061179f565b60405180821515815260200191505060405180910390f35b61094e6004803603602081101561092257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506117bf565b60405180821515815260200191505060405180910390f35b61096e611814565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6109a261183e565b6040518082815260200191505060405180910390f35b6109e4600480360360208110156109ce57600080fd5b8101908080359060200190929190505050611848565b005b610a12600480360360208110156109fc57600080fd5b8101908080359060200190929190505050611852565b005b610ac9600480360360a0811015610a2a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190640100000000811115610a7157600080fd5b820183602082011115610a8357600080fd5b80359060200191846001830284011164010000000083111715610aa557600080fd5b90919293919293908035906020019092919080359060200190929190505050611b0a565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610afd611cf9565b6040518082815260200191505060405180910390f35b610b9460048036036040811015610b2957600080fd5b8101908080359060200190640100000000811115610b4657600080fd5b820183602082011115610b5857600080fd5b80359060200191846020830284011164010000000083111715610b7a57600080fd5b909192939192939080359060200190929190505050611d4c565b005b610b9e611ff0565b60405180821515815260200191505060405180910390f35b610be260048036036020811015610bcc57600080fd5b8101908080359060200190929190505050612003565b6040518082815260200191505060405180910390f35b610c00612060565b6040518082815260200191505060405180910390f35b610c1e61206a565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610c61578082015181840152602081019050610c46565b505050509050019250505060405180910390f35b610c7d6120f8565b6040518082815260200191505060405180910390f35b610c9b6120fe565b005b610ca56121e3565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60018181548110610cde57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60065481565b610d1c336117bf565b610d8e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f4e6f6e2d7369676e657220696e206f6e6c795369676e6572206d6574686f640081525060200191505060405180910390fd5b6000610d98612209565b88888888886040516020018087805190602001908083835b60208310610dd35780518252602082019150602081019050602083039250610db0565b6001836020036101000a0380198251168184511680821785525050505050509050018673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018581526020018473ffffffffffffffffffffffffffffffffffffffff1660601b81526014018381526020018281526020019650505050505050604051602081830303815290604052805190602001209050610e73888285858989611b0a565b50610e9f88888873ffffffffffffffffffffffffffffffffffffffff166122469092919063ffffffff16565b5050505050505050565b600460159054906101000a900460ff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610eeb336117bf565b610f5d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f4e6f6e2d7369676e657220696e206f6e6c795369676e6572206d6574686f640081525060200191505060405180910390fd5b6000610f676122e8565b8989898989896040516020018088805190602001908083835b60208310610fa35780518252602082019150602081019050602083039250610f80565b6001836020036101000a0380198251168184511680821785525050505050509050018773ffffffffffffffffffffffffffffffffffffffff1660601b81526014018681526020018585808284378083019250505083815260200182815260200197505050505050505060405160208183030381529060405280519060200120905060006110348a8386868a8a611b0a565b90507f59bed9ab5d78073465dd642a9e3e76dfdb7d53bcae9d09df7d0b8f5234d5a8063382848d8d8d8d604051808873ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509850505050505050505060405180910390a160008a73ffffffffffffffffffffffffffffffffffffffff168a8a8a60405180838380828437808301925050509250505060006040518083038185875af1925050503d8060008114611171576040519150601f19603f3d011682016040523d82523d6000602084013e611176565b606091505b50509050806111ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f43616c6c20657865637574696f6e206661696c6564000000000000000000000081525060200191505060405180910390fd5b7f59bed9ab5d78073465dd642a9e3e76dfdb7d53bcae9d09df7d0b8f5234d5a8063383858e8e8e8e604051808873ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509850505050505050505060405180910390a15050505050505050505050565b6000601b836040815181106112d857fe5b602001015160f81c60f81b60f81c60000b1261134c57601b836040815181106112fd57fe5b602001015160f81c60f81b60f81c0360f81b8360408151811061131c57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053505b60608484846040516020018084815260200180602001838152602001828103825284818151815260200191508051906020019080838360005b838110156113a0578082015181840152602081019050611385565b50505050905090810190601f1680156113cd5780820380516001836020036101000a031916815260200191505b5094505050505060405160208183030381529060405290506113ed6126b4565b8151610120828260208601600060f2600019f161140957600080fd5b5060008160006001811061141957fe5b6020020151905060208060ff161461147c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806127b76024913960400191505060405180910390fd5b80600381905550606060035460001c901c600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1693505050509392505050565b60006041825114611575576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f496e76616c6964207369676e6174757265202d2077726f6e67206c656e67746881525060200191505060405180910390fd5b60008360405160200180807f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250601c018281526020019150506040516020818303038152906040528051906020012090506115d581846005546112c7565b91505092915050565b60055481565b6000878787878787876040516020018088805190602001908083835b602083106116235780518252602082019150602081019050602083039250611600565b6001836020036101000a0380198251168184511680821785525050505050509050018773ffffffffffffffffffffffffffffffffffffffff1660601b815260140186815260200185858082843780830192505050838152602001828152602001975050505050505050604051602081830303815290604052805190602001209050979650505050505050565b6000806000806020850151925060408501519150606085015160001a905060018682858560405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015611727573d6000803e3d6000fd5b50505060206040510351600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16935050505092915050565b60006020528060005260406000206000915054906101000a900460ff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600554905090565b8060058190555050565b61185b336117bf565b6118cd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f4e6f6e2d7369676e657220696e206f6e6c795369676e6572206d6574686f640081525060200191505060405180910390fd5b60006118d76126d6565b6007600a806020026040519081016040528092919082600a8015611910576020028201915b8154815260200190600101908083116118fc575b5050505050905060005b600a8110156119e257838282600a811061193057fe5b602002015114156119a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f53657175656e636520494420616c72656164792075736564000000000000000081525060200191505060405180910390fd5b8183600a81106119b557fe5b60200201518282600a81106119c657fe5b602002015110156119d5578092505b808060010191505061191a565b508082600a81106119ef57fe5b60200201518311611a68576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f53657175656e63652049442062656c6f772077696e646f77000000000000000081525060200191505060405180910390fd5b6127108183600a8110611a7757fe5b602002015101831115611af2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f53657175656e63652049442061626f7665206d6178696d756d0000000000000081525060200191505060405180910390fd5b82600783600a8110611b0057fe5b0181905550505050565b6000600460149054906101000a900460ff161580611b2d5750611b2c876117bf565b5b611b9f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f45787465726e616c207472616e7366657220696e2073616665206d6f6465000081525060200191505060405180910390fd5b42831015611c15576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f5472616e73616374696f6e20657870697265640000000000000000000000000081525060200191505060405180910390fd5b6000611c658787878080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506114fc565b9050611c7083611852565b611c79816117bf565b611ceb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f496e76616c6964207369676e657200000000000000000000000000000000000081525060200191505060405180910390fd5b809150509695505050505050565b6000806000905060005b600a811015611d415781600782600a8110611d1a57fe5b01541115611d3457600781600a8110611d2f57fe5b015491505b8080600101915050611d03565b506001810191505090565b600460159054906101000a900460ff1615611dcf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f436f6e747261637420616c726561647920696e697469616c697a65640000000081525060200191505060405180910390fd5b60038383905014611e48576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f496e76616c6964206e756d626572206f66207369676e6572730000000000000081525060200191505060405180910390fd5b60005b838390508160ff161015611fb657600073ffffffffffffffffffffffffffffffffffffffff1684848360ff16818110611e8057fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611f27576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f496e76616c6964207369676e657200000000000000000000000000000000000081525060200191505060405180910390fd5b600160008086868560ff16818110611f3b57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080600101915050611e4b565b5080600581905550828260019190611fcf9291906126f9565b506001600460156101000a81548160ff021916908315150217905550505050565b600460149054906101000a900460ff1681565b6000808260405160200180807f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250601c0182815260200191505060405160208183030381529060405280519060200120905080915050919050565b6000600354905090565b606060018054806020026020016040519081016040528092919081815260200182805480156120ee57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116120a4575b5050505050905090565b60035481565b612107336117bf565b612179576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f4e6f6e2d7369676e657220696e206f6e6c795369676e6572206d6574686f640081525060200191505060405180910390fd5b6001600460146101000a81548160ff0219169083151502179055507f0909e8f76a4fd3e970f2eaef56c0ee6dfaf8b87c5b8d3f56ffce78e825a9115733604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60606040518060400160405280600581526020017f4552433230000000000000000000000000000000000000000000000000000000815250905090565b6122e38363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612325565b505050565b60606040518060400160405280600581526020017f4554484552000000000000000000000000000000000000000000000000000000815250905090565b6060612387826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166124149092919063ffffffff16565b905060008151111561240f578080602001905160208110156123a857600080fd5b810190808051906020019092919050505061240e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612801602a913960400191505060405180910390fd5b5b505050565b6060612423848460008561242c565b90509392505050565b606082471015612487576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806127db6026913960400191505060405180910390fd5b612490856125d5565b612502576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310612552578051825260208201915060208101905060208303925061252f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146125b4576040519150601f19603f3d011682016040523d82523d6000602084013e6125b9565b606091505b50915091506125c98282866125e8565b92505050949350505050565b600080823b905060008111915050919050565b606083156125f8578290506126ad565b60008351111561260b5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612672578082015181840152602081019050612657565b50505050905090810190601f16801561269f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b6040518060200160405280600190602082028036833780820191505090505090565b604051806101400160405280600a90602082028036833780820191505090505090565b828054828255906000526020600020908101928215612788579160200282015b8281111561278757823573ffffffffffffffffffffffffffffffffffffffff168260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190612719565b5b5090506127959190612799565b5090565b5b808211156127b257600081600090555060010161279a565b509056fe696e76616c6964207265636f7665726564207363726970742068617368206c656e677468416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212201bcc5df7da0185c9cc373157af7020fb98e88960a795b32031a352dca7ff74bf64736f6c63430007030033 \ No newline at end of file diff --git a/polyjuice-tests/src/test_cases/mod.rs b/polyjuice-tests/src/test_cases/mod.rs index 5a806f89..5991cddf 100644 --- a/polyjuice-tests/src/test_cases/mod.rs +++ b/polyjuice-tests/src/test_cases/mod.rs @@ -13,6 +13,7 @@ pub(crate) mod parse_log_event; pub(crate) mod selfdestruct; pub(crate) mod simple_storage; pub(crate) mod simple_transfer; +pub(crate) mod simple_wallet; // The account polyjuice want to create already created by meta_contract pub(crate) mod account_already_exists; diff --git a/polyjuice-tests/src/test_cases/simple_wallet.rs b/polyjuice-tests/src/test_cases/simple_wallet.rs new file mode 100644 index 00000000..f517441a --- /dev/null +++ b/polyjuice-tests/src/test_cases/simple_wallet.rs @@ -0,0 +1,46 @@ +//! Deploy muti-sign-wallet Contract +//! See https://github.com/Flouse/godwoken-examples/blob/contracts/packages/polyjuice/contracts/WalletSimple.sol/WalletSimple.json + +use crate::helper::{self, CKB_SUDT_ACCOUNT_ID}; +use gw_common::state::State; +use gw_generator::traits::StateExt; + +const BIN_CODE: &str = include_str!("./evm-contracts/SimpleWallet.bin"); + +#[test] +fn test_simple_wallet() { + let (store, mut state, generator, creator_account_id) = helper::setup(); + let block_producer_script = helper::build_eth_l2_script([0x99u8; 20]); + let block_producer_id = state + .create_account_from_script(block_producer_script) + .unwrap(); + + let from_script = helper::build_eth_l2_script([1u8; 20]); + let from_script_hash = from_script.hash(); + let from_short_address = &from_script_hash[0..20]; + let from_id = state.create_account_from_script(from_script).unwrap(); + state + .mint_sudt(CKB_SUDT_ACCOUNT_ID, from_short_address, 20000000) + .unwrap(); + let mut block_number = 0; + + // Deploy Contract + block_number += 1; + let _run_result = helper::deploy( + &generator, + &store, + &mut state, + creator_account_id, + from_id, + BIN_CODE, + 122000, + 0, + block_producer_id, + block_number, + ); + let account_script = helper::new_account_script(&mut state, creator_account_id, from_id, false); + let _contract_account_id = state + .get_account_id_by_script_hash(&account_script.hash().into()) + .unwrap() + .unwrap(); +}