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

Create a blob verification utility #1066

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

litt3
Copy link
Contributor

@litt3 litt3 commented Jan 6, 2025

Why are these changes needed?

  • This verification utility is needed for the v2 client

Notes

  • I made the decision to not add the verification contract logic into the existing reader.go, since doing so would cause a cascade of changes in unrelated files
    • IMO, I don't see the advantage of piling all of this stuff into a single class, when the only thing shared is the eth client

Checks

  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • I've checked the new test coverage and the coverage percentage didn't drop.
  • Testing Strategy: This verification utility cannot be meaningfully unit tested. E2E integration tests will be created in a future PR.

litt3 added 2 commits January 3, 2025 17:10
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
@litt3 litt3 self-assigned this Jan 6, 2025
litt3 added 8 commits January 6, 2025 13:18
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
@litt3 litt3 marked this pull request as ready for review January 7, 2025 15:53
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
@litt3 litt3 requested review from cody-littley and anupsv January 7, 2025 16:43
gethcommon "github.com/ethereum/go-ethereum/common"
)

// BlobVerifier is responsible for making eth calls to verify blobs that have been received by the client
Copy link

Choose a reason for hiding this comment

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

knit

Suggested change
// BlobVerifier is responsible for making eth calls to verify blobs that have been received by the client
// BlobVerifier is responsible for making eth calls against the BlobVerifier contract to ensure cryptographic and structural integrity of V2 certificates

Copy link
Contributor Author

Choose a reason for hiding this comment

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


// BlobVerifier is responsible for making eth calls to verify blobs that have been received by the client
type BlobVerifier struct {
// go binding around the verifyBlobV2FromSignedBatch ethereum contract
Copy link

Choose a reason for hiding this comment

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

isn't the contract name BlobVerifier?

Copy link
Contributor Author

@litt3 litt3 Jan 7, 2025

Choose a reason for hiding this comment

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

It's EigenDABlobVerifier. Fixed in ca8d9d74

// NewBlobVerifier constructs a BlobVerifier
func NewBlobVerifier(
ethClient *common.EthClient, // the eth client, which should already be set up
verifyBlobV2FromSignedBatchAddress string, // the hex address of the verifyBlobV2FromSignedBatch contract
Copy link

Choose a reason for hiding this comment

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

knit - why not just blobVerifierAddress?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

}

err = v.blobVerifierCaller.VerifyBlobV2FromSignedBatch(
&bind.CallOpts{Context: ctx},
Copy link

Choose a reason for hiding this comment

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

knit - is there any utility in allowing a configurable user timeout for simulation calls?

Copy link

Choose a reason for hiding this comment

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

if there's not a default timeout used by the binding wrapper then we may wanna instate given this could result in the connection infinitely hanging

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment clarifying that the caller is responsible for any timeout c752e5b1

}, nil
}

// VerifyBlobV2FromSignedBatch makes a call to the verifyBlobV2FromSignedBatch contract
Copy link

Choose a reason for hiding this comment

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

verifyBlobV2FromSignedBatch contract?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed terminology ca8d9d74

Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
litt3 added 2 commits January 7, 2025 16:05
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
@litt3 litt3 requested a review from epociask January 7, 2025 21:48
Copy link
Contributor

@samlaf samlaf left a comment

Choose a reason for hiding this comment

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

@litt3 you must be a masochist asking for so many people to review your PR. As the saying goes: 10 line PR = 10 comments. 1000 line PR = LGTM. So here's my 2 comments :D

gethcommon "github.com/ethereum/go-ethereum/common"
)

// BlobVerifier is responsible for making eth calls against the BlobVerifier contract to ensure cryptographic and
Copy link
Contributor

Choose a reason for hiding this comment

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

add link to BlobVerifier contract?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean like this? I don't like that this sort of link is instantly out of date, but I don't know of a better way to link here

function verifyBlobV2FromSignedBatch(

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes did mean like this. We can also just link to the contract itself, in the master branch, so that it doesn't get out of date instantly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added 8bba429a

api/clients/v2/verification/blob_verifier.go Show resolved Hide resolved
api/clients/v2/verification/blob_verifier.go Show resolved Hide resolved

func bytesToBN254G2Point(bytes []byte) (*BN254G2Point, error) {
var g2Point bn254.G2Affine
_, err := g2Point.SetBytes(bytes)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a comment to say, this makes sure bytes is in the subgroup
https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254#G2Affine.SetBytes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done f31e4a6b

@bxue-l2
Copy link
Contributor

bxue-l2 commented Jan 8, 2025

One thing that looks missing to me is the test. Though it looks difficult to test, unless we can mock the eth call, and prepare all the consistent data

@litt3
Copy link
Contributor Author

litt3 commented Jan 8, 2025

@litt3 you must be a masochist asking for so many people to review your PR. As the saying goes: 10 line PR = 10 comments. 1000 line PR = LGTM. So here's my 2 comments :D

@samlaf Unfortunately github has no concept of "optional reviewer"... better lots of comments now than lots of bugs tomorrow

@litt3
Copy link
Contributor Author

litt3 commented Jan 8, 2025

One thing that looks missing to me is the test. Though it looks difficult to test, unless we can mock the eth call, and prepare all the consistent data

@bxue-l2 I considered mocking the eth call, but it would be a lot of boilerplate to really only test the simple logic of whether errors are returned. This seems to fall into the "99% coverage" bucket.

I wouldn't have a problem with a 99% coverage policy, if that's what we want to go for across the board. Thoughts?

litt3 added 2 commits January 8, 2025 09:44
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
@bxue-l2
Copy link
Contributor

bxue-l2 commented Jan 8, 2025

One thing that looks missing to me is the test. Though it looks difficult to test, unless we can mock the eth call, and prepare all the consistent data

@bxue-l2 I considered mocking the eth call, but it would be a lot of boilerplate to really only test the simple logic of whether errors are returned. This seems to fall into the "99% coverage" bucket.

I wouldn't have a problem with a 99% coverage policy, if that's what we want to go for across the board. Thoughts?

Got it, I am not trying to impose a high coverage policy, The code looks good to me.

@litt3 litt3 requested a review from samlaf January 8, 2025 19:48
}

var x, y [2]*big.Int
x[0] = g2Point.X.A0.BigInt(new(big.Int))
Copy link
Contributor

@ian-shim ian-shim Jan 8, 2025

Choose a reason for hiding this comment

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

Has this been tested?
I'm pretty sure the ordering should be reversed, i.e. X = {X.A1, X.A0}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has this been tested?

Not yet, integration tests are forthcoming

Good catch, thank you. Fixed

litt3 added 3 commits January 9, 2025 11:00
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants