Add pending tx and auto relay mechanism in RPC and CLI#1047
Add pending tx and auto relay mechanism in RPC and CLI#1047superboyiii wants to merge 18 commits into
Conversation
Signed-off-by: superboyiii <573504781@qq.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master-n3 #1047 +/- ##
=============================================
+ Coverage 48.49% 48.94% +0.44%
=============================================
Files 274 278 +4
Lines 15850 16089 +239
Branches 2023 2057 +34
=============================================
+ Hits 7687 7875 +188
- Misses 7627 7665 +38
- Partials 536 549 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
More unit tests? |
vncoelho
left a comment
There was a problem hiding this comment.
I think this should be an extra plugin as an optional node service.
|
Maybe it's easier allow the user to config a higer value than We already have |
According to what I discussed with @roman-khimov previously, for safety reasons, we even tend to narrow the |
It's not complex, the trigger is |
Signed-off-by: superboyiii <573504781@qq.com>
Done |
I do not think this is the correct way to go, adding an "extra mempool". |
It's a very little local IStore which will not be synced to peers. It's only for temporary use and it will be removed when the height is passed. In terms of resource consumption, it is imperceptible and almost negligible. |
Since it is not synced, it is indeed a local mempool. However, in my opinion, it should be a plugin. |
It's not active on default. Not a problem. A new plugin means new command and new RPC, it's not necessary. |
It's a bypass of |
This new one is an isolated IStore. It's not in cache, so it's not mempool in fact. Such kind of pending tx will not go into original mempool before because it's verified as |
|
I tend to agree with @vncoelho on this, an additional plugin makes sense. Overriding MVUBI locally to put into the main mempool is not a solution, there are subscriptions to mempool, there are interfaces to obtain pooled transactions, there are rebroadcasts tied to mempool, CNs get their transactions from the same main mempool as well. We can't have invalid (as per protocol) transactions there, something will break for sure this way. So given that it's a separate store the only question is where to put it. Currently it's tied to CLI, but it'd not dependent on CLI (transactions can be pushed via RPC and CLI code shouldn't care much about where transactions are stored), so a separate plugin would be structurally more sound. |
|
I will wait for conclusion on neo-project/neo#4545, so I can decide how to make changes. Since @vncoelho and @roman-khimov prefer a Plugin way, it's OK for me. |
|
Since neo-project/neo#4545 has been merged, this PR needs to be updated before the design can be re-reviewed. The far-future |
|
Conflicts |
I will make it as a plugin. Need a little time to modify. |
Signed-off-by: superboyiii <573504781@qq.com>
| { | ||
| "PluginConfiguration": { | ||
| "Path": "DeferredRelay_{0}", | ||
| "Network": 860833102, |
There was a problem hiding this comment.
It can relay to a different network, so this value should be taken from the ProtocolSettings
There was a problem hiding this comment.
It can relay to a different network, so this value should be taken from the
ProtocolSettings
No. It's no way to relay to another chain. If DeferredRelay.json Network ≠ the node’s ProtocolSettings.Network, OnSystemLoaded returns immediately: no store, no actor, no queue, no retry. The plugin does nothing on that node. Cross-chain relay is not possible here; The worst case is a silent misconfiguration (you think DeferredRelay is on, but it isn’t).
| - name: Run tests with expect | ||
| run: expect ./.github/workflows/test-neo-cli-plugins.expect | ||
| run: | | ||
| # Count loadable plugins only (exclude MPTTrie dependency and RpcClient library). |
There was a problem hiding this comment.
Why the exclude?
RpcClient is not Plugin, it's SDK. I don't release it in zip package. It will be only update to Nuget.
MPTTire is packed inside StateService.zip, so it's not necessary to be packed alone again.
Signed-off-by: superboyiii <573504781@qq.com>
Motivation: Transactions can fail relay with NotYetValid when ValidUntilBlock is too far ahead of the current chain head. This PR adds the DeferredRelay plugin so nodes can queue those transactions locally (when enabled) and retry relay later, instead of dropping them immediately.DeferredRelay.json: Under PluginConfiguration, set MaxTransactions and CheckFrequency both > 0 to enable the feature; CheckFrequency sets how often (in persisted blocks) the node rescans the local pending store. Requires the RpcServer plugin.CLI: New commandlist pending— prints the JSON snapshot of locally queued NotYetValid transactions and related height / plugin settings (same data shape the RPC exposes).RPC: New methodgetpendingvaliduntilrelay(no params) — returns that snapshot as JSON; when disabled or the store is not active, enabled is false. sendrawtransaction still returns -510 with data: "NotYetValid"; when DeferredRelay is enabled, qualifying txs are queued automatically via relay events.