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

feat: Verify commitment after put #26

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading