-
Notifications
You must be signed in to change notification settings - Fork 257
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
Feature support delayed tx #1075
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1075 +/- ##
==========================================
+ Coverage 62.85% 63.01% +0.16%
==========================================
Files 157 164 +7
Lines 22640 22890 +250
==========================================
+ Hits 14230 14424 +194
- Misses 6561 6605 +44
- Partials 1849 1861 +12
Continue to review full report at Codecov.
|
664d919
to
35b6d59
Compare
其他模块代码单元测试失败,需要优先解决 |
1f48d22
to
8df4498
Compare
13d6205
to
dbf72d9
Compare
@@ -1057,3 +1060,39 @@ func (q *QueueProtocol) GetCryptoList() *types.CryptoList { | |||
} | |||
return list | |||
} | |||
|
|||
// SendDelayTx send delay transaction to mempool | |||
func (q *QueueProtocol) SendDelayTx(param *types.DelayTx, waitReply bool) (*types.Reply, 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.
delay 的交易理论上来说可以直接识别出来,我感觉不需要重新添加接口,直接用原来的接口就可以了。delay的交易和普通交易一样发送就可以
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.
-
延时交易通常由延时存证交易tx发起的,就是tx.paylod=delaytx, 延时存证交易不需要调用这个接口,发送方法和普通交易是一致的,在执行后调用发送延时交易到mempool
-
本质上延时交易和普通交易是无差别的,这个接口是提供交易暂存延时打包功能,包括但不限于延时交易,也可以是单纯希望暂缓打包的交易
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.
修改成 mempool 主动过滤后,这个接口还需要吗?
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.
-
这个看普通交易,有没有延缓加入mempool的需求,上次讨论是说南京那边目前还独立做了这个sdk,希望交易等待若干区块后被发送,这里相当于mempool支持这个功能
-
延时存证交易本身已经不需要这个接口了
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.
先保留吧,这个接口。
system/dapp/none/executor/exec.go
Outdated
&types.ReceiptLog{Ty: nty.TyCommitDelayTxLog, Log: types.Encode(delayInfo)}) | ||
|
||
// send delay tx to mempool | ||
_, err := n.GetAPI().SendDelayTx(&types.DelayTx{Tx: commit.GetDelayTx(), EndDelayTime: delayInfo.EndDelayTime}, false) |
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.
在执行过程中发送交易,可能会因为 mempool 消息满而整个系统卡住,也会影响性能。建议这个放到blockchain 执行结束向mempool 通知的情况下,可靠性还不是最重要的。
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.
已修改
@@ -156,3 +161,97 @@ func (cache *txCache) getTxByHash(hash string) *types.Transaction { | |||
} | |||
return item.Value | |||
} | |||
|
|||
//delayTxCache 延时交易缓存 | |||
type delayTxCache struct { |
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.
是不是要考虑大量的delay交易的情况,delay 交易的列表可以考虑存在合约数据库中,用Table保存,以过期时间位索引。mempool 定期去查询,比如10分钟查一次delay的交易,放到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.
这个可以考虑放到后期处理,有业务后也会关联到一些查询需求,到时统一做设计
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.
可以
🎉 This PR is included in version 1.66.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.66.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
none合约增加延时存证交易类型
mempool增加延时交易缓存模块
rpc增加发送延时交易接口
fix #1076
fix #1077