-
Notifications
You must be signed in to change notification settings - Fork 3
feat: use datastore directly for state store #66
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
Changes from 1 commit
afa7904
847ab68
f6f33b7
719b785
5179a57
b170ffa
9823886
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,6 +15,7 @@ import ( | |||||||||||||||||||||||
cmtypes "github.com/cometbft/cometbft/types" | ||||||||||||||||||||||||
servertypes "github.com/cosmos/cosmos-sdk/server/types" | ||||||||||||||||||||||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" | ||||||||||||||||||||||||
ds "github.com/ipfs/go-datastore" | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
"github.com/rollkit/rollkit/core/execution" | ||||||||||||||||||||||||
rollkitp2p "github.com/rollkit/rollkit/pkg/p2p" | ||||||||||||||||||||||||
|
@@ -37,10 +38,11 @@ func LoadGenesisDoc(cfg *config.Config) (*cmtypes.GenesisDoc, error) { | |||||||||||||||||||||||
|
||||||||||||||||||||||||
// Adapter is a struct that will contain an ABCI Application, and will implement the go-execution interface | ||||||||||||||||||||||||
type Adapter struct { | ||||||||||||||||||||||||
App servertypes.ABCI | ||||||||||||||||||||||||
Store store.Store | ||||||||||||||||||||||||
Mempool mempool.Mempool | ||||||||||||||||||||||||
MempoolIDs *mempoolIDs | ||||||||||||||||||||||||
App servertypes.ABCI | ||||||||||||||||||||||||
Store ds.Batching | ||||||||||||||||||||||||
RollkitStore store.Store | ||||||||||||||||||||||||
Mempool mempool.Mempool | ||||||||||||||||||||||||
MempoolIDs *mempoolIDs | ||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
P2PClient *rollkitp2p.Client | ||||||||||||||||||||||||
TxGossiper *p2p.Gossiper | ||||||||||||||||||||||||
|
@@ -58,7 +60,7 @@ type Adapter struct { | |||||||||||||||||||||||
// The Adapter wraps the provided ABCI application and delegates execution-related operations to it. | ||||||||||||||||||||||||
func NewABCIExecutor( | ||||||||||||||||||||||||
app servertypes.ABCI, | ||||||||||||||||||||||||
store store.Store, | ||||||||||||||||||||||||
store ds.Batching, | ||||||||||||||||||||||||
p2pClient *rollkitp2p.Client, | ||||||||||||||||||||||||
p2pMetrics *rollkitp2p.Metrics, | ||||||||||||||||||||||||
logger log.Logger, | ||||||||||||||||||||||||
|
@@ -391,7 +393,7 @@ func (a *Adapter) GetTxs(ctx context.Context) ([][]byte, error) { | |||||||||||||||||||||||
txsBytes[i] = tx | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
currentHeight, err := a.Store.Height(ctx) | ||||||||||||||||||||||||
currentHeight, err := a.RollkitStore.Height(ctx) | ||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||
return nil, err | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
Comment on lines
+402
to
405
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard against nil Even with the constructor fix, defensive code is advisable: - currentHeight, err := a.RollkitStore.Height(ctx)
+ if a.RollkitStore == nil {
+ return nil, fmt.Errorf("RollkitStore not initialised")
+ }
+ currentHeight, err := a.RollkitStore.Height(ctx) 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
|
@@ -417,7 +419,7 @@ func (a *Adapter) SetFinal(ctx context.Context, blockHeight uint64) error { | |||||||||||||||||||||||
return nil | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
func NewAdapter(store store.Store) *Adapter { | ||||||||||||||||||||||||
func NewAdapter(store ds.Batching) *Adapter { | ||||||||||||||||||||||||
return &Adapter{ | ||||||||||||||||||||||||
Store: store, | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personal preference: this is not used somewhere else and can be private
not sure if this is the same idea as @tac0turtle mentioned below but if you would replace batch with a custom state store type, you could encapsulate load/store and avoid the verbose db type.
This may even enable features like caching in the future