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
f9a13ef0
Unverified
Commit
f9a13ef0
authored
7 years ago
by
Silas Davis
Browse files
Options
Downloads
Patches
Plain Diff
Updated ABCI app for latest Tendermint
Signed-off-by:
Silas Davis
<
silas@monax.io
>
parent
e2a168ea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
consensus/tendermint/abci/app.go
+60
-28
60 additions, 28 deletions
consensus/tendermint/abci/app.go
consensus/tendermint/codes/codes.go
+18
-0
18 additions, 0 deletions
consensus/tendermint/codes/codes.go
with
78 additions
and
28 deletions
consensus/tendermint/abci/app.go
+
60
−
28
View file @
f9a13ef0
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"time"
"time"
bcm
"github.com/hyperledger/burrow/blockchain"
bcm
"github.com/hyperledger/burrow/blockchain"
"github.com/hyperledger/burrow/consensus/tendermint/codes"
"github.com/hyperledger/burrow/execution"
"github.com/hyperledger/burrow/execution"
"github.com/hyperledger/burrow/logging"
"github.com/hyperledger/burrow/logging"
"github.com/hyperledger/burrow/logging/structure"
"github.com/hyperledger/burrow/logging/structure"
...
@@ -50,29 +51,34 @@ func (app *abciApp) Info(info abci_types.RequestInfo) abci_types.ResponseInfo {
...
@@ -50,29 +51,34 @@ func (app *abciApp) Info(info abci_types.RequestInfo) abci_types.ResponseInfo {
return
abci_types
.
ResponseInfo
{
return
abci_types
.
ResponseInfo
{
Data
:
responseInfoName
,
Data
:
responseInfoName
,
Version
:
version
.
GetSemanticVersionString
(),
Version
:
version
.
GetSemanticVersionString
(),
LastBlockHeight
:
tip
.
LastBlockHeight
(),
LastBlockHeight
:
int64
(
tip
.
LastBlockHeight
()
)
,
LastBlockAppHash
:
tip
.
AppHashAfterLastBlock
(),
LastBlockAppHash
:
tip
.
AppHashAfterLastBlock
(),
}
}
}
}
func
(
app
*
abciApp
)
SetOption
(
key
string
,
value
string
)
string
{
func
(
app
*
abciApp
)
SetOption
(
option
abci_types
.
RequestSetOption
)
(
respSetOption
abci_types
.
ResponseSetOption
)
{
return
"No options available"
respSetOption
.
Log
=
"SetOption not supported"
respSetOption
.
Code
=
codes
.
UnsupportedRequestCode
return
}
}
func
(
app
*
abciApp
)
Query
(
reqQuery
abci_types
.
RequestQuery
)
(
respQuery
abci_types
.
ResponseQuery
)
{
func
(
app
*
abciApp
)
Query
(
reqQuery
abci_types
.
RequestQuery
)
(
respQuery
abci_types
.
ResponseQuery
)
{
respQuery
.
Log
=
"Query not support"
respQuery
.
Log
=
"Query not support
ed
"
respQuery
.
Code
=
abci_types
.
CodeType_Unknown
Request
respQuery
.
Code
=
codes
.
Unsupported
Request
Code
return
respQuery
return
}
}
func
(
app
*
abciApp
)
CheckTx
(
txBytes
[]
byte
)
abci_types
.
Res
ult
{
func
(
app
*
abciApp
)
CheckTx
(
txBytes
[]
byte
)
abci_types
.
Res
ponseCheckTx
{
app
.
mtx
.
Lock
()
app
.
mtx
.
Lock
()
defer
app
.
mtx
.
Unlock
()
defer
app
.
mtx
.
Unlock
()
tx
,
err
:=
app
.
txDecoder
.
DecodeTx
(
txBytes
)
tx
,
err
:=
app
.
txDecoder
.
DecodeTx
(
txBytes
)
if
err
!=
nil
{
if
err
!=
nil
{
logging
.
TraceMsg
(
app
.
logger
,
"CheckTx decoding error"
,
logging
.
TraceMsg
(
app
.
logger
,
"CheckTx decoding error"
,
structure
.
ErrorKey
,
err
)
structure
.
ErrorKey
,
err
)
return
abci_types
.
NewError
(
abci_types
.
CodeType_EncodingError
,
fmt
.
Sprintf
(
"Encoding error: %v"
,
err
))
return
abci_types
.
ResponseCheckTx
{
Code
:
codes
.
EncodingErrorCode
,
Log
:
fmt
.
Sprintf
(
"Encoding error: %s"
,
err
),
}
}
}
// TODO: map ExecTx errors to sensible ABCI error codes
// TODO: map ExecTx errors to sensible ABCI error codes
receipt
:=
txs
.
GenerateReceipt
(
app
.
blockchain
.
ChainID
(),
tx
)
receipt
:=
txs
.
GenerateReceipt
(
app
.
blockchain
.
ChainID
(),
tx
)
...
@@ -83,33 +89,44 @@ func (app *abciApp) CheckTx(txBytes []byte) abci_types.Result {
...
@@ -83,33 +89,44 @@ func (app *abciApp) CheckTx(txBytes []byte) abci_types.Result {
structure
.
ErrorKey
,
err
,
structure
.
ErrorKey
,
err
,
"tx_hash"
,
receipt
.
TxHash
,
"tx_hash"
,
receipt
.
TxHash
,
"creates_contract"
,
receipt
.
CreatesContract
)
"creates_contract"
,
receipt
.
CreatesContract
)
return
abci_types
.
NewError
(
abci_types
.
CodeType_InternalError
,
return
abci_types
.
ResponseCheckTx
{
fmt
.
Sprintf
(
"Could not execute transaction: %s, error: %v"
,
tx
,
err
))
Code
:
codes
.
EncodingErrorCode
,
Log
:
fmt
.
Sprintf
(
"Could not execute transaction: %s, error: %v"
,
tx
,
err
),
}
}
}
receiptBytes
:=
wire
.
BinaryBytes
(
receipt
)
receiptBytes
:=
wire
.
BinaryBytes
(
receipt
)
logging
.
TraceMsg
(
app
.
logger
,
"CheckTx success"
,
logging
.
TraceMsg
(
app
.
logger
,
"CheckTx success"
,
"tx_hash"
,
receipt
.
TxHash
,
"tx_hash"
,
receipt
.
TxHash
,
"creates_contract"
,
receipt
.
CreatesContract
)
"creates_contract"
,
receipt
.
CreatesContract
)
return
abci_types
.
NewResultOK
(
receiptBytes
,
"Success"
)
return
abci_types
.
ResponseCheckTx
{
Code
:
codes
.
TxExecutionSuccessCode
,
Log
:
"CheckTx success - receipt in data"
,
Data
:
receiptBytes
,
}
}
}
func
(
app
*
abciApp
)
InitChain
(
chain
abci_types
.
RequestInitChain
)
{
func
(
app
*
abciApp
)
InitChain
(
chain
abci_types
.
RequestInitChain
)
(
respInitChain
abci_types
.
ResponseInitChain
)
{
// Could verify agreement on initial validator set here
// Could verify agreement on initial validator set here
return
}
}
func
(
app
*
abciApp
)
BeginBlock
(
block
abci_types
.
RequestBeginBlock
)
{
func
(
app
*
abciApp
)
BeginBlock
(
block
abci_types
.
RequestBeginBlock
)
(
respBeginBlock
abci_types
.
ResponseBeginBlock
)
{
app
.
block
=
&
block
app
.
block
=
&
block
return
}
}
func
(
app
*
abciApp
)
DeliverTx
(
txBytes
[]
byte
)
abci_types
.
Res
ult
{
func
(
app
*
abciApp
)
DeliverTx
(
txBytes
[]
byte
)
abci_types
.
Res
ponseDeliverTx
{
app
.
mtx
.
Lock
()
app
.
mtx
.
Lock
()
defer
app
.
mtx
.
Unlock
()
defer
app
.
mtx
.
Unlock
()
tx
,
err
:=
app
.
txDecoder
.
DecodeTx
(
txBytes
)
tx
,
err
:=
app
.
txDecoder
.
DecodeTx
(
txBytes
)
if
err
!=
nil
{
if
err
!=
nil
{
logging
.
TraceMsg
(
app
.
logger
,
"DeliverTx decoding error"
,
logging
.
TraceMsg
(
app
.
logger
,
"DeliverTx decoding error"
,
structure
.
ErrorKey
,
err
)
structure
.
ErrorKey
,
err
)
return
abci_types
.
NewError
(
abci_types
.
CodeType_EncodingError
,
fmt
.
Sprintf
(
"Encoding error: %s"
,
err
))
return
abci_types
.
ResponseDeliverTx
{
Code
:
codes
.
EncodingErrorCode
,
Log
:
fmt
.
Sprintf
(
"Encoding error: %s"
,
err
),
}
}
}
receipt
:=
txs
.
GenerateReceipt
(
app
.
blockchain
.
ChainID
(),
tx
)
receipt
:=
txs
.
GenerateReceipt
(
app
.
blockchain
.
ChainID
(),
tx
)
...
@@ -119,22 +136,29 @@ func (app *abciApp) DeliverTx(txBytes []byte) abci_types.Result {
...
@@ -119,22 +136,29 @@ func (app *abciApp) DeliverTx(txBytes []byte) abci_types.Result {
structure
.
ErrorKey
,
err
,
structure
.
ErrorKey
,
err
,
"tx_hash"
,
receipt
.
TxHash
,
"tx_hash"
,
receipt
.
TxHash
,
"creates_contract"
,
receipt
.
CreatesContract
)
"creates_contract"
,
receipt
.
CreatesContract
)
return
abci_types
.
NewError
(
abci_types
.
CodeType_InternalError
,
return
abci_types
.
ResponseDeliverTx
{
fmt
.
Sprintf
(
"Could not execute transaction: %s, error: %s"
,
tx
,
err
))
Code
:
codes
.
TxExecutionErrorCode
,
Log
:
fmt
.
Sprintf
(
"Could not execute transaction: %s, error: %s"
,
tx
,
err
),
}
}
}
logging
.
TraceMsg
(
app
.
logger
,
"DeliverTx success"
,
logging
.
TraceMsg
(
app
.
logger
,
"DeliverTx success"
,
"tx_hash"
,
receipt
.
TxHash
,
"tx_hash"
,
receipt
.
TxHash
,
"creates_contract"
,
receipt
.
CreatesContract
)
"creates_contract"
,
receipt
.
CreatesContract
)
receiptBytes
:=
wire
.
BinaryBytes
(
receipt
)
receiptBytes
:=
wire
.
BinaryBytes
(
receipt
)
return
abci_types
.
NewResultOK
(
receiptBytes
,
"Success"
)
return
abci_types
.
ResponseDeliverTx
{
Code
:
codes
.
TxExecutionSuccessCode
,
Log
:
"DeliverTx success - receipt in data"
,
Data
:
receiptBytes
,
}
}
}
func
(
app
*
abciApp
)
EndBlock
(
height
uint64
)
(
respEndBlock
abci_types
.
ResponseEndBlock
)
{
func
(
app
*
abciApp
)
EndBlock
(
reqEndBlock
abci_types
.
RequestEndBlock
)
(
respEndBlock
abci_types
.
ResponseEndBlock
)
{
return
respEndBlock
// Validator mutation goes here
return
}
}
func
(
app
*
abciApp
)
Commit
()
abci_types
.
Res
ul
t
{
func
(
app
*
abciApp
)
Commit
()
abci_types
.
Res
ponseCommi
t
{
app
.
mtx
.
Lock
()
app
.
mtx
.
Lock
()
defer
app
.
mtx
.
Unlock
()
defer
app
.
mtx
.
Unlock
()
tip
:=
app
.
blockchain
.
Tip
()
tip
:=
app
.
blockchain
.
Tip
()
...
@@ -149,8 +173,10 @@ func (app *abciApp) Commit() abci_types.Result {
...
@@ -149,8 +173,10 @@ func (app *abciApp) Commit() abci_types.Result {
appHash
,
err
:=
app
.
committer
.
Commit
()
appHash
,
err
:=
app
.
committer
.
Commit
()
if
err
!=
nil
{
if
err
!=
nil
{
return
abci_types
.
NewError
(
abci_types
.
CodeType_InternalError
,
return
abci_types
.
ResponseCommit
{
fmt
.
Sprintf
(
"Could not commit block: %s"
,
err
))
Code
:
codes
.
CommitErrorCode
,
Log
:
fmt
.
Sprintf
(
"Could not commit block: %s"
,
err
),
}
}
}
logging
.
InfoMsg
(
app
.
logger
,
"Resetting transaction check cache"
)
logging
.
InfoMsg
(
app
.
logger
,
"Resetting transaction check cache"
)
...
@@ -160,15 +186,21 @@ func (app *abciApp) Commit() abci_types.Result {
...
@@ -160,15 +186,21 @@ func (app *abciApp) Commit() abci_types.Result {
app
.
blockchain
.
CommitBlock
(
time
.
Unix
(
int64
(
app
.
block
.
Header
.
Time
),
0
),
app
.
block
.
Hash
,
appHash
)
app
.
blockchain
.
CommitBlock
(
time
.
Unix
(
int64
(
app
.
block
.
Header
.
Time
),
0
),
app
.
block
.
Hash
,
appHash
)
// Perform a sanity check our block height
// Perform a sanity check our block height
if
app
.
blockchain
.
LastBlockHeight
()
!=
app
.
block
.
Header
.
Height
{
if
app
.
blockchain
.
LastBlockHeight
()
!=
uint64
(
app
.
block
.
Header
.
Height
)
{
logging
.
InfoMsg
(
app
.
logger
,
"Burrow block height disagrees with Tendermint block height"
,
logging
.
InfoMsg
(
app
.
logger
,
"Burrow block height disagrees with Tendermint block height"
,
structure
.
ScopeKey
,
"Commit()"
,
structure
.
ScopeKey
,
"Commit()"
,
"burrow_height"
,
app
.
blockchain
.
LastBlockHeight
(),
"burrow_height"
,
app
.
blockchain
.
LastBlockHeight
(),
"tendermint_height"
,
app
.
block
.
Header
.
Height
)
"tendermint_height"
,
app
.
block
.
Header
.
Height
)
return
abci_types
.
NewError
(
abci_types
.
CodeType_InternalError
,
return
abci_types
.
ResponseCommit
{
fmt
.
Sprintf
(
"Burrow has recorded a block height of %v, "
+
Code
:
codes
.
CommitErrorCode
,
Log
:
fmt
.
Sprintf
(
"Burrow has recorded a block height of %v, "
+
"but Tendermint reports a block height of %v, and the two should agree."
,
"but Tendermint reports a block height of %v, and the two should agree."
,
app
.
blockchain
.
LastBlockHeight
(),
app
.
block
.
Header
.
Height
))
app
.
blockchain
.
LastBlockHeight
(),
app
.
block
.
Header
.
Height
),
}
}
return
abci_types
.
ResponseCommit
{
Code
:
codes
.
TxExecutionSuccessCode
,
Data
:
appHash
,
Log
:
"Success - AppHash in data"
,
}
}
return
abci_types
.
NewResultOK
(
appHash
,
"Success"
)
}
}
This diff is collapsed.
Click to expand it.
consensus/tendermint/codes/codes.go
0 → 100644
+
18
−
0
View file @
f9a13ef0
package
codes
import
(
abci_types
"github.com/tendermint/abci/types"
)
const
(
// Success
TxExecutionSuccessCode
uint32
=
abci_types
.
CodeTypeOK
// Informational
UnsupportedRequestCode
uint32
=
400
// Internal errors
EncodingErrorCode
uint32
=
500
TxExecutionErrorCode
uint32
=
501
CommitErrorCode
uint32
=
502
)
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