Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
c94e0f28
Commit
c94e0f28
authored
5 years ago
by
Tomasz Drwięga
Committed by
Gavin Wood
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Reject transactions with no provides tags. (#3416)
parent
3825a21b
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/core/transaction-pool/graph/src/error.rs
+6
-0
6 additions, 0 deletions
substrate/core/transaction-pool/graph/src/error.rs
substrate/core/transaction-pool/graph/src/pool.rs
+24
-2
24 additions, 2 deletions
substrate/core/transaction-pool/graph/src/pool.rs
with
30 additions
and
2 deletions
substrate/core/transaction-pool/graph/src/error.rs
+
6
−
0
View file @
c94e0f28
...
...
@@ -30,6 +30,12 @@ pub enum Error {
/// Transaction is invalid.
#[display(fmt=
"Invalid Transaction. Error Code: {}"
,
_0)]
InvalidTransaction
(
i8
),
/// The transaction validity returned no "provides" tag.
///
/// Such transactions are not accepted to the pool, since we use those tags
/// to define identity of transactions (occupance of the same "slot").
#[display(fmt=
"The transaction does not provide any tags, so the pool can't identify it."
)]
NoTagsProvided
,
/// The transaction is temporarily banned.
#[display(fmt=
"Temporarily Banned"
)]
TemporarilyBanned
,
...
...
This diff is collapsed.
Click to expand it.
substrate/core/transaction-pool/graph/src/pool.rs
+
24
−
2
View file @
c94e0f28
...
...
@@ -129,7 +129,9 @@ impl<B: ChainApi> Pool<B> {
}
match
self
.api
.validate_transaction
(
at
,
xt
.clone
())
?
{
TransactionValidity
::
Valid
(
validity
)
=>
{
TransactionValidity
::
Valid
(
validity
)
=>
if
validity
.provides
.is_empty
()
{
Err
(
error
::
Error
::
NoTagsProvided
.into
())
}
else
{
Ok
(
base
::
Transaction
{
data
:
xt
,
bytes
...
...
@@ -458,6 +460,8 @@ mod tests {
use
assert_matches
::
assert_matches
;
use
crate
::
watcher
;
const
INVALID_NONCE
:
u64
=
254
;
#[derive(Debug,
Default)]
struct
TestApi
{
delay
:
Mutex
<
Option
<
std
::
sync
::
mpsc
::
Receiver
<
()
>>>
,
...
...
@@ -490,7 +494,7 @@ mod tests {
Ok
(
TransactionValidity
::
Valid
(
ValidTransaction
{
priority
:
4
,
requires
:
if
nonce
>
block_number
{
vec!
[
vec!
[
nonce
as
u8
-
1
]]
}
else
{
vec!
[]
},
provides
:
vec!
[
vec!
[
nonce
as
u8
]],
provides
:
if
nonce
==
INVALID_NONCE
{
vec!
[]
}
else
{
vec!
[
vec!
[
nonce
as
u8
]]
}
,
longevity
:
3
,
propagate
:
true
,
}))
...
...
@@ -723,6 +727,24 @@ mod tests {
assert_eq!
(
pool
.status
()
.future
,
0
);
}
#[test]
fn
should_reject_transactions_with_no_provides
()
{
// given
let
pool
=
pool
();
// when
let
err
=
pool
.submit_one
(
&
BlockId
::
Number
(
0
),
uxt
(
Transfer
{
from
:
AccountId
::
from_h256
(
H256
::
from_low_u64_be
(
1
)),
to
:
AccountId
::
from_h256
(
H256
::
from_low_u64_be
(
2
)),
amount
:
5
,
nonce
:
INVALID_NONCE
,
}))
.unwrap_err
();
// then
assert_eq!
(
pool
.status
()
.ready
,
0
);
assert_eq!
(
pool
.status
()
.future
,
0
);
assert_matches!
(
err
,
error
::
Error
::
NoTagsProvided
);
}
mod
listener
{
use
super
::
*
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment