新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!

Commit 53d3d179 authored by mosesyzding's avatar mosesyzding

add compatable for bugfix of process create ret

parent 93c35466
...@@ -375,6 +375,17 @@ func (r *ContractManagerRuntime) GetAllContracts(context protocol.TxSimContext) ...@@ -375,6 +375,17 @@ func (r *ContractManagerRuntime) GetAllContracts(context protocol.TxSimContext)
return result, nil return result, nil
} }
func differentiateErr(version uint32, rtType commonPb.RuntimeType, msg string) (*commonPb.Contract, uint64, error) {
if version < 2218 {
return nil, 0, fmt.Errorf("%s, %s", errContractInitFail, msg)
}
if rtType == commonPb.RuntimeType_EVM {
return nil, 0, errors.New(msg)
}
return nil, 0, fmt.Errorf("%s, %s", errContractInitFail, msg)
}
//InstallContract 安装新合约 //InstallContract 安装新合约
func (r *ContractManagerRuntime) InstallContract(context protocol.TxSimContext, name, version string, byteCode []byte, func (r *ContractManagerRuntime) InstallContract(context protocol.TxSimContext, name, version string, byteCode []byte,
runTime commonPb.RuntimeType, initParameters map[string][]byte) (*commonPb.Contract, uint64, error) { runTime commonPb.RuntimeType, initParameters map[string][]byte) (*commonPb.Contract, uint64, error) {
...@@ -413,13 +424,16 @@ func (r *ContractManagerRuntime) InstallContract(context protocol.TxSimContext, ...@@ -413,13 +424,16 @@ func (r *ContractManagerRuntime) InstallContract(context protocol.TxSimContext,
return nil, 0, err return nil, 0, err
} }
//实例化合约,并init合约,产生读写集 //实例化合约,并init合约,产生读写集
blockVersion := context.GetBlockVersion()
result, _, statusCode := context.CallContract(contract, protocol.ContractInitMethod, byteCode, initParameters, result, _, statusCode := context.CallContract(contract, protocol.ContractInitMethod, byteCode, initParameters,
0, commonPb.TxType_INVOKE_CONTRACT) 0, commonPb.TxType_INVOKE_CONTRACT)
if statusCode != commonPb.TxStatusCode_SUCCESS { if statusCode != commonPb.TxStatusCode_SUCCESS {
return nil, 0, fmt.Errorf("%s, %s", errContractInitFail, result.Message) //return nil, 0, fmt.Errorf("%s, %s", errContractInitFail, result.Message)
return differentiateErr(blockVersion, runTime, result.Message)
} }
if result.Code > 0 { //throw error if result.Code > 0 { //throw error
return nil, 0, fmt.Errorf("%s, %s", errContractInitFail, result.Message) //return nil, 0, fmt.Errorf("%s, %s", errContractInitFail, result.Message)
return differentiateErr(blockVersion, runTime, result.Message)
} }
if runTime == commonPb.RuntimeType_EVM { if runTime == commonPb.RuntimeType_EVM {
//save bytecode body //save bytecode body
...@@ -427,7 +441,8 @@ func (r *ContractManagerRuntime) InstallContract(context protocol.TxSimContext, ...@@ -427,7 +441,8 @@ func (r *ContractManagerRuntime) InstallContract(context protocol.TxSimContext,
if len(result.Result) > 0 { if len(result.Result) > 0 {
err := context.Put(ContractName, byteCodeKey, result.Result) err := context.Put(ContractName, byteCodeKey, result.Result)
if err != nil { if err != nil {
return nil, 0, fmt.Errorf("%s, %s", errContractInitFail, err) //return nil, 0, fmt.Errorf("%s, %s", errContractInitFail, err)
return differentiateErr(blockVersion, runTime, err.Error())
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment