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

Respond with latest for pending block number requests #1623

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions go/enclave/components/batch_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,8 @@ func (br *batchRegistry) GetBatchAtHeight(height gethrpc.BlockNumber) (*core.Bat
return nil, fmt.Errorf("could not retrieve genesis rollup. Cause: %w", err)
}
batch = genesisBatch
case gethrpc.PendingBlockNumber:
// todo - depends on the current pending rollup; leaving it for a different iteration as it will need more thought
return nil, fmt.Errorf("requested balance for pending block. This is not handled currently")
case gethrpc.SafeBlockNumber, gethrpc.FinalizedBlockNumber, gethrpc.LatestBlockNumber:
// note: our API currently treats all these block statuses the same for obscuro batches
case gethrpc.SafeBlockNumber, gethrpc.FinalizedBlockNumber, gethrpc.LatestBlockNumber, gethrpc.PendingBlockNumber:
headBatch, err := br.storage.FetchBatchBySeqNo(br.headBatchSeq.Uint64())
if err != nil {
return nil, fmt.Errorf("batch with requested height %d was not found. Cause: %w", height, err)
Expand Down
9 changes: 3 additions & 6 deletions go/host/rpc/clientapi/client_api_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/obscuronet/go-obscuro/go/common"
"github.com/obscuronet/go-obscuro/go/common/errutil"
"github.com/obscuronet/go-obscuro/go/common/host"
"github.com/obscuronet/go-obscuro/go/common/log"
"github.com/obscuronet/go-obscuro/go/responses"
Expand Down Expand Up @@ -207,7 +206,9 @@ type FeeHistoryResult struct {
// Given a batch number, returns the hash of the batch with that number.
func (api *EthereumAPI) batchNumberToBatchHash(batchNumber rpc.BlockNumber) (*gethcommon.Hash, error) {
// Handling the special cases first. No special handling is required for rpc.EarliestBlockNumber.
if batchNumber == rpc.LatestBlockNumber {
// note: our API currently treats all these block statuses the same for obscuro batches
if batchNumber == rpc.LatestBlockNumber || batchNumber == rpc.PendingBlockNumber ||
batchNumber == rpc.FinalizedBlockNumber || batchNumber == rpc.SafeBlockNumber {
batchHeader, err := api.host.DB().GetHeadBatchHeader()
if err != nil {
return nil, err
Expand All @@ -216,10 +217,6 @@ func (api *EthereumAPI) batchNumberToBatchHash(batchNumber rpc.BlockNumber) (*ge
return &batchHash, nil
}

if batchNumber == rpc.PendingBlockNumber {
return nil, errutil.ErrNoImpl
}

batchNumberBig := big.NewInt(batchNumber.Int64())
batchHash, err := api.host.DB().GetBatchHash(batchNumberBig)
if err != nil {
Expand Down
Loading