-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
代@CodeCmn提交只读跨链的实现,和3.10版本实现的方式一致 #289
base: master
Are you sure you want to change the base?
代@CodeCmn提交只读跨链的实现,和3.10版本实现的方式一致 #289
Conversation
} | ||
|
||
// NewCrossQueryCacheWithData return CrossQuery instance while posttx | ||
func NewCrossQueryCacheWithData(crossQueries []*pb.CrossQueryInfo) *CrossQueryCache { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
post tx的cache没有实现?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感谢您的贡献😄 在只读跨链时的post tx阶段,只需要通过缓存验证,而无需再次发起网络请求,好像没有看到对应代码实现
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,我们明天看下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (cqc *CrossQueryCache) CrossQuery(
crossQueryRequest *pb.CrossQueryRequest,
queryMeta *pb.CrossQueryMeta) (*pb.ContractResponse, error) {
fmt.Println("Receive CrossQuery", "crossQueryRequest", crossQueryRequest, "queryMeta", queryMeta)
if !isQueryMetaValid(queryMeta) {
return nil, fmt.Errorf("isQueryParamValid check failed")
}
// Call endorsor for responce
if cqc.isPenetrate {
queryInfo, err := crossQueryFromEndorsor(crossQueryRequest, queryMeta)
if err != nil {
return nil, err
}
fmt.Println("crossQueryFromEndorsor", "无缓存?", cqc.isPenetrate)
cqc.crossQueryCaches = append(cqc.crossQueryCaches, queryInfo)
return queryInfo.GetResponse().GetResponse(), nil
}
fmt.Println("crossQueryFromEndorsor", "有缓存?", cqc.isPenetrate)
// 验证背书规则、参数有效性、时间戳有效性
if cqc.crossQueryIdx > len(cqc.crossQueryCaches)-1 {
return nil, fmt.Errorf("len of crossQueryCaches not match the contract")
}
crossQuery := cqc.crossQueryCaches[cqc.crossQueryIdx]
// 验证request、签名等信息
if !isCossQueryValid(crossQueryRequest, queryMeta, crossQuery) {
return nil, fmt.Errorf("isCossQueryValid check failed")
}
cqc.crossQueryIdx++
return crossQuery.GetResponse().GetResponse(), nil
}
是否要达到的效果如上面代码中的fmt所示,如果有缓存就不再 crossQueryFromEndorsor()发起网络请求,没有缓存则发起网络请求。
我本地刚才修改了下测试,执行跨链调用命令
./bin/xchain-cli wasm invoke cross_query_demo --method cross_query -H 127.0.0.1:37101 --fee 1000
加上 --fee, 会走缓存,如果不加 --fee, 则会发送网络请求。这样是否正常?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我按照v3.10的代码改了下,加上fee就会走缓存,不加就不行。。 我再看看
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v3.11 跟踪调用 NewCrossQueryCacheWithData() 该方法
只有
func (uv *UtxoVM) ImmediateVerifyTx(tx *pb.Transaction, isRootTx bool) (bool, error) {}
⬇
func (uv *UtxoVM) verifyTxRWSets(tx *pb.Transaction) (bool, error) {}
⬇
func (s *XModel) PrepareEnv(tx *pb.Transaction) (*Env, error) {}
⬇
func NewXModelCacheWithInputs(vdatas []*xmodel_pb.VersionedData, utxoInputs []*pb.TxInput, crossQueries []*pb.CrossQueryInfo) *XMCache {}
调用到。
预执行代码中,好像也没看到调用最上层 ImmediateVerifyTx()
这个方法
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
预执行调用的 NewCrossQueryCache()
<= NewXModelCache()
<= PreExec()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在的XuperCore的master分支上有 PreExec()
=> NewStateSandbox()
=> NewXModelCache()
=> NewCrossQueryCache()
。是对应上边的么,我看内容一样。但是没找到调用 NewCrossQueryCacheWithData()
这个方法。
😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的。 因为NewXModelCacheWithInputs
被移除了,统一通过NewXModelCache(cfg *contract.SandboxConfig)
来区分预执行和验证阶段。
可以问下 `只读跨链时的post tx阶段,只需要通过缓存验证,而无需再次发起网络请求` 这部分代码在v3.10或者三点多的版本 哪里有实现么,参考一下。
…------------------ 原始邮件 ------------------
发件人: "xuperchain/xupercore" ***@***.***>;
发送时间: 2021年11月15日(星期一) 晚上8:57
***@***.***>;
***@***.******@***.***>;
主题: Re: [xuperchain/xupercore] ***@***.***提交只读跨链的实现,和3.10版本实现的方式一致 (PR #289)
@preminem commented on this pull request.
In kernel/contract/sandbox/cross_query_cache.go:
> +} + +type queryRes struct { + queryRes *pb.CrossQueryResponse + signs *pb.SignatureInfo +} + +// NewCrossQueryCache return CrossQuery instance while preexec +func NewCrossQueryCache() *CrossQueryCache { + return &CrossQueryCache{ + isPenetrate: true, + } +} + +// NewCrossQueryCacheWithData return CrossQuery instance while posttx +func NewCrossQueryCacheWithData(crossQueries []*pb.CrossQueryInfo) *CrossQueryCache {
感谢您的贡献😄 在只读跨链时的post tx阶段,只需要通过缓存验证,而无需再次发起网络请求,好像没有看到对应代码实现
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
可以参考3.11 分支, |
0a5e94e
to
30ca9b3
Compare
) | ||
|
||
// MarshalMessages marshal protobuf message slice | ||
func MarshalMessages(msgs interface{}) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在bcs/ledger/xledger/state/xmodel/message.go 已经实现了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的 我把我多出来这个去掉
4423aa7
to
79b7480
Compare
Description
What is the purpose of the change?
代@CodeCmn提交只读跨链的实现,和3.10版本实现的方式一致
Fixes # (issue)
Type of change
Please delete options that are not relevant.
Brief of your solution
代@CodeCmn提交只读跨链的实现,和3.10版本实现的方式一致
How Has This Been Tested?
代@CodeCmn提交只读跨链的实现,和3.10版本实现的方式一致