Skip to content

Commit

Permalink
Merge branch 'release/v1.x.x' into dependabot/go_modules/release/v1.x…
Browse files Browse the repository at this point in the history
….x/github.com/cometbft/cometbft-db-0.9.0
  • Loading branch information
davidterpay authored Dec 4, 2023
2 parents 652b63b + d2a7f21 commit 0d3f84e
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 164 deletions.
4 changes: 2 additions & 2 deletions abci/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
)

// Fill the proposal with transactions from each lane.
finalProposal, err := h.prepareLanesHandler(ctx, proposals.NewProposalWithContext(h.logger, ctx, h.txEncoder))
finalProposal, err := h.prepareLanesHandler(ctx, proposals.NewProposalWithContext(ctx, h.logger))
if err != nil {
h.logger.Error("failed to prepare proposal", "err", err)
return abci.ResponsePrepareProposal{Txs: make([][]byte, 0)}
Expand Down Expand Up @@ -126,7 +126,7 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {

// Build handler that will verify the partial proposals according to each lane's verification logic.
processLanesHandler := ChainProcessLanes(h.mempool.Registry())
finalProposal, err := processLanesHandler(ctx, proposals.NewProposalWithContext(h.logger, ctx, h.txEncoder), decodedTxs)
finalProposal, err := processLanesHandler(ctx, proposals.NewProposalWithContext(ctx, h.logger), decodedTxs)
if err != nil {
h.logger.Error("failed to validate the proposal", "err", err)
return abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}
Expand Down
15 changes: 6 additions & 9 deletions block/proposals/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,24 @@ type (
Txs [][]byte
// Cache is a cache of the selected transactions in the proposal.
Cache map[string]struct{}
// TxEncoder is the transaction encoder.
TxEncoder sdk.TxEncoder
// Info contains information about the state of the proposal.
Info types.ProposalInfo
}
)

// NewProposalWithContext returns a new empty proposal.
func NewProposalWithContext(logger log.Logger, ctx sdk.Context, txEncoder sdk.TxEncoder) Proposal {
func NewProposalWithContext(ctx sdk.Context, logger log.Logger) Proposal {
maxBlockSize, maxGasLimit := GetBlockLimits(ctx)
return NewProposal(logger, txEncoder, maxBlockSize, maxGasLimit)
return NewProposal(logger, maxBlockSize, maxGasLimit)
}

// NewProposal returns a new empty proposal. Any transactions added to the proposal
// will be subject to the given max block size and max gas limit.
func NewProposal(logger log.Logger, txEncoder sdk.TxEncoder, maxBlockSize int64, maxGasLimit uint64) Proposal {
func NewProposal(logger log.Logger, maxBlockSize int64, maxGasLimit uint64) Proposal {
return Proposal{
Logger: logger,
TxEncoder: txEncoder,
Txs: make([][]byte, 0),
Cache: make(map[string]struct{}),
Logger: logger,
Txs: make([][]byte, 0),
Cache: make(map[string]struct{}),
Info: types.ProposalInfo{
TxsByLane: make(map[string]uint64),
MaxBlockSize: maxBlockSize,
Expand Down
20 changes: 10 additions & 10 deletions block/proposals/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestUpdateProposal(t *testing.T) {
lane.On("GetMaxBlockSpace").Return(math.LegacyNewDec(1)).Maybe()

t.Run("can update with no transactions", func(t *testing.T) {
proposal := proposals.NewProposal(log.NewNopLogger(), nil, 100, 100)
proposal := proposals.NewProposal(log.NewNopLogger(), 100, 100)

err := proposal.UpdateProposal(lane, nil)
require.NoError(t, err)
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestUpdateProposal(t *testing.T) {

size := len(txBzs[0])
gasLimit := 100
proposal := proposals.NewProposal(log.NewNopLogger(), encodingConfig.TxConfig.TxEncoder(), int64(size), uint64(gasLimit))
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), uint64(gasLimit))

txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
require.NoError(t, err)
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestUpdateProposal(t *testing.T) {
gasLimit += 100
}

proposal := proposals.NewProposal(log.NewNopLogger(), encodingConfig.TxConfig.TxEncoder(), int64(size), gasLimit)
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), gasLimit)

txsWithInfo, err := getTxsWithInfo(txs)
require.NoError(t, err)
Expand Down Expand Up @@ -153,7 +153,7 @@ func TestUpdateProposal(t *testing.T) {

size := int64(len(txBzs[0]))
gasLimit := uint64(100)
proposal := proposals.NewProposal(log.NewNopLogger(), encodingConfig.TxConfig.TxEncoder(), size, gasLimit)
proposal := proposals.NewProposal(log.NewNopLogger(), size, gasLimit)

txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
require.NoError(t, err)
Expand Down Expand Up @@ -219,7 +219,7 @@ func TestUpdateProposal(t *testing.T) {

size := len(txBzs[0]) + len(txBzs[1])
gasLimit := 200
proposal := proposals.NewProposal(log.NewNopLogger(), encodingConfig.TxConfig.TxEncoder(), int64(size), uint64(gasLimit))
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), uint64(gasLimit))

txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
require.NoError(t, err)
Expand Down Expand Up @@ -263,7 +263,7 @@ func TestUpdateProposal(t *testing.T) {

size := len(txBzs[0])
gasLimit := 100
proposal := proposals.NewProposal(log.NewNopLogger(), encodingConfig.TxConfig.TxEncoder(), int64(size), uint64(gasLimit))
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), uint64(gasLimit))

lane := mocks.NewLane(t)

Expand Down Expand Up @@ -304,7 +304,7 @@ func TestUpdateProposal(t *testing.T) {

size := len(txBzs[0])
gasLimit := 100
proposal := proposals.NewProposal(log.NewNopLogger(), encodingConfig.TxConfig.TxEncoder(), int64(size), uint64(gasLimit))
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), uint64(gasLimit))

lane := mocks.NewLane(t)

Expand Down Expand Up @@ -345,7 +345,7 @@ func TestUpdateProposal(t *testing.T) {

size := len(txBzs[0])
gasLimit := 100
proposal := proposals.NewProposal(log.NewNopLogger(), encodingConfig.TxConfig.TxEncoder(), int64(size)-1, uint64(gasLimit))
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size)-1, uint64(gasLimit))

txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
require.NoError(t, err)
Expand Down Expand Up @@ -381,7 +381,7 @@ func TestUpdateProposal(t *testing.T) {

size := len(txBzs[0])
gasLimit := 100
proposal := proposals.NewProposal(log.NewNopLogger(), encodingConfig.TxConfig.TxEncoder(), int64(size), uint64(gasLimit)-1)
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), uint64(gasLimit)-1)

txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
require.NoError(t, err)
Expand Down Expand Up @@ -425,7 +425,7 @@ func TestUpdateProposal(t *testing.T) {
txBzs, err := utils.GetEncodedTxs(encodingConfig.TxConfig.TxEncoder(), []sdk.Tx{tx, tx2})
require.NoError(t, err)

proposal := proposals.NewProposal(log.NewNopLogger(), encodingConfig.TxConfig.TxEncoder(), 10000, 10000)
proposal := proposals.NewProposal(log.NewNopLogger(), 10000, 10000)

txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
require.NoError(t, err)
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
golang.org/x/tools v0.15.0
golang.org/x/tools v0.16.0
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
Expand Down Expand Up @@ -291,15 +291,15 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.14.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.143.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1326,8 +1326,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb h1:xIApU0ow1zwMa2uL1VDNeQlNVFTWMQxZUZCMDy0Q4Us=
golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
Expand Down Expand Up @@ -1428,8 +1428,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -1585,16 +1585,16 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8=
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down Expand Up @@ -1689,8 +1689,8 @@ golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8=
golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk=
golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM=
golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
11 changes: 6 additions & 5 deletions lanes/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ $ go install github.com/skip-mev/block-sdk

## 📚 Usage

> Note: Please visit [app.go](../../tests/app/lanes.go) to see a sample base app set up.
1. First determine the set of lanes that you want to use in your application. The
available lanes can be found in our
[Lane App Store](https://docs.skip.money/chains/lanes/existing-lanes/default).
Expand Down Expand Up @@ -45,8 +47,7 @@ func NewApp() {
// 1. Create the lanes.
//
// NOTE: The lanes are ordered by priority. The first lane is the highest priority
// lane and the last lane is the lowest priority lane. Top of block lane allows
// transactions to bid for inclusion at the top of the next block.
// lane and the last lane is the lowest priority lane.
//
// For more information on how to utilize the LaneConfig please
// visit the README in docs.skip.money/chains/lanes/build-your-own-lane#-lane-config.
Expand All @@ -57,15 +58,15 @@ func NewApp() {
TxEncoder: app.txConfig.TxEncoder(),
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyZeroDec(),
MaxTxs: 0,
MaxTxs: 5000,
}
defaultLane := defaultlane.NewDefaultLane(defaultConfig)
defaultLane := defaultlane.NewDefaultLane(defaultConfig, base.DefaultMatchHandler())

// 2. Set up the relative priority of lanes
lanes := []block.Lane{
defaultLane,
}
mempool := block.NewLanedMempool(app.Logger(), true, lanes...)
mempool := block.NewLanedMempool(app.Logger(), lanes)
app.App.SetMempool(mempool)

...
Expand Down
Loading

0 comments on commit 0d3f84e

Please sign in to comment.