Skip to content

Commit

Permalink
Remove entropy
Browse files Browse the repository at this point in the history
  • Loading branch information
ulbqb committed Aug 7, 2023
1 parent d971aa4 commit 474e6aa
Show file tree
Hide file tree
Showing 20 changed files with 165 additions and 588 deletions.
4 changes: 2 additions & 2 deletions abci/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Client interface {
QueryAsync(types.RequestQuery, ResponseCallback) *ReqRes
CommitAsync(ResponseCallback) *ReqRes
InitChainAsync(types.RequestInitChain, ResponseCallback) *ReqRes
BeginBlockAsync(ocabci.RequestBeginBlock, ResponseCallback) *ReqRes
BeginBlockAsync(types.RequestBeginBlock, ResponseCallback) *ReqRes
EndBlockAsync(types.RequestEndBlock, ResponseCallback) *ReqRes
BeginRecheckTxAsync(ocabci.RequestBeginRecheckTx, ResponseCallback) *ReqRes
EndRecheckTxAsync(ocabci.RequestEndRecheckTx, ResponseCallback) *ReqRes
Expand All @@ -58,7 +58,7 @@ type Client interface {
QuerySync(types.RequestQuery) (*types.ResponseQuery, error)
CommitSync() (*types.ResponseCommit, error)
InitChainSync(types.RequestInitChain) (*types.ResponseInitChain, error)
BeginBlockSync(ocabci.RequestBeginBlock) (*types.ResponseBeginBlock, error)
BeginBlockSync(types.RequestBeginBlock) (*types.ResponseBeginBlock, error)
EndBlockSync(types.RequestEndBlock) (*types.ResponseEndBlock, error)
BeginRecheckTxSync(ocabci.RequestBeginRecheckTx) (*ocabci.ResponseBeginRecheckTx, error)
EndRecheckTxSync(ocabci.RequestEndRecheckTx) (*ocabci.ResponseEndRecheckTx, error)
Expand Down
4 changes: 2 additions & 2 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (cli *grpcClient) InitChainAsync(params types.RequestInitChain, cb Response
return cli.finishAsyncCall(req, &ocabci.Response{Value: &ocabci.Response_InitChain{InitChain: res}}, cb)
}

func (cli *grpcClient) BeginBlockAsync(params ocabci.RequestBeginBlock, cb ResponseCallback) *ReqRes {
func (cli *grpcClient) BeginBlockAsync(params types.RequestBeginBlock, cb ResponseCallback) *ReqRes {
req := ocabci.ToRequestBeginBlock(params)
res, err := cli.client.BeginBlock(context.Background(), req.GetBeginBlock(), grpc.WaitForReady(true))
if err != nil {
Expand Down Expand Up @@ -366,7 +366,7 @@ func (cli *grpcClient) InitChainSync(params types.RequestInitChain) (*types.Resp
return reqres.Response.GetInitChain(), cli.Error()
}

func (cli *grpcClient) BeginBlockSync(params ocabci.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
func (cli *grpcClient) BeginBlockSync(params types.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
reqres := cli.BeginBlockAsync(params, nil)
reqres.Wait()
return reqres.Response.GetBeginBlock(), cli.Error()
Expand Down
4 changes: 2 additions & 2 deletions abci/client/grpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestGrpcClientCalls(t *testing.T) {
c.QueryAsync(types.RequestQuery{}, getResponseCallback(t))
c.CommitAsync(getResponseCallback(t))
c.InitChainAsync(types.RequestInitChain{}, getResponseCallback(t))
c.BeginBlockAsync(ocabci.RequestBeginBlock{}, getResponseCallback(t))
c.BeginBlockAsync(types.RequestBeginBlock{}, getResponseCallback(t))
c.EndBlockAsync(types.RequestEndBlock{}, getResponseCallback(t))
c.BeginRecheckTxAsync(ocabci.RequestBeginRecheckTx{}, getResponseCallback(t))
c.EndRecheckTxAsync(ocabci.RequestEndRecheckTx{}, getResponseCallback(t))
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestGrpcClientCalls(t *testing.T) {
_, err = c.InitChainSync(types.RequestInitChain{})
require.NoError(t, err)

_, err = c.BeginBlockSync(ocabci.RequestBeginBlock{})
_, err = c.BeginBlockSync(types.RequestBeginBlock{})
require.NoError(t, err)

_, err = c.EndBlockSync(types.RequestEndBlock{})
Expand Down
4 changes: 2 additions & 2 deletions abci/client/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (app *localClient) InitChainAsync(req types.RequestInitChain, cb ResponseCa
return app.done(reqRes, ocabci.ToResponseInitChain(res))
}

func (app *localClient) BeginBlockAsync(req ocabci.RequestBeginBlock, cb ResponseCallback) *ReqRes {
func (app *localClient) BeginBlockAsync(req types.RequestBeginBlock, cb ResponseCallback) *ReqRes {
app.mtx.Lock()
defer app.mtx.Unlock()

Expand Down Expand Up @@ -290,7 +290,7 @@ func (app *localClient) InitChainSync(req types.RequestInitChain) (*types.Respon
return &res, nil
}

func (app *localClient) BeginBlockSync(req ocabci.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
func (app *localClient) BeginBlockSync(req types.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
app.mtx.Lock()
defer app.mtx.Unlock()

Expand Down
4 changes: 2 additions & 2 deletions abci/client/local_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestLocalClientCalls(t *testing.T) {
c.QueryAsync(types.RequestQuery{}, getResponseCallback(t))
c.CommitAsync(getResponseCallback(t))
c.InitChainAsync(types.RequestInitChain{}, getResponseCallback(t))
c.BeginBlockAsync(ocabci.RequestBeginBlock{}, getResponseCallback(t))
c.BeginBlockAsync(types.RequestBeginBlock{}, getResponseCallback(t))
c.EndBlockAsync(types.RequestEndBlock{}, getResponseCallback(t))
c.BeginRecheckTxAsync(ocabci.RequestBeginRecheckTx{}, getResponseCallback(t))
c.EndRecheckTxAsync(ocabci.RequestEndRecheckTx{}, getResponseCallback(t))
Expand Down Expand Up @@ -87,7 +87,7 @@ func TestLocalClientCalls(t *testing.T) {
_, err = c.InitChainSync(types.RequestInitChain{})
require.NoError(t, err)

_, err = c.BeginBlockSync(ocabci.RequestBeginBlock{})
_, err = c.BeginBlockSync(types.RequestBeginBlock{})
require.NoError(t, err)

_, err = c.EndBlockSync(types.RequestEndBlock{})
Expand Down
12 changes: 6 additions & 6 deletions abci/client/mocks/client.go

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

4 changes: 2 additions & 2 deletions abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (cli *socketClient) InitChainAsync(req types.RequestInitChain, cb ResponseC
return cli.queueRequest(ocabci.ToRequestInitChain(req), cb)
}

func (cli *socketClient) BeginBlockAsync(req ocabci.RequestBeginBlock, cb ResponseCallback) *ReqRes {
func (cli *socketClient) BeginBlockAsync(req types.RequestBeginBlock, cb ResponseCallback) *ReqRes {
return cli.queueRequest(ocabci.ToRequestBeginBlock(req), cb)
}

Expand Down Expand Up @@ -377,7 +377,7 @@ func (cli *socketClient) InitChainSync(req types.RequestInitChain) (*types.Respo
return reqres.Response.GetInitChain(), cli.Error()
}

func (cli *socketClient) BeginBlockSync(req ocabci.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
func (cli *socketClient) BeginBlockSync(req types.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
reqres := cli.queueRequest(ocabci.ToRequestBeginBlock(req), nil)
if _, err := cli.FlushSync(); err != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions abci/client/socket_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestProperSyncCalls(t *testing.T) {
resp := make(chan error, 1)
go func() {
// This is BeginBlockSync unrolled....
reqres := c.BeginBlockAsync(ocabci.RequestBeginBlock{}, nil)
reqres := c.BeginBlockAsync(types.RequestBeginBlock{}, nil)
_, err := c.FlushSync()
require.NoError(t, err)
res := reqres.Response.GetBeginBlock()
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestHangingSyncCalls(t *testing.T) {
resp := make(chan error, 1)
go func() {
// Start BeginBlock and flush it
reqres := c.BeginBlockAsync(ocabci.RequestBeginBlock{}, nil)
reqres := c.BeginBlockAsync(types.RequestBeginBlock{}, nil)
flush := c.FlushAsync(nil)
// wait 20 ms for all events to travel socket, but
// no response yet from server
Expand Down Expand Up @@ -116,7 +116,7 @@ type slowApp struct {
ocabci.BaseApplication
}

func (slowApp) BeginBlock(req ocabci.RequestBeginBlock) types.ResponseBeginBlock {
func (slowApp) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock {
time.Sleep(200 * time.Millisecond)
return types.ResponseBeginBlock{}
}
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestSockerClientCalls(t *testing.T) {
c.QueryAsync(types.RequestQuery{}, getResponseCallback(t))
c.CommitAsync(getResponseCallback(t))
c.InitChainAsync(types.RequestInitChain{}, getResponseCallback(t))
c.BeginBlockAsync(ocabci.RequestBeginBlock{}, getResponseCallback(t))
c.BeginBlockAsync(types.RequestBeginBlock{}, getResponseCallback(t))
c.EndBlockAsync(types.RequestEndBlock{}, getResponseCallback(t))
c.BeginRecheckTxAsync(ocabci.RequestBeginRecheckTx{}, getResponseCallback(t))
c.EndRecheckTxAsync(ocabci.RequestEndRecheckTx{}, getResponseCallback(t))
Expand Down Expand Up @@ -184,7 +184,7 @@ func TestSockerClientCalls(t *testing.T) {
_, err = c.InitChainSync(types.RequestInitChain{})
require.NoError(t, err)

_, err = c.BeginBlockSync(ocabci.RequestBeginBlock{})
_, err = c.BeginBlockSync(types.RequestBeginBlock{})
require.NoError(t, err)

_, err = c.EndBlockSync(types.RequestEndBlock{})
Expand Down
4 changes: 2 additions & 2 deletions abci/example/kvstore/kvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestPersistentKVStoreInfo(t *testing.T) {
header := tmproto.Header{
Height: height,
}
kvstore.BeginBlock(ocabci.RequestBeginBlock{Hash: hash, Header: header})
kvstore.BeginBlock(types.RequestBeginBlock{Hash: hash, Header: header})
kvstore.EndBlock(types.RequestEndBlock{Height: header.Height})
kvstore.Commit()

Expand Down Expand Up @@ -197,7 +197,7 @@ func makeApplyBlock(
Height: height,
}

kvstore.BeginBlock(ocabci.RequestBeginBlock{Hash: hash, Header: header})
kvstore.BeginBlock(types.RequestBeginBlock{Hash: hash, Header: header})
for _, tx := range txs {
if r := kvstore.DeliverTx(types.RequestDeliverTx{Tx: tx}); r.IsErr() {
t.Fatal(r)
Expand Down
2 changes: 1 addition & 1 deletion abci/example/kvstore/persistent_kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (app *PersistentKVStoreApplication) InitChain(req types.RequestInitChain) t
}

// Track the block hash and header information
func (app *PersistentKVStoreApplication) BeginBlock(req ocabci.RequestBeginBlock) types.ResponseBeginBlock {
func (app *PersistentKVStoreApplication) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock {
// reset valset changes
app.ValUpdates = make([]types.ValidatorUpdate, 0)

Expand Down
14 changes: 7 additions & 7 deletions abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ type Application interface {
EndRecheckTx(RequestEndRecheckTx) ResponseEndRecheckTx // Signals the end of rechecking

// Consensus Connection
InitChain(types.RequestInitChain) types.ResponseInitChain // Initialize blockchain w validators/other info from OstraconCore
BeginBlock(RequestBeginBlock) types.ResponseBeginBlock // Signals the beginning of a block
DeliverTx(types.RequestDeliverTx) types.ResponseDeliverTx // Deliver a tx for full processing
EndBlock(types.RequestEndBlock) types.ResponseEndBlock // Signals the end of a block, returns changes to the validator set
Commit() types.ResponseCommit // Commit the state and return the application Merkle root hash
InitChain(types.RequestInitChain) types.ResponseInitChain // Initialize blockchain w validators/other info from OstraconCore
BeginBlock(types.RequestBeginBlock) types.ResponseBeginBlock // Signals the beginning of a block
DeliverTx(types.RequestDeliverTx) types.ResponseDeliverTx // Deliver a tx for full processing
EndBlock(types.RequestEndBlock) types.ResponseEndBlock // Signals the end of a block, returns changes to the validator set
Commit() types.ResponseCommit // Commit the state and return the application Merkle root hash

// State Sync Connection
ListSnapshots(types.RequestListSnapshots) types.ResponseListSnapshots // List available snapshots
Expand Down Expand Up @@ -92,7 +92,7 @@ func (BaseApplication) InitChain(req types.RequestInitChain) types.ResponseInitC
return types.ResponseInitChain{}
}

func (BaseApplication) BeginBlock(req RequestBeginBlock) types.ResponseBeginBlock {
func (BaseApplication) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock {
return types.ResponseBeginBlock{}
}

Expand Down Expand Up @@ -181,7 +181,7 @@ func (app *GRPCApplication) InitChain(ctx context.Context, req *types.RequestIni
return &res, nil
}

func (app *GRPCApplication) BeginBlock(ctx context.Context, req *RequestBeginBlock) (*types.ResponseBeginBlock, error) {
func (app *GRPCApplication) BeginBlock(ctx context.Context, req *types.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
res := app.app.BeginBlock(*req)
return &res, nil
}
Expand Down
2 changes: 1 addition & 1 deletion abci/types/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func ToRequestInitChain(req types.RequestInitChain) *Request {
}
}

func ToRequestBeginBlock(req RequestBeginBlock) *Request {
func ToRequestBeginBlock(req types.RequestBeginBlock) *Request {
return &Request{
Value: &Request_BeginBlock{&req},
}
Expand Down
4 changes: 2 additions & 2 deletions abci/types/mocks/application.go

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

Loading

0 comments on commit 474e6aa

Please sign in to comment.