Skip to content

Commit

Permalink
feat: Verify commitment after put
Browse files Browse the repository at this point in the history
  • Loading branch information
epociask committed Jun 6, 2024
1 parent c8b5c14 commit 211935a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 20 additions & 2 deletions store/eigenda.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 8 additions & 0 deletions test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -62,6 +69,7 @@ func createTestSuite(t *testing.T) (TestSuite, func()) {
StatusQueryTimeout: time.Minute * 45,
StatusQueryRetryInterval: time.Second * 1,
DisableTLS: false,
SignerPrivateKeyHex: pk,
},
}

Expand Down

0 comments on commit 211935a

Please sign in to comment.