Skip to content

Commit

Permalink
refactor: happy path for EspressoReader.readEspresso
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiooshiro committed Feb 27, 2025
1 parent c449ca5 commit 9374914
Show file tree
Hide file tree
Showing 3 changed files with 421 additions and 2 deletions.
8 changes: 8 additions & 0 deletions DEV2DEV.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Dev 2 Dev

## Run just one test

```sh
watchexec --exts go --watch . 'go test -p 1 ./... -testify.m ^TestReadEspresso$'
```

## Run all integrated

Run the database

```sh
Expand Down
17 changes: 15 additions & 2 deletions internal/espressoreader/espresso_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,26 @@ import (
"github.com/cartesi/rollups-espresso-reader/internal/services/retry"

"github.com/EspressoSystems/espresso-sequencer-go/client"
"github.com/EspressoSystems/espresso-sequencer-go/types"
espresso "github.com/EspressoSystems/espresso-sequencer-go/types/common"
"github.com/ethereum/go-ethereum/common"
"github.com/tidwall/gjson"
)

type EspressoClient interface {
FetchVidCommonByHeight(ctx context.Context, blockHeight uint64) (espresso.VidCommon, error)
FetchLatestBlockHeight(ctx context.Context) (uint64, error)
FetchHeaderByHeight(ctx context.Context, blockHeight uint64) (types.HeaderImpl, error)
FetchHeadersByRange(ctx context.Context, from uint64, until uint64) ([]types.HeaderImpl, error)
FetchTransactionByHash(ctx context.Context, hash *types.TaggedBase64) (types.TransactionQueryData, error)
FetchBlockMerkleProof(ctx context.Context, rootHeight uint64, hotshotHeight uint64) (types.HotShotBlockMerkleProof, error)
FetchTransactionsInBlock(ctx context.Context, blockHeight uint64, namespace uint64) (client.TransactionsInBlock, error)
SubmitTransaction(ctx context.Context, tx types.Transaction) (*types.TaggedBase64, error)
}

type EspressoReader struct {
url string
client client.Client
client EspressoClient
startingBlock uint64
namespace uint64
repository repository.Repository
Expand All @@ -44,7 +57,7 @@ type EspressoReader struct {

func NewEspressoReader(url string, startingBlock uint64, namespace uint64, repository repository.Repository, evmReader *evmreader.EvmReader, chainId uint64, inputBoxDeploymentBlock uint64, maxRetries uint64, maxDelay uint64) EspressoReader {
client := client.NewClient(url)
return EspressoReader{url: url, client: *client, startingBlock: startingBlock, namespace: namespace, repository: repository, evmReader: evmReader, chainId: chainId, inputBoxDeploymentBlock: inputBoxDeploymentBlock, maxRetries: maxRetries, maxDelay: maxDelay}
return EspressoReader{url: url, client: client, startingBlock: startingBlock, namespace: namespace, repository: repository, evmReader: evmReader, chainId: chainId, inputBoxDeploymentBlock: inputBoxDeploymentBlock, maxRetries: maxRetries, maxDelay: maxDelay}
}

func (e *EspressoReader) Run(ctx context.Context, ready chan<- struct{}) error {
Expand Down
Loading

0 comments on commit 9374914

Please sign in to comment.