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

[OCC] occ+evm #439

Draft
wants to merge 45 commits into
base: occ-main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1923a47
Add occ todos / comments (#317)
udpatil Sep 13, 2023
5ad76e0
Multiversion Item Implementation and Tests (#318)
udpatil Sep 26, 2023
5e5b4ce
[occ] Add incarnation field (#321)
udpatil Sep 29, 2023
cda8c31
[occ] Implement basic multiversion store (#322)
udpatil Oct 6, 2023
703b28a
[occ] Add concurrency worker configuration (#324)
stevenlanders Oct 9, 2023
1e60246
[occ] Occ multiversion store (#326)
udpatil Oct 10, 2023
a3aec8a
[occ] Add batch tx delivery interface (#327)
stevenlanders Oct 10, 2023
0520ced
[occ] MVKV store implementation and tests (#323)
udpatil Oct 10, 2023
0864c32
[occ] Add validation function for transaction state to multiversionst…
udpatil Oct 13, 2023
de92cbc
[occ] Add basic worker task and scheduler shell (#328)
stevenlanders Oct 17, 2023
6406dd9
[occ] Implement iterator for mvkv (#329)
udpatil Oct 17, 2023
f6b0b9f
fix dependency (#334)
udpatil Oct 17, 2023
f3a6cf4
[occ] Iterateset tracking and validation implementation (#337)
udpatil Oct 19, 2023
60b2113
[occ] Add scheduler logic for validation (#336)
stevenlanders Oct 19, 2023
1178e0b
[occ] Fix situation where no stores causes a panic (#338)
stevenlanders Oct 20, 2023
6ec1620
Add occ flag check to context (#340)
stevenlanders Oct 23, 2023
9530aeb
[occ] Add struct field and helpers for estimate prefills (#341)
udpatil Oct 24, 2023
3bdbc96
Fix map access panic (#343)
stevenlanders Oct 30, 2023
954c5a9
Gen estimates writeset (#344)
udpatil Nov 3, 2023
be45bb5
[OCC] Add trace spans to scheduler (#347)
stevenlanders Nov 6, 2023
061ef70
[occ] Fix parent store readset validation (#348)
udpatil Nov 10, 2023
f9541fb
[occ] OCC scheduler and validation fixes (#359)
udpatil Nov 22, 2023
30b7fab
[occ] Add optimizations for multiversion and mvkv (#361)
udpatil Nov 27, 2023
4d12564
[OCC] Add scheduler goroutine pool and optimizations (#362)
stevenlanders Nov 29, 2023
a780a58
update concurrency workers (#380)
udpatil Dec 12, 2023
cb02f7e
[OCC] Fix hang where abort channel blocks iterator (#379)
stevenlanders Dec 13, 2023
fa4b76d
Occ iterator fix (#389)
udpatil Jan 2, 2024
6bf4d72
fix interface
udpatil Jan 2, 2024
6878b96
fix deleteIterateSet and leave some comments (#395)
udpatil Jan 12, 2024
d08b8f0
Occ enabled cfg (#398)
udpatil Jan 18, 2024
75d1151
Remove block gas meter in occ (#407)
udpatil Jan 25, 2024
48dfff5
Relax locking contention (#427)
udpatil Feb 9, 2024
f9805fe
Rebase occ main (#428)
udpatil Feb 9, 2024
6b43421
fix assignment to not cause panic (#429)
udpatil Feb 9, 2024
53e08da
merge v0.2.73-evm-rebase-8
udpatil Feb 9, 2024
36e8aa1
occ-evm compatibility changes
udpatil Jan 8, 2024
41af76d
update generate estimated writeset for evm compatibility
udpatil Jan 9, 2024
8dccecd
use absoluteIndex instead of relative Index for txIndex
udpatil Jan 11, 2024
bccb819
Fix mvkv to adhere to updated KVStore interface
udpatil Jan 25, 2024
e1547ed
update schduler and tests
udpatil Jan 26, 2024
5a05027
[OCC] add metrics for scheduler (#431)
stevenlanders Feb 13, 2024
801b461
[OCC] add metrics for scheduler (#431)
stevenlanders Feb 13, 2024
2f1e3f8
[OCC] perform validateAll after execution (#437)
stevenlanders Feb 15, 2024
f33393c
merge occ-main
stevenlanders Feb 16, 2024
8de9a54
fix test compile
stevenlanders Feb 16, 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
1 change: 1 addition & 0 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 Down
101 changes: 66 additions & 35 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"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 Down Expand Up @@ -69,11 +71,6 @@
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 @@ -205,7 +202,7 @@
// internal CheckTx state if the AnteHandler passes. Otherwise, the ResponseCheckTx
// will contain releveant error information. Regardless of tx execution outcome,
// the ResponseCheckTx will contain relevant gas execution context.
func (app *BaseApp) CheckTx(ctx context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) {
func (app *BaseApp) CheckTx(ctx context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTxV2, error) {
defer telemetry.MeasureSince(time.Now(), "abci", "check_tx")

var mode runTxMode
Expand All @@ -222,25 +219,60 @@
}

sdkCtx := app.getContextForTx(mode, req.Tx)
gInfo, result, _, priority, err := app.runTx(sdkCtx, mode, req.Tx)
tx, err := app.txDecoder(req.Tx)
if err != nil {
res := sdkerrors.ResponseCheckTx(err, 0, 0, app.trace)
return &abci.ResponseCheckTxV2{ResponseCheckTx: &res}, err
}

Check warning on line 226 in baseapp/abci.go

View check run for this annotation

Codecov / codecov/patch

baseapp/abci.go#L224-L226

Added lines #L224 - L226 were not covered by tests
gInfo, result, _, priority, pendingTxChecker, expireTxHandler, txCtx, err := app.runTx(sdkCtx, mode, tx, sha256.Sum256(req.Tx))
if err != nil {
res := sdkerrors.ResponseCheckTx(err, gInfo.GasWanted, gInfo.GasUsed, app.trace)
return &res, err
return &abci.ResponseCheckTxV2{ResponseCheckTx: &res}, err

Check warning on line 230 in baseapp/abci.go

View check run for this annotation

Codecov / codecov/patch

baseapp/abci.go#L230

Added line #L230 was not covered by tests
}

return &abci.ResponseCheckTx{
GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints?
Data: result.Data,
Priority: priority,
}, nil
res := &abci.ResponseCheckTxV2{
ResponseCheckTx: &abci.ResponseCheckTx{
GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints?
Data: result.Data,
Priority: priority,
},
ExpireTxHandler: expireTxHandler,
EVMNonce: txCtx.EVMNonce(),
EVMSenderAddress: txCtx.EVMSenderAddress(),
IsEVM: txCtx.IsEVM(),
}
if pendingTxChecker != nil {
res.IsPendingTransaction = true
res.Checker = pendingTxChecker
}

Check warning on line 247 in baseapp/abci.go

View check run for this annotation

Codecov / codecov/patch

baseapp/abci.go#L245-L247

Added lines #L245 - L247 were not covered by tests

return res, 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.
func (app *BaseApp) DeliverTx(ctx sdk.Context, req abci.RequestDeliverTx) (res abci.ResponseDeliverTx) {
func (app *BaseApp) DeliverTx(ctx sdk.Context, req abci.RequestDeliverTx, tx sdk.Tx, checksum [32]byte) (res abci.ResponseDeliverTx) {
defer telemetry.MeasureSince(time.Now(), "abci", "deliver_tx")
defer func() {
for _, streamingListener := range app.abciListeners {
Expand All @@ -260,7 +292,7 @@
telemetry.SetGauge(float32(gInfo.GasWanted), "tx", "gas", "wanted")
}()

gInfo, result, anteEvents, _, err := app.runTx(ctx.WithTxBytes(req.Tx).WithVoteInfos(app.voteInfos), runTxModeDeliver, req.Tx)
gInfo, result, anteEvents, _, _, _, _, err := app.runTx(ctx.WithTxBytes(req.Tx).WithVoteInfos(app.voteInfos), runTxModeDeliver, tx, checksum)
if err != nil {
resultStr = "failed"
// if we have a result, use those events instead of just the anteEvents
Expand Down Expand Up @@ -1012,29 +1044,36 @@
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}
}
}()

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}
}

Check warning on line 1076 in baseapp/abci.go

View check run for this annotation

Codecov / codecov/patch

baseapp/abci.go#L1065-L1076

Added lines #L1065 - L1076 were not covered by tests
}()

if app.processProposalHandler != nil {
Expand Down Expand Up @@ -1094,22 +1133,14 @@
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
Loading