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

[api] eth_getBlobSidecar #4371

Merged
merged 5 commits into from
Sep 23, 2024
Merged

[api] eth_getBlobSidecar #4371

merged 5 commits into from
Sep 23, 2024

Conversation

envestcc
Copy link
Member

Description

introduce new api eth_getBlobSidecars to return blobs in a block.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

Copy link

sonarcloud bot commented Aug 22, 2024

return res, nil
}

func (core *coreService) getBlobSidecars(height uint64) (blobs []any, txIndexes []uint64, txHashes []hash.Hash256) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this func should only return blobs
txIndexes, txHashes should come from core's other API funcs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also txIndexes --> txIndices

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@envestcc envestcc marked this pull request as ready for review September 19, 2024 13:32
@envestcc envestcc requested review from CoderZhi, Liuhaai and a team as code owners September 19, 2024 13:32
@@ -1213,6 +1217,58 @@ func (core *coreService) getBlockByHeight(height uint64) (*apitypes.BlockWithRec
}, nil
}

func (core *coreService) BlobSidecarsByHeight(height uint64) ([]*apitypes.BlobSidecarResult, error) {
header, err := core.bc.BlockHeaderByHeight(height)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to L1238

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

txIndices = append(txIndices, uint64(index))
}
blkHash := header.HashBlock()
for i, blob := range blobs {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move L1232 to here, get the index and use it at L1244, then we don't need to define txIndices?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

res = append(res, &apitypes.BlobSidecarResult{
BlobSidecar: blob,
BlockNumber: height,
BlockHash: common.BytesToHash(blkHash[:]),
Copy link
Member

@dustinxie dustinxie Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BlockNumber, BlockHash is common for all tx, only need 1 copy, i mean like below?

apitypes.BlobSidecarResult {
    BlockNumber
    BlockHash
    [] struct {
        blobSidecar
        txIndex
        txHash
    }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just keep same as bsc. IMO, this design is to use same structure for getSidercarByBlock and getSidercarByTx

case nil:
return res, nil
case ErrNotFound:
return nil, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ErrNotFound should return nil to caller?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, just like getBlock and getTransaction

BlockNumber: height,
BlockHash: common.BytesToHash(blkHash[:]),
TxIndex: uint64(index),
TxHash: common.BytesToHash(txHashes[i][:]),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the conversion in line 1230 and save them in local variables.

Copy link

sonarcloud bot commented Sep 23, 2024

@envestcc envestcc merged commit 0dec7d5 into iotexproject:master Sep 23, 2024
3 checks passed
@envestcc envestcc deleted the eth_getblob branch September 23, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants