Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
timothe
duniter
Commits
9895862c
Commit
9895862c
authored
Dec 15, 2019
by
Éloïs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] transactions check: auto use new verify fn when dubp jump to v12
parent
9f7afef8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
18 deletions
+28
-18
app/lib/dto/TransactionDTO.ts
app/lib/dto/TransactionDTO.ts
+10
-5
app/lib/indexer.ts
app/lib/indexer.ts
+1
-1
app/lib/rules/global_rules.ts
app/lib/rules/global_rules.ts
+12
-7
app/lib/rules/local_rules.ts
app/lib/rules/local_rules.ts
+1
-1
app/modules/prover/lib/blockGenerator.ts
app/modules/prover/lib/blockGenerator.ts
+2
-2
app/service/TransactionsService.ts
app/service/TransactionsService.ts
+2
-2
No files found.
app/lib/dto/TransactionDTO.ts
View file @
9895862c
...
...
@@ -13,7 +13,7 @@
import
{
hashf
}
from
"
../common
"
import
{
Cloneable
}
from
"
./Cloneable
"
import
{
verifyBuggy
}
from
"
../common-libs/crypto/keyring
"
import
{
verify
,
verifyBuggy
}
from
"
../common-libs/crypto/keyring
"
export
interface
BaseDTO
{
base
:
number
...
...
@@ -237,7 +237,7 @@ export class TransactionDTO implements Cloneable {
}
}
getTransactionSigResult
()
{
getTransactionSigResult
(
dubp_version
:
number
)
{
const
sigResult
=
new
TxSignatureResultImpl
(
this
.
issuers
.
slice
())
let
i
=
0
const
raw
=
this
.
getRawTxNoSig
()
...
...
@@ -245,14 +245,19 @@ export class TransactionDTO implements Cloneable {
while
(
matching
&&
i
<
this
.
signatures
.
length
)
{
const
sig
=
this
.
signatures
[
i
]
const
pub
=
this
.
issuers
[
i
]
sigResult
.
sigs
[
i
].
ok
=
matching
=
verifyBuggy
(
raw
,
sig
,
pub
)
if
(
dubp_version
>=
12
)
{
sigResult
.
sigs
[
i
].
ok
=
verify
(
raw
,
sig
,
pub
)
}
else
{
sigResult
.
sigs
[
i
].
ok
=
verifyBuggy
(
raw
,
sig
,
pub
)
}
matching
=
sigResult
.
sigs
[
i
].
ok
i
++
}
return
sigResult
}
checkSignatures
()
{
return
this
.
getTransactionSigResult
().
allMatching
checkSignatures
(
dubp_version
:
number
)
{
return
this
.
getTransactionSigResult
(
dubp_version
).
allMatching
}
static
fromJSONObject
(
obj
:
any
,
currency
:
string
=
""
)
{
...
...
app/lib/indexer.ts
View file @
9895862c
...
...
@@ -2160,7 +2160,7 @@ function txSourceUnlock(ENTRY:SindexEntry, source:{ conditions: string, written_
const
tx
=
ENTRY
.
txObj
;
const
unlockParams
:
string
[]
=
TransactionDTO
.
unlock2params
(
ENTRY
.
unlock
||
''
)
const
unlocksMetadata
:
UnlockMetadata
=
{}
const
sigResult
=
TransactionDTO
.
fromJSONObject
(
tx
).
getTransactionSigResult
()
const
sigResult
=
TransactionDTO
.
fromJSONObject
(
tx
).
getTransactionSigResult
(
HEAD
.
version
)
if
(
!
source
.
conditions
)
{
return
false
// Unlock fail
}
...
...
app/lib/rules/global_rules.ts
View file @
9895862c
...
...
@@ -94,7 +94,7 @@ export const GLOBAL_RULES_FUNCTIONS = {
return
true
;
},
checkSourcesAvailability
:
async
(
block
:{
transactions
:
TransactionDTO
[],
medianTime
:
number
},
conf
:
ConfDTO
,
dal
:
FileDAL
,
findSourceTx
:(
txHash
:
string
)
=>
Promise
<
DBTx
|
null
>
)
=>
{
checkSourcesAvailability
:
async
(
block
:{
version
:
number
,
transactions
:
TransactionDTO
[],
medianTime
:
number
},
conf
:
ConfDTO
,
dal
:
FileDAL
,
findSourceTx
:(
txHash
:
string
)
=>
Promise
<
DBTx
|
null
>
)
=>
{
const
txs
=
block
.
transactions
const
current
=
await
dal
.
getCurrentBlockOrNull
();
for
(
const
tx
of
txs
)
{
...
...
@@ -150,7 +150,7 @@ export const GLOBAL_RULES_FUNCTIONS = {
unlocksMetadata
.
elapsedTime
=
block
.
medianTime
-
dbSrc
.
written_time
;
}
const
sigs
=
tx
.
getTransactionSigResult
()
const
sigs
=
tx
.
getTransactionSigResult
(
block
.
version
)
try
{
if
(
!
txunlock
(
dbSrc
.
conditions
,
unlocksForCondition
,
sigs
,
unlocksMetadata
))
{
...
...
@@ -213,13 +213,18 @@ export const GLOBAL_RULES_HELPERS = {
checkSingleTransaction
:
(
tx
:
TransactionDTO
,
block
:{
medianTime
:
number
},
dubp_version
:
number
,
medianTime
:
number
,
conf
:
ConfDTO
,
dal
:
FileDAL
,
findSourceTx
:(
txHash
:
string
)
=>
Promise
<
DBTx
|
null
>
)
=>
GLOBAL_RULES_FUNCTIONS
.
checkSourcesAvailability
({
transactions
:
[
tx
],
medianTime
:
block
.
medianTime
},
conf
,
dal
,
findSourceTx
),
findSourceTx
:(
txHash
:
string
)
=>
Promise
<
DBTx
|
null
>
)
=>
GLOBAL_RULES_FUNCTIONS
.
checkSourcesAvailability
(
{
version
:
dubp_version
,
transactions
:
[
tx
],
medianTime
:
medianTime
},
conf
,
dal
,
findSourceTx
),
checkTxBlockStamp
:
async
(
tx
:
TransactionDTO
,
dal
:
FileDAL
)
=>
{
const
number
=
parseInt
(
tx
.
blockstamp
.
split
(
'
-
'
)[
0
])
...
...
app/lib/rules/local_rules.ts
View file @
9895862c
...
...
@@ -390,7 +390,7 @@ export const LOCAL_RULES_FUNCTIONS = {
const
txs
=
block
.
transactions
// Check rule against each transaction
for
(
const
tx
of
txs
)
{
if
(
!
tx
.
checkSignatures
())
{
if
(
!
tx
.
checkSignatures
(
block
.
version
))
{
throw
Error
(
'
Signature from a transaction must match
'
)
}
}
...
...
app/modules/prover/lib/blockGenerator.ts
View file @
9895862c
...
...
@@ -144,8 +144,8 @@ export class BlockGenerator {
const
tx
=
TransactionDTO
.
fromJSONObject
(
obj
);
try
{
await
LOCAL_RULES_HELPERS
.
checkBunchOfTransactions
(
passingTxs
.
concat
(
tx
),
this
.
conf
,
medianTime
,
options
)
const
nextBlockWithF
akeTimeVariation
=
{
medianTime
:
current
.
medianTime
+
1
}
;
await
GLOBAL_RULES_HELPERS
.
checkSingleTransaction
(
tx
,
nextBlockWithF
akeTimeVariation
,
this
.
conf
,
this
.
dal
,
async
(
txHash
:
string
)
=>
{
const
f
akeTimeVariation
=
current
.
medianTime
+
1
;
await
GLOBAL_RULES_HELPERS
.
checkSingleTransaction
(
tx
,
current
.
version
,
f
akeTimeVariation
,
this
.
conf
,
this
.
dal
,
async
(
txHash
:
string
)
=>
{
return
Underscore
.
findWhere
(
passingTxs
,
{
hash
:
txHash
})
||
null
});
await
GLOBAL_RULES_HELPERS
.
checkTxBlockStamp
(
tx
,
this
.
dal
);
...
...
app/service/TransactionsService.ts
View file @
9895862c
...
...
@@ -54,11 +54,11 @@ export class TransactionService extends FIFOService {
throw
constants
.
ERRORS
.
TX_ALREADY_PROCESSED
;
}
// Start checks...
const
nextBlockWithF
akeTimeVariation
=
{
medianTime
:
current
.
medianTime
+
1
}
;
const
f
akeTimeVariation
=
current
.
medianTime
+
1
;
const
dto
=
TransactionDTO
.
fromJSONObject
(
tx
)
await
LOCAL_RULES_HELPERS
.
checkSingleTransactionLocally
(
dto
,
this
.
conf
)
await
GLOBAL_RULES_HELPERS
.
checkTxBlockStamp
(
tx
,
this
.
dal
);
await
GLOBAL_RULES_HELPERS
.
checkSingleTransaction
(
dto
,
nextBlockWithF
akeTimeVariation
,
this
.
conf
,
this
.
dal
,
this
.
dal
.
getTxByHash
.
bind
(
this
.
dal
));
await
GLOBAL_RULES_HELPERS
.
checkSingleTransaction
(
dto
,
current
.
version
,
f
akeTimeVariation
,
this
.
conf
,
this
.
dal
,
this
.
dal
.
getTxByHash
.
bind
(
this
.
dal
));
const
server_pubkey
=
this
.
conf
.
pair
&&
this
.
conf
.
pair
.
pub
;
if
(
!
(
await
this
.
dal
.
txsDAL
.
sandbox
.
acceptNewSandBoxEntry
({
issuers
:
tx
.
issuers
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment