-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7cf1a6
commit b028d0c
Showing
22 changed files
with
2,256 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package kv | ||
|
||
import ( | ||
"context" | ||
|
||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" | ||
bolt "go.etcd.io/bbolt" | ||
"go.opencensus.io/trace" | ||
) | ||
|
||
// SaveSignedExecutionPayloadEnvelopeBlind saves a signed execution payload envelope blind in the database. | ||
func (s *Store) SaveSignedExecutionPayloadEnvelopeBlind(ctx context.Context, env *ethpb.SignedExecutionPayloadEnvelopeBlind) error { | ||
ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveSignedExecutionPayloadEnvelopeBlind") | ||
defer span.End() | ||
|
||
enc, err := encode(ctx, env) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
r := env.Message.BeaconBlockRoot | ||
err = s.db.Update(func(tx *bolt.Tx) error { | ||
bucket := tx.Bucket(executionPayloadEnvelopeBucket) | ||
return bucket.Put(r, enc) | ||
}) | ||
|
||
return err | ||
} | ||
|
||
// SignedExecutionPayloadEnvelopeBlind retrieves a signed execution payload envelope blind from the database. | ||
func (s *Store) SignedExecutionPayloadEnvelopeBlind(ctx context.Context, blockRoot []byte) (*ethpb.SignedExecutionPayloadEnvelopeBlind, error) { | ||
ctx, span := trace.StartSpan(ctx, "BeaconDB.SignedExecutionPayloadEnvelopeBlind") | ||
defer span.End() | ||
|
||
env := ðpb.SignedExecutionPayloadEnvelopeBlind{} | ||
err := s.db.View(func(tx *bolt.Tx) error { | ||
bkt := tx.Bucket(executionPayloadEnvelopeBucket) | ||
enc := bkt.Get(blockRoot) | ||
if enc == nil { | ||
return ErrNotFound | ||
} | ||
return decode(ctx, enc, env) | ||
}) | ||
return env, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package kv | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/testing/require" | ||
"github.com/prysmaticlabs/prysm/v5/testing/util/random" | ||
) | ||
|
||
func TestStore_SignedExecutionPayloadEnvelopeBlind(t *testing.T) { | ||
db := setupDB(t) | ||
ctx := context.Background() | ||
_, err := db.SignedExecutionPayloadEnvelopeBlind(ctx, []byte("test")) | ||
require.ErrorIs(t, err, ErrNotFound) | ||
|
||
env := random.SignedExecutionPayloadEnvelopeBlind(t) | ||
err = db.SaveSignedExecutionPayloadEnvelopeBlind(ctx, env) | ||
require.NoError(t, err) | ||
got, err := db.SignedExecutionPayloadEnvelopeBlind(ctx, env.Message.BeaconBlockRoot) | ||
require.NoError(t, err) | ||
require.DeepEqual(t, got, env) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.