From 211935ae0fe0c7fc98004375e931530ba7a7ef7a Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Thu, 6 Jun 2024 12:57:26 -0400 Subject: [PATCH] feat: Verify commitment after put --- .github/workflows/actions.yml | 20 ++++++++++++++++++++ store/eigenda.go | 22 ++++++++++++++++++++-- test/e2e_test.go | 8 ++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 20ab9ee..2c5da4d 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -53,3 +53,23 @@ jobs: uses: securego/gosec@master with: args: ./... + + e2e-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.21 + + - name: Install project dependencies + run: | + go mod download + + - name: Run E2E Tests + env: + SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }} + run: | + SIGNER_PRIVATE_KEY=$SIGNER_PRIVATE_KEY make e2e-test \ No newline at end of file diff --git a/store/eigenda.go b/store/eigenda.go index f2632f9..f2e71c5 100644 --- a/store/eigenda.go +++ b/store/eigenda.go @@ -53,12 +53,30 @@ func (e EigenDAStore) Get(ctx context.Context, key []byte) ([]byte, error) { // Put disperses a blob for some pre-image and returns the associated RLP encoded certificate commit. func (e EigenDAStore) Put(ctx context.Context, value []byte) (comm []byte, err error) { - cert, err := e.client.PutBlob(ctx, value) + daCert, err := e.client.PutBlob(ctx, value) if err != nil { return nil, err } - bytes, err := rlp.EncodeToBytes(cert) + qids := make([]uint32, len(daCert.BlobVerificationProof.QuorumIndexes)) + for i, qid := range daCert.BlobVerificationProof.QuorumIndexes { + qids[i] = uint32(qid) + } + + proxyCert := eigenda.Cert{ + BatchHeaderHash: daCert.BlobVerificationProof.BatchMetadata.BatchHeaderHash, + BlobIndex: daCert.BlobVerificationProof.BlobIndex, + ReferenceBlockNumber: daCert.BlobVerificationProof.BatchMetadata.ConfirmationBlockNumber, + QuorumIDs: qids, + BlobCommitment: daCert.BlobHeader.Commitment, + } + + err = e.verifier.Verify(proxyCert, value) + if err != nil { + return nil, err + } + + bytes, err := rlp.EncodeToBytes(proxyCert) if err != nil { return nil, fmt.Errorf("failed to encode DA cert to RLP format: %w", err) } diff --git a/test/e2e_test.go b/test/e2e_test.go index 568726b..a3fd7ed 100644 --- a/test/e2e_test.go +++ b/test/e2e_test.go @@ -32,6 +32,7 @@ func init() { // Use of single port makes tests incapable of running in parallel const ( + privateKey = "SIGNER_PRIVATE_KEY" transport = "http" serviceName = "eigenda_proxy" host = "127.0.0.1" @@ -48,6 +49,12 @@ type TestSuite struct { func createTestSuite(t *testing.T) (TestSuite, func()) { ctx := context.Background() + // load signer key from environment + pk := os.Getenv(privateKey) + if pk == "" { + t.Fatal("SIGNER_PRIVATE_KEY environment variable not set") + } + log := oplog.NewLogger(os.Stdout, oplog.CLIConfig{ Level: log.LevelDebug, Format: oplog.FormatLogFmt, @@ -62,6 +69,7 @@ func createTestSuite(t *testing.T) (TestSuite, func()) { StatusQueryTimeout: time.Minute * 45, StatusQueryRetryInterval: time.Second * 1, DisableTLS: false, + SignerPrivateKeyHex: pk, }, }