Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!
Open sidebar
T BaaS
vm-native
Commits
53d3d179
Commit
53d3d179
authored
Jun 16, 2023
by
mosesyzding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add compatable for bugfix of process create ret
parent
93c35466
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
contractmgr/contract_manager.go
contractmgr/contract_manager.go
+18
-3
No files found.
contractmgr/contract_manager.go
View file @
53d3d179
...
...
@@ -375,6 +375,17 @@ func (r *ContractManagerRuntime) GetAllContracts(context protocol.TxSimContext)
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 安装新合约
func
(
r
*
ContractManagerRuntime
)
InstallContract
(
context
protocol
.
TxSimContext
,
name
,
version
string
,
byteCode
[]
byte
,
runTime
commonPb
.
RuntimeType
,
initParameters
map
[
string
][]
byte
)
(
*
commonPb
.
Contract
,
uint64
,
error
)
{
...
...
@@ -413,13 +424,16 @@ func (r *ContractManagerRuntime) InstallContract(context protocol.TxSimContext,
return
nil
,
0
,
err
}
//实例化合约,并init合约,产生读写集
blockVersion
:=
context
.
GetBlockVersion
()
result
,
_
,
statusCode
:=
context
.
CallContract
(
contract
,
protocol
.
ContractInitMethod
,
byteCode
,
initParameters
,
0
,
commonPb
.
TxType_INVOKE_CONTRACT
)
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
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
{
//save bytecode body
...
...
@@ -427,7 +441,8 @@ func (r *ContractManagerRuntime) InstallContract(context protocol.TxSimContext,
if
len
(
result
.
Result
)
>
0
{
err
:=
context
.
Put
(
ContractName
,
byteCodeKey
,
result
.
Result
)
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
())
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment