代@CodeCmn提交只读跨链的实现,和3.10版本实现的方式一致#289
代@CodeCmn提交只读跨链的实现,和3.10版本实现的方式一致#289springrain wants to merge 15 commits intoOpenAtomFoundation:masterfrom
Conversation
| } | ||
|
|
||
| // NewCrossQueryCacheWithData return CrossQuery instance while posttx | ||
| func NewCrossQueryCacheWithData(crossQueries []*pb.CrossQueryInfo) *CrossQueryCache { |
There was a problem hiding this comment.
感谢您的贡献😄 在只读跨链时的post tx阶段,只需要通过缓存验证,而无需再次发起网络请求,好像没有看到对应代码实现
There was a problem hiding this comment.
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.
我按照v3.10的代码改了下,加上fee就会走缓存,不加就不行。。 我再看看
There was a problem hiding this comment.
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.
预执行调用的 NewCrossQueryCache() <= NewXModelCache()<= PreExec()
There was a problem hiding this comment.
现在的XuperCore的master分支上有 PreExec() => NewStateSandbox() => NewXModelCache() => NewCrossQueryCache()。是对应上边的么,我看内容一样。但是没找到调用 NewCrossQueryCacheWithData()这个方法。
😅
There was a problem hiding this comment.
是的。 因为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.
在bcs/ledger/xledger/state/xmodel/message.go 已经实现了
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版本实现的方式一致