Skip to content

Commit

Permalink
Respond with latest for pending block number requests
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel committed Oct 25, 2023
1 parent 563c567 commit 064c0e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
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

0 comments on commit 064c0e0

Please sign in to comment.