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

SeiDB+OCC for benchmark #351

Open
wants to merge 156 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
5e3f93f
Changes for memiavl
Jul 26, 2023
84bdda0
Fix changes for config
Jul 26, 2023
5a6e3eb
Remove debug log
Jul 26, 2023
539054b
fix go mod fir iavl
Jul 26, 2023
9d2e9c1
Bump golang version to 1.20
Jul 26, 2023
b717c11
Bump to 1.20
Jul 26, 2023
82df860
Fix go version
Jul 26, 2023
a9730a9
Expose Snapshot function
Jul 27, 2023
73eee20
Bump version
yzang2019 Aug 30, 2023
929da20
Bump mmap-iavl version
yzang2019 Sep 1, 2023
b03c2d4
Fix go sum
yzang2019 Sep 1, 2023
518544a
Add method for snapshot
yzang2019 Sep 2, 2023
2d06820
Bump iavl version
yzang2019 Sep 2, 2023
39068d8
Remove condition check
yzang2019 Sep 2, 2023
0d8aa92
Fix snapshot error handling logic
yzang2019 Sep 3, 2023
cd731c9
Merge branch 'main' into yzang/memiavl
yzang2019 Sep 3, 2023
6431ea7
Bump iavl and tendermint version
yzang2019 Sep 4, 2023
20c9714
Adding close for cache multistore in abci query
yzang2019 Sep 6, 2023
ed5e785
Add logs for cache multistore
yzang2019 Sep 7, 2023
6880b18
Add logs for cache multistore
yzang2019 Sep 7, 2023
ec9638a
Switch to seidb
yzang2019 Oct 11, 2023
6bc6c90
Add occ todos / comments (#317)
udpatil Sep 13, 2023
b66d23e
Multiversion Item Implementation and Tests (#318)
udpatil Sep 26, 2023
0048776
[occ] Add incarnation field (#321)
udpatil Sep 29, 2023
5d8941c
[occ] Implement basic multiversion store (#322)
udpatil Oct 6, 2023
dac5f7b
[occ] Add concurrency worker configuration (#324)
stevenlanders Oct 9, 2023
94bb98f
[occ] Occ multiversion store (#326)
udpatil Oct 10, 2023
5f89416
[occ] Add batch tx delivery interface (#327)
stevenlanders Oct 10, 2023
571d00a
[occ] MVKV store implementation and tests (#323)
udpatil Oct 10, 2023
9886602
[occ] Add validation function for transaction state to multiversionst…
udpatil Oct 13, 2023
293ac79
[occ] Add basic worker task and scheduler shell (#328)
stevenlanders Oct 17, 2023
dfb2260
[occ] Implement iterator for mvkv (#329)
udpatil Oct 17, 2023
663716a
fix dependency (#334)
udpatil Oct 17, 2023
b34d61c
[occ] Iterateset tracking and validation implementation (#337)
udpatil Oct 19, 2023
0aebbc9
[occ] Add scheduler logic for validation (#336)
stevenlanders Oct 19, 2023
096041b
[occ] Fix situation where no stores causes a panic (#338)
stevenlanders Oct 20, 2023
0b9193c
Add occ flag check to context (#340)
stevenlanders Oct 23, 2023
27484e4
[occ] Add struct field and helpers for estimate prefills (#341)
udpatil Oct 24, 2023
ab957f6
Add configs for seidb
yzang2019 Oct 24, 2023
7dcdd39
Bump seidb version
yzang2019 Oct 26, 2023
95ddc84
Fix map access panic (#343)
stevenlanders Oct 30, 2023
c51bdcb
Add query multi store for cosmos sdk
yzang2019 Nov 1, 2023
6302d64
Add qms
yzang2019 Nov 1, 2023
1d56ec8
Add snapshot manager for SC and SS
yzang2019 Nov 2, 2023
b96d79f
Fix snapshot manager
yzang2019 Nov 3, 2023
eab249d
Merge latest main
yzang2019 Nov 3, 2023
be4a4ae
Gen estimates writeset (#344)
udpatil Nov 3, 2023
948d27a
Bump seidb version
yzang2019 Nov 6, 2023
931e2f6
[OCC] Add trace spans to scheduler (#347)
stevenlanders Nov 6, 2023
2cc26a2
Add pruning settings for qms
yzang2019 Nov 7, 2023
9b57f8d
Revert change
yzang2019 Nov 7, 2023
cc31016
Add config for ss pruning manager
yzang2019 Nov 8, 2023
eac8657
[occ] Fix parent store readset validation (#348)
udpatil Nov 10, 2023
4111eeb
update lock to read lock on read
stevenlanders Nov 13, 2023
5bd9359
make validates parallel
stevenlanders Nov 13, 2023
09eaa06
add narrower lock
stevenlanders Nov 13, 2023
bf22e17
Bump seidb version
yzang2019 Nov 13, 2023
66ba9e6
Add config for num workers
yzang2019 Nov 13, 2023
06833bd
Add log for snapshot restore time
yzang2019 Nov 13, 2023
8818539
fix panic
stevenlanders Nov 14, 2023
1505649
make assertion dynamic
stevenlanders Nov 14, 2023
e321cf5
add more parallelization
stevenlanders Nov 14, 2023
b64efe1
add more parallelization
stevenlanders Nov 14, 2023
0d53d94
fix nested span
stevenlanders Nov 14, 2023
2752c9b
fix apphash
stevenlanders Nov 14, 2023
ce568cd
update spans
stevenlanders Nov 14, 2023
ac01db9
back the mapCacheBackend with a sync.Map
stevenlanders Nov 15, 2023
dc8e018
Revert "back the mapCacheBackend with a sync.Map"
stevenlanders Nov 15, 2023
ec87828
try early validate
stevenlanders Nov 15, 2023
9830c6c
add validation for previous tx dependency
stevenlanders Nov 15, 2023
2859512
fix span for validate
stevenlanders Nov 15, 2023
34a755a
remove mvkv mutex
udpatil Nov 13, 2023
205d5ca
remove some telemetry calls on heavily used functions
udpatil Nov 13, 2023
582e526
comment out rest of telemetry
udpatil Nov 13, 2023
7bab1f4
refactor MVS to use sync maps
udpatil Nov 14, 2023
e109f7e
remove log
udpatil Nov 14, 2023
a29338d
remove cachesize metric
udpatil Nov 14, 2023
a2ad48c
refactor cachekv mutex into map of mtxs
udpatil Nov 14, 2023
47fcbb1
remove event emit
udpatil Nov 15, 2023
33b1602
refactor cachekv for concurrent safe operation
udpatil Nov 15, 2023
ddeb662
remove telemetry from validateAll
udpatil Nov 15, 2023
925ebec
remove telemetry from runTX
udpatil Nov 15, 2023
4973f07
separate commitKVcache locking for getting vs writing to cache
udpatil Nov 15, 2023
4205725
avoid execute race
stevenlanders Nov 15, 2023
f7aa55d
remove lock from writeCache in commitKVStoreCache
udpatil Nov 15, 2023
d15a1aa
Merge branch 'main' into yzang/memiavl
yzang2019 Nov 15, 2023
9dda5d7
Bump seidb version
yzang2019 Nov 15, 2023
a7a9bb7
Fix merge conflict
yzang2019 Nov 15, 2023
887b943
Bump seidb version
yzang2019 Nov 15, 2023
e2a259a
cleanup
stevenlanders Nov 15, 2023
b0cb3ff
Fix seidb configs
yzang2019 Nov 15, 2023
b3783f5
Add log for DeliverTxBatch time
yzang2019 Nov 15, 2023
8da49cf
Fix logging
yzang2019 Nov 15, 2023
961ef16
fix data race
stevenlanders Nov 15, 2023
a3618f5
Bump seidb version
yzang2019 Nov 15, 2023
ebb8fe1
Bump version
yzang2019 Nov 15, 2023
62e2bf2
Remove some logs
yzang2019 Nov 15, 2023
5a6b268
refactor setWriteset to write keys concurrently
udpatil Nov 16, 2023
f83fcda
Try disable tracing for tx execution
yzang2019 Nov 16, 2023
2297520
Fix nil pointer
yzang2019 Nov 16, 2023
7a57d9f
remove mvkv mutex
udpatil Nov 13, 2023
3611e8f
remove some telemetry calls on heavily used functions
udpatil Nov 13, 2023
8ff1b86
comment out rest of telemetry
udpatil Nov 13, 2023
2bf854a
refactor MVS to use sync maps
udpatil Nov 14, 2023
be51212
remove log
udpatil Nov 14, 2023
4679312
remove cachesize metric
udpatil Nov 14, 2023
a56d9a8
refactor cachekv mutex into map of mtxs
udpatil Nov 14, 2023
d93219c
remove event emit
udpatil Nov 15, 2023
7fd83ac
refactor cachekv for concurrent safe operation
udpatil Nov 15, 2023
92c693d
remove telemetry from validateAll
udpatil Nov 15, 2023
bdbd3a6
remove telemetry from runTX
udpatil Nov 15, 2023
b619bae
separate commitKVcache locking for getting vs writing to cache
udpatil Nov 15, 2023
4876150
remove lock from writeCache in commitKVStoreCache
udpatil Nov 15, 2023
10a0106
try setting writeset concurrently
udpatil Nov 15, 2023
8b5cac1
add log
udpatil Nov 16, 2023
faa45e9
add log
udpatil Nov 16, 2023
961d567
add log
udpatil Nov 16, 2023
744428f
add log
udpatil Nov 16, 2023
247cac3
add log
udpatil Nov 16, 2023
d8fe722
add log
udpatil Nov 16, 2023
b7ffe7d
add logger
udpatil Nov 16, 2023
38380a8
add logger
udpatil Nov 16, 2023
2de779c
add logs
udpatil Nov 16, 2023
ad48a78
add logs
udpatil Nov 16, 2023
5397208
add logs
udpatil Nov 16, 2023
922837b
add logs
udpatil Nov 16, 2023
f616719
add logs
udpatil Nov 16, 2023
c48b8ad
add logs
udpatil Nov 16, 2023
a7571ae
bump go mod
udpatil Nov 16, 2023
de87d52
add logs
udpatil Nov 16, 2023
33e7242
add logs
udpatil Nov 16, 2023
dc36ad5
add logs
udpatil Nov 16, 2023
efdac0e
add logs
udpatil Nov 16, 2023
aa9a276
add clear iterateset
udpatil Nov 16, 2023
5d96863
Merge latest branch
yzang2019 Nov 16, 2023
f597fcd
Revert "add logs"
udpatil Nov 17, 2023
107fde3
Fix iterateset validation to no longer delete expectedKeys
udpatil Nov 20, 2023
6175308
Merge branch 'occ-optimization' into seidb+occ
yzang2019 Nov 20, 2023
ed65ad0
Fix bug
yzang2019 Nov 20, 2023
839d155
Revert "try setting writeset concurrently"
udpatil Nov 21, 2023
adf2e8b
Merge branch 'occ-optimization' into seidb+occ
yzang2019 Nov 21, 2023
07afd1d
[OCC] Use worker pool to limit number of goroutines (#355)
stevenlanders Nov 21, 2023
abddea4
[OCC] Fix deadlock (#356)
stevenlanders Nov 21, 2023
a0d2aa9
Test no-op deliver tx
yzang2019 Nov 28, 2023
81a029f
Add logging for occ latency
yzang2019 Nov 28, 2023
3bae5dd
Add config to disable seqno (#385)
philipsu522 Jan 9, 2024
20f8928
Add migration handler for disabling seqno (#394)
philipsu522 Jan 11, 2024
3483ce7
Pick part1
yzang2019 Dec 27, 2023
87493f6
Part 2
yzang2019 Dec 27, 2023
5631500
Part 3
yzang2019 Dec 27, 2023
640567f
Part 4
yzang2019 Dec 28, 2023
16a5b68
Fix
yzang2019 Feb 5, 2024
c320a02
Fix
yzang2019 Feb 5, 2024
0aa8a5b
Fix
yzang2019 Feb 5, 2024
1972318
Add
yzang2019 Feb 5, 2024
5be6b78
Add log
yzang2019 Feb 15, 2024
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
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches:
- main
- occ-main # TODO: remove after occ work is done

permissions:
contents: read
Expand All @@ -22,7 +23,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: '1.20'
- name: Create a file with all core Cosmos SDK pkgs
run: go list ./... > pkgs.txt
- name: Split pkgs into 10 files
Expand Down Expand Up @@ -81,7 +82,7 @@ jobs:
- uses: actions/setup-python@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: '1.20'
- uses: technote-space/[email protected]
with:
PATTERNS: |
Expand Down Expand Up @@ -116,7 +117,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: '1.20'

# Download all coverage reports from the 'tests' job
- name: Download coverage reports
Expand Down
125 changes: 83 additions & 42 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"syscall"
"time"

"github.com/cosmos/cosmos-sdk/tasks"

"github.com/armon/go-metrics"
"github.com/gogo/protobuf/proto"
abci "github.com/tendermint/tendermint/abci/types"
Expand All @@ -25,6 +27,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/legacytm"
"github.com/cosmos/cosmos-sdk/utils"
)

// InitChain implements the ABCI interface. It runs the initialization logic
Expand Down Expand Up @@ -68,11 +71,6 @@ func (app *BaseApp) InitChain(ctx context.Context, req *abci.RequestInitChain) (
return
}

// add block gas meter for any genesis transactions (allow infinite gas)
app.deliverState.ctx = app.deliverState.ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())
app.prepareProposalState.ctx = app.prepareProposalState.ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())
app.processProposalState.ctx = app.processProposalState.ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())

resp := app.initChainer(app.deliverState.ctx, *req)
app.initChainer(app.prepareProposalState.ctx, *req)
app.initChainer(app.processProposalState.ctx, *req)
Expand Down Expand Up @@ -234,11 +232,31 @@ func (app *BaseApp) CheckTx(ctx context.Context, req *abci.RequestCheckTx) (*abc
}, nil
}

// DeliverTxBatch executes multiple txs
func (app *BaseApp) DeliverTxBatch(ctx sdk.Context, req sdk.DeliverTxBatchRequest) (res sdk.DeliverTxBatchResponse) {
scheduler := tasks.NewScheduler(app.concurrencyWorkers, app.TracingInfo, app.DeliverTx)
// This will basically no-op the actual prefill if the metadata for the txs is empty

// process all txs, this will also initializes the MVS if prefill estimates was disabled
txRes, err := scheduler.ProcessAll(ctx, req.TxEntries)
if err != nil {
// TODO: handle error
}

responses := make([]*sdk.DeliverTxResult, 0, len(req.TxEntries))
for _, tx := range txRes {
responses = append(responses, &sdk.DeliverTxResult{Response: tx})
}
return sdk.DeliverTxBatchResponse{Results: responses}
}

// DeliverTx implements the ABCI interface and executes a tx in DeliverTx mode.
// State only gets persisted if all messages are valid and get executed successfully.
// Otherwise, the ResponseDeliverTx will contain releveant error information.
// Otherwise, the ResponseDeliverTx will contain relevant error information.
// Regardless of tx execution outcome, the ResponseDeliverTx will contain relevant
// gas execution context.
// TODO: (occ) this is the function called from sei-chain to perform execution of a transaction.
// We'd likely replace this with an execution tasks that is scheduled by the OCC scheduler
func (app *BaseApp) DeliverTx(ctx sdk.Context, req abci.RequestDeliverTx) (res abci.ResponseDeliverTx) {
defer telemetry.MeasureSince(time.Now(), "abci", "deliver_tx")
defer func() {
Expand Down Expand Up @@ -344,15 +362,19 @@ func (app *BaseApp) Commit(ctx context.Context) (res *abci.ResponseCommit, err e
app.halt()
}

if app.snapshotInterval > 0 && uint64(header.Height)%app.snapshotInterval == 0 {
go app.snapshot(header.Height)
}
app.SnapshotIfApplicable(uint64(header.Height))

return &abci.ResponseCommit{
RetainHeight: retainHeight,
}, nil
}

func (app *BaseApp) SnapshotIfApplicable(height uint64) {
if app.snapshotInterval > 0 && height%app.snapshotInterval == 0 {
go app.Snapshot(int64(height))
}
}

// halt attempts to gracefully shutdown the node via SIGINT and SIGTERM falling
// back on os.Exit if both fail.
func (app *BaseApp) halt() {
Expand All @@ -375,8 +397,8 @@ func (app *BaseApp) halt() {
os.Exit(0)
}

// snapshot takes a snapshot of the current state and prunes any old snapshottypes.
func (app *BaseApp) snapshot(height int64) {
// Snapshot takes a snapshot of the current state and prunes any old snapshottypes.
func (app *BaseApp) Snapshot(height int64) {
if app.snapshotManager == nil {
app.logger.Info("snapshot manager not configured")
return
Expand Down Expand Up @@ -908,7 +930,7 @@ func splitPath(requestPath string) (path []string) {
}

// ABCI++
func (app *BaseApp) PrepareProposal(ctx context.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) {
func (app *BaseApp) PrepareProposal(ctx context.Context, req *abci.RequestPrepareProposal) (resp *abci.ResponsePrepareProposal, err error) {
defer telemetry.MeasureSince(time.Now(), "abci", "prepare_proposal")

header := tmproto.Header{
Expand Down Expand Up @@ -942,21 +964,40 @@ func (app *BaseApp) PrepareProposal(ctx context.Context, req *abci.RequestPrepar

app.preparePrepareProposalState()

defer func() {
if err := recover(); err != nil {
app.logger.Error(
"panic recovered in PrepareProposal",
"height", req.Height,
"time", req.Time,
"panic", err,
)

resp = &abci.ResponsePrepareProposal{
TxRecords: utils.Map(req.Txs, func(tx []byte) *abci.TxRecord {
return &abci.TxRecord{Action: abci.TxRecord_UNMODIFIED, Tx: tx}
}),
}
}
}()

if app.prepareProposalHandler != nil {
res, err := app.prepareProposalHandler(app.prepareProposalState.ctx, req)
resp, err = app.prepareProposalHandler(app.prepareProposalState.ctx, req)
if err != nil {
return nil, err
}

if cp := app.GetConsensusParams(app.prepareProposalState.ctx); cp != nil {
res.ConsensusParamUpdates = cp
resp.ConsensusParamUpdates = cp
}
return res, nil
} else {
return nil, errors.New("no prepare proposal handler")

return resp, nil
}

return nil, errors.New("no prepare proposal handler")
}

func (app *BaseApp) ProcessProposal(ctx context.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) {
func (app *BaseApp) ProcessProposal(ctx context.Context, req *abci.RequestProcessProposal) (resp *abci.ResponseProcessProposal, err error) {
defer telemetry.MeasureSince(time.Now(), "abci", "process_proposal")

header := tmproto.Header{
Expand Down Expand Up @@ -988,30 +1029,38 @@ func (app *BaseApp) ProcessProposal(ctx context.Context, req *abci.RequestProces
app.setProcessProposalHeader(header)
}

// add block gas meter
var gasMeter sdk.GasMeter
if maxGas := app.getMaximumBlockGas(app.processProposalState.ctx); maxGas > 0 {
gasMeter = sdk.NewGasMeter(maxGas)
} else {
gasMeter = sdk.NewInfiniteGasMeter()
}

// NOTE: header hash is not set in NewContext, so we manually set it here

app.prepareProcessProposalState(gasMeter, req.Hash)
app.prepareProcessProposalState(req.Hash)

defer func() {
if err := recover(); err != nil {
app.logger.Error(
"panic recovered in ProcessProposal",
"height", req.Height,
"time", req.Time,
"hash", fmt.Sprintf("%X", req.Hash),
"panic", err,
)

resp = &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}
}
}()

if app.processProposalHandler != nil {
res, err := app.processProposalHandler(app.processProposalState.ctx, req)
resp, err = app.processProposalHandler(app.processProposalState.ctx, req)
if err != nil {
return nil, err
}

if cp := app.GetConsensusParams(app.processProposalState.ctx); cp != nil {
res.ConsensusParamUpdates = cp
resp.ConsensusParamUpdates = cp
}
return res, nil
} else {
return nil, errors.New("no process proposal handler")

return resp, nil
}

return nil, errors.New("no process proposal handler")
}

func (app *BaseApp) FinalizeBlock(ctx context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) {
Expand Down Expand Up @@ -1055,22 +1104,14 @@ func (app *BaseApp) FinalizeBlock(ctx context.Context, req *abci.RequestFinalize
app.setDeliverStateHeader(header)
}

// add block gas meter
var gasMeter sdk.GasMeter
if maxGas := app.getMaximumBlockGas(app.deliverState.ctx); maxGas > 0 {
gasMeter = sdk.NewGasMeter(maxGas)
} else {
gasMeter = sdk.NewInfiniteGasMeter()
}

// NOTE: header hash is not set in NewContext, so we manually set it here

app.prepareDeliverState(gasMeter, req.Hash)
app.prepareDeliverState(req.Hash)

// we also set block gas meter to checkState in case the application needs to
// verify gas consumption during (Re)CheckTx
if app.checkState != nil {
app.checkState.SetContext(app.checkState.ctx.WithBlockGasMeter(gasMeter).WithHeaderHash(req.Hash))
app.checkState.SetContext(app.checkState.ctx.WithHeaderHash(req.Hash))
}

if app.finalizeBlocker != nil {
Expand Down
Loading