Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abci: add preprocess block #110

Merged
merged 43 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4a9247c
version docs
tac0turtle Aug 13, 2020
a46562d
stash commits
tac0turtle Aug 13, 2020
99cf9c0
fix url
tac0turtle Aug 13, 2020
c51a1f5
remove master from sidebar
tac0turtle Aug 13, 2020
296d854
test go version
tac0turtle Aug 18, 2020
25de71a
remove go version
tac0turtle Aug 18, 2020
0a24577
Merge branch 'master' into marko/versioned_docs
tac0turtle Aug 20, 2020
0cdebf6
invert versions
tac0turtle Aug 20, 2020
c19e0d3
Merge branch 'master' into marko/versioned_docs
tac0turtle Aug 20, 2020
db3140f
Merge branch 'master' into marko/versioned_docs
mergify[bot] Aug 20, 2020
7756e2d
Merge branch 'master' into marko/versioned_docs
mergify[bot] Aug 20, 2020
828880d
Merge branch 'master' into marko/versioned_docs
mergify[bot] Aug 20, 2020
8f37751
Merge branch 'master' into marko/versioned_docs
mergify[bot] Aug 20, 2020
1afe9db
add todo
tac0turtle Aug 21, 2020
b118204
init
tac0turtle Aug 21, 2020
682a16d
changes to abci
tac0turtle Aug 21, 2020
35ca92b
fix build errors
tac0turtle Aug 21, 2020
6a8161d
move to consensus connection
tac0turtle Aug 21, 2020
6ea48d0
add process
tac0turtle Aug 21, 2020
0caedd2
add proof to block
tac0turtle Sep 10, 2020
cb770d6
undo changes
tac0turtle Sep 10, 2020
4677f69
add block metadata in beginBlcok
tac0turtle Sep 22, 2020
e8e7179
Merge branch 'master' into marko/preprocess
tac0turtle Sep 22, 2020
eec2c96
fix testing
tac0turtle Sep 22, 2020
7078389
regenerate mocks
tac0turtle Sep 22, 2020
60fa00d
add in needed proto changes
tac0turtle Oct 18, 2020
c527158
regenerate mocks
tac0turtle Oct 19, 2020
2efa9fb
Merge branch 'master' into marko/preprocess
tac0turtle Nov 12, 2020
ff4be69
fix makeblock calls
tac0turtle Nov 16, 2020
46f1be9
Merge branch 'master' into marko/preprocess
tac0turtle Dec 11, 2020
91bf953
Apply suggestions from code review
tac0turtle Dec 11, 2020
0305175
Merge branch 'marko/preprocess' of https://github.com/marbar3778/lazy…
tac0turtle Dec 11, 2020
a0deb45
fix rpc tests
tac0turtle Dec 11, 2020
2df2ba5
fix linting and ci errors
tac0turtle Dec 11, 2020
c4ac115
fix consensus tests
tac0turtle Dec 11, 2020
4bb6af4
add preprocess to e2e
tac0turtle Dec 11, 2020
4e3abfd
add preprocess to counter app
tac0turtle Dec 11, 2020
6842950
replace meta_data with messages
tac0turtle Dec 14, 2020
acd911a
fix linting
tac0turtle Dec 14, 2020
7d179d2
Update state/execution.go
tac0turtle Dec 14, 2020
add6537
fix comment
tac0turtle Dec 14, 2020
088b4ce
Merge branch 'marko/preprocess' of https://github.com/marbar3778/lazy…
tac0turtle Dec 15, 2020
dd9208a
fix e2e tests
tac0turtle Dec 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,56 +23,56 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Set GOBIN
run: |
echo "::add-path::$(go env GOPATH)/bin"
Comment on lines -33 to -35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this too! 🙏

- name: install
run: make install install_abci
if: "env.GIT_DIFF != ''"
- uses: actions/cache@v2.1.2
- uses: actions/cache@v2.1.3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
if: env.GIT_DIFF
# Cache binaries for use by other jobs
- uses: actions/cache@v2.1.2
- uses: actions/cache@v2.1.3
with:
path: ~/go/bin
key: ${{ runner.os }}-${{ github.sha }}-tm-binary
if: env.GIT_DIFF

test_abci_apps:
runs-on: ubuntu-latest
needs: Build
needs: build
timeout-minutes: 5
steps:
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Set GOBIN
run: |
echo "::add-path::$(go env GOPATH)/bin"
- uses: actions/cache@v2.1.2
- uses: actions/cache@v2.1.3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
if: env.GIT_DIFF
- uses: actions/cache@v2.1.2
- uses: actions/cache@v2.1.3
with:
path: ~/go/bin
key: ${{ runner.os }}-${{ github.sha }}-tm-binary
Expand All @@ -84,27 +84,27 @@ jobs:

test_abci_cli:
runs-on: ubuntu-latest
needs: Build
needs: build
timeout-minutes: 5
steps:
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Set GOBIN
run: |
echo "::add-path::$(go env GOPATH)/bin"
- uses: actions/cache@v2.1.2
- uses: actions/cache@v2.1.3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
if: env.GIT_DIFF
- uses: actions/cache@v2.1.2
- uses: actions/cache@v2.1.3
with:
path: ~/go/bin
key: ${{ runner.os }}-${{ github.sha }}-tm-binary
Expand All @@ -115,27 +115,27 @@ jobs:

test_apps:
runs-on: ubuntu-latest
needs: Build
needs: build
timeout-minutes: 5
steps:
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Set GOBIN
run: |
echo "::add-path::$(go env GOPATH)/bin"
- uses: actions/cache@v2.1.2
- uses: actions/cache@v2.1.3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
if: env.GIT_DIFF
- uses: actions/cache@v2.1.2
- uses: actions/cache@v2.1.3
with:
path: ~/go/bin
key: ${{ runner.os }}-${{ github.sha }}-tm-binary
Expand Down
3 changes: 3 additions & 0 deletions abci/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
// All `Sync` methods return the appropriate protobuf ResponseXxx struct and an error.
// Note these are client errors, eg. ABCI socket connectivity issues.
// Application-related errors are reflected in response via ABCI error codes and logs.
//go:generate mockery --case underscore --name Client
type Client interface {
service.Service

Expand All @@ -41,6 +42,7 @@ type Client interface {
OfferSnapshotAsync(types.RequestOfferSnapshot) *ReqRes
LoadSnapshotChunkAsync(types.RequestLoadSnapshotChunk) *ReqRes
ApplySnapshotChunkAsync(types.RequestApplySnapshotChunk) *ReqRes
PreprocessTxsAsync(types.RequestPreprocessTxs) *ReqRes

FlushSync() error
EchoSync(msg string) (*types.ResponseEcho, error)
Expand All @@ -56,6 +58,7 @@ type Client interface {
OfferSnapshotSync(types.RequestOfferSnapshot) (*types.ResponseOfferSnapshot, error)
LoadSnapshotChunkSync(types.RequestLoadSnapshotChunk) (*types.ResponseLoadSnapshotChunk, error)
ApplySnapshotChunkSync(types.RequestApplySnapshotChunk) (*types.ResponseApplySnapshotChunk, error)
PreprocessTxsSync(types.RequestPreprocessTxs) (*types.ResponsePreprocessTxs, error)
}

//----------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,15 @@ func (cli *grpcClient) ApplySnapshotChunkAsync(params types.RequestApplySnapshot
return cli.finishAsyncCall(req, &types.Response{Value: &types.Response_ApplySnapshotChunk{ApplySnapshotChunk: res}})
}

func (cli *grpcClient) PreprocessTxsAsync(params types.RequestPreprocessTxs) *ReqRes {
req := types.ToRequestPreprocessTxs(params)
res, err := cli.client.PreprocessTxs(context.Background(), req.GetPreprocessTxs(), grpc.WaitForReady(true))
if err != nil {
cli.StopForError(err)
}
return cli.finishAsyncCall(req, &types.Response{Value: &types.Response_PreprocessTxs{PreprocessTxs: res}})
}

func (cli *grpcClient) finishAsyncCall(req *types.Request, res *types.Response) *ReqRes {
reqres := NewReqRes(req)
reqres.Response = res // Set response
Expand Down Expand Up @@ -350,3 +359,9 @@ func (cli *grpcClient) ApplySnapshotChunkSync(
reqres := cli.ApplySnapshotChunkAsync(params)
return reqres.Response.GetApplySnapshotChunk(), cli.Error()
}

func (cli *grpcClient) PreprocessTxsSync(
params types.RequestPreprocessTxs) (*types.ResponsePreprocessTxs, error) {
reqres := cli.PreprocessTxsAsync(params)
return reqres.Response.GetPreprocessTxs(), cli.Error()
}
20 changes: 20 additions & 0 deletions abci/client/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ func (app *localClient) ApplySnapshotChunkAsync(req types.RequestApplySnapshotCh
)
}

func (app *localClient) PreprocessTxsAsync(req types.RequestPreprocessTxs) *ReqRes {
app.mtx.Lock()
defer app.mtx.Unlock()

res := app.Application.PreprocessTxs(req)
return app.callback(
types.ToRequestPreprocessTxs(req),
types.ToResponsePreprocessTx(res),
)
}

//-------------------------------------------------------

func (app *localClient) FlushSync() error {
Expand Down Expand Up @@ -298,6 +309,15 @@ func (app *localClient) ApplySnapshotChunkSync(
return &res, nil
}

func (app *localClient) PreprocessTxsSync(
req types.RequestPreprocessTxs) (*types.ResponsePreprocessTxs, error) {
app.mtx.Lock()
defer app.mtx.Unlock()

res := app.Application.PreprocessTxs(req)
return &res, nil
}

//-------------------------------------------------------

func (app *localClient) callback(req *types.Request, res *types.Response) *ReqRes {
Expand Down
39 changes: 39 additions & 0 deletions abci/client/mocks/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ func (cli *socketClient) ApplySnapshotChunkAsync(req types.RequestApplySnapshotC
return cli.queueRequest(types.ToRequestApplySnapshotChunk(req))
}

func (cli *socketClient) PreprocessTxsAsync(req types.RequestPreprocessTxs) *ReqRes {
return cli.queueRequest(types.ToRequestPreprocessTxs(req))
}

//----------------------------------------

func (cli *socketClient) FlushSync() error {
Expand Down Expand Up @@ -406,6 +410,15 @@ func (cli *socketClient) ApplySnapshotChunkSync(
return reqres.Response.GetApplySnapshotChunk(), cli.Error()
}

func (cli *socketClient) PreprocessTxsSync(
req types.RequestPreprocessTxs) (*types.ResponsePreprocessTxs, error) {
reqres := cli.queueRequest(types.ToRequestPreprocessTxs(req))
if err := cli.FlushSync(); err != nil {
return nil, err
}
return reqres.Response.GetPreprocessTxs(), cli.Error()
}

//----------------------------------------

func (cli *socketClient) queueRequest(req *types.Request) *ReqRes {
Expand Down Expand Up @@ -479,6 +492,8 @@ func resMatchesReq(req *types.Request, res *types.Response) (ok bool) {
_, ok = res.Value.(*types.Response_ListSnapshots)
case *types.Request_OfferSnapshot:
_, ok = res.Value.(*types.Response_OfferSnapshot)
case *types.Request_PreprocessTxs:
_, ok = res.Value.(*types.Response_PreprocessTxs)
}
return ok
}
Expand Down
5 changes: 5 additions & 0 deletions abci/example/counter/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ func (app *Application) Query(reqQuery types.RequestQuery) types.ResponseQuery {
return types.ResponseQuery{Log: fmt.Sprintf("Invalid query path. Expected hash or tx, got %v", reqQuery.Path)}
}
}

func (app *Application) PreprocessTxs(
req types.RequestPreprocessTxs) types.ResponsePreprocessTxs {
return types.ResponsePreprocessTxs{Txs: req.Txs}
}
5 changes: 5 additions & 0 deletions abci/example/kvstore/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,8 @@ func (app *Application) Query(reqQuery types.RequestQuery) (resQuery types.Respo

return resQuery
}

func (app *Application) PreprocessTxs(
req types.RequestPreprocessTxs) types.ResponsePreprocessTxs {
return types.ResponsePreprocessTxs{Txs: req.Txs}
}
5 changes: 5 additions & 0 deletions abci/example/kvstore/persistent_kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ func (app *PersistentKVStoreApplication) ApplySnapshotChunk(
return types.ResponseApplySnapshotChunk{Result: types.ResponseApplySnapshotChunk_ABORT}
}

func (app *PersistentKVStoreApplication) PreprocessTxs(
req types.RequestPreprocessTxs) types.ResponsePreprocessTxs {
return types.ResponsePreprocessTxs{Txs: req.Txs}
}

//---------------------------------------------
// update validators

Expand Down
3 changes: 3 additions & 0 deletions abci/server/socket_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ func (s *SocketServer) handleRequest(req *types.Request, responses chan<- *types
case *types.Request_ApplySnapshotChunk:
res := s.app.ApplySnapshotChunk(*r.ApplySnapshotChunk)
responses <- types.ToResponseApplySnapshotChunk(res)
case *types.Request_PreprocessTxs:
res := s.app.PreprocessTxs(*r.PreprocessTxs)
responses <- types.ToResponsePreprocessTx(res)
default:
responses <- types.ToResponseException("Unknown request")
}
Expand Down
22 changes: 17 additions & 5 deletions abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
// to be driven by a blockchain-based replication engine via the ABCI.
// All methods take a RequestXxx argument and return a ResponseXxx argument,
// except CheckTx/DeliverTx, which take `tx []byte`, and `Commit`, which takes nothing.
// nolint:lll // ignore for interface
type Application interface {
// Info/Query Connection
Info(RequestInfo) ResponseInfo // Return application info
Expand All @@ -17,11 +18,12 @@ type Application interface {
CheckTx(RequestCheckTx) ResponseCheckTx // Validate a tx for the mempool

// Consensus Connection
InitChain(RequestInitChain) ResponseInitChain // Initialize blockchain w validators/other info from TendermintCore
BeginBlock(RequestBeginBlock) ResponseBeginBlock // Signals the beginning of a block
DeliverTx(RequestDeliverTx) ResponseDeliverTx // Deliver a tx for full processing
EndBlock(RequestEndBlock) ResponseEndBlock // Signals the end of a block, returns changes to the validator set
Commit() ResponseCommit // Commit the state and return the application Merkle root hash
InitChain(RequestInitChain) ResponseInitChain // Initialize blockchain w validators/other info from TendermintCore
BeginBlock(RequestBeginBlock) ResponseBeginBlock // Signals the beginning of a block
DeliverTx(RequestDeliverTx) ResponseDeliverTx // Deliver a tx for full processing
EndBlock(RequestEndBlock) ResponseEndBlock // Signals the end of a block, returns changes to the validator set
Commit() ResponseCommit // Commit the state and return the application Merkle root hash
PreprocessTxs(RequestPreprocessTxs) ResponsePreprocessTxs // State machine preprocessing of txs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this in between InitChain and BeginBlock. But as this is only the interface it does not block merging this PR.


// State Sync Connection
ListSnapshots(RequestListSnapshots) ResponseListSnapshots // List available snapshots
Expand Down Expand Up @@ -90,6 +92,10 @@ func (BaseApplication) ApplySnapshotChunk(req RequestApplySnapshotChunk) Respons
return ResponseApplySnapshotChunk{}
}

func (BaseApplication) PreprocessTxs(req RequestPreprocessTxs) ResponsePreprocessTxs {
return ResponsePreprocessTxs{}
}

//-------------------------------------------------------

// GRPCApplication is a GRPC wrapper for Application
Expand Down Expand Up @@ -172,3 +178,9 @@ func (app *GRPCApplication) ApplySnapshotChunk(
res := app.app.ApplySnapshotChunk(*req)
return &res, nil
}

func (app *GRPCApplication) PreprocessTxs(
ctx context.Context, req *RequestPreprocessTxs) (*ResponsePreprocessTxs, error) {
res := app.app.PreprocessTxs(*req)
return &res, nil
}
Loading