Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
face4ace
Unverified
Commit
face4ace
authored
6 years ago
by
Silas Davis
Browse files
Options
Downloads
Patches
Plain Diff
Check ChainID in Verify!
Signed-off-by:
Silas Davis
<
silas@monax.io
>
parent
07746593
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
execution/execution.go
+1
-1
1 addition, 1 deletion
execution/execution.go
txs/envelope.go
+5
-1
5 additions, 1 deletion
txs/envelope.go
txs/tx_test.go
+1
-1
1 addition, 1 deletion
txs/tx_test.go
with
7 additions
and
3 deletions
execution/execution.go
+
1
−
1
View file @
face4ace
...
...
@@ -184,7 +184,7 @@ func (exe *executor) Execute(txEnv *txs.Envelope) (txe *exec.TxExecution, err er
logger
.
TraceMsg
(
"Executing transaction"
,
"tx"
,
txEnv
.
String
())
// Verify transaction signature against inputs
err
=
txEnv
.
Verify
(
exe
.
stateCache
)
err
=
txEnv
.
Verify
(
exe
.
stateCache
,
exe
.
blockchain
.
ChainID
()
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
txs/envelope.go
+
5
−
1
View file @
face4ace
...
...
@@ -77,12 +77,16 @@ func (txEnv *Envelope) Validate() error {
// Verifies the validity of the Signatories' Signatures in the Envelope. The Signatories must
// appear in the same order as the inputs as returned by Tx.GetInputs().
func
(
txEnv
*
Envelope
)
Verify
(
getter
state
.
AccountGetter
)
error
{
func
(
txEnv
*
Envelope
)
Verify
(
getter
state
.
AccountGetter
,
chainID
string
)
error
{
err
:=
txEnv
.
Validate
()
if
err
!=
nil
{
return
err
}
errPrefix
:=
fmt
.
Sprintf
(
"could not verify transaction %X"
,
txEnv
.
Tx
.
Hash
())
if
txEnv
.
Tx
.
ChainID
!=
chainID
{
return
fmt
.
Errorf
(
"%s: ChainID in envelope is %s but receiving chain has ID %s"
,
errPrefix
,
txEnv
.
Tx
.
ChainID
,
chainID
)
}
inputs
:=
txEnv
.
Tx
.
GetInputs
()
if
len
(
inputs
)
!=
len
(
txEnv
.
Signatories
)
{
return
fmt
.
Errorf
(
"%s: number of inputs (= %v) should equal number of signatories (= %v)"
,
...
...
This diff is collapsed.
Click to expand it.
txs/tx_test.go
+
1
−
1
View file @
face4ace
...
...
@@ -216,5 +216,5 @@ func testTxSignVerify(t *testing.T, tx payload.Payload) {
}
txEnv
:=
Enclose
(
chainID
,
tx
)
require
.
NoError
(
t
,
txEnv
.
Sign
(
signers
...
),
"Error signing tx: %s"
,
debug
.
Stack
())
require
.
NoError
(
t
,
txEnv
.
Verify
(
nil
),
"Error verifying tx: %s"
,
debug
.
Stack
())
require
.
NoError
(
t
,
txEnv
.
Verify
(
nil
,
chainID
),
"Error verifying tx: %s"
,
debug
.
Stack
())
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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