-
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.
* Add ePBS to db
- Loading branch information
Showing
30 changed files
with
4,218 additions
and
458 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
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" | ||
) | ||
|
||
// SaveBlindPayloadEnvelope saves a signed execution payload envelope blind in the database. | ||
func (s *Store) SaveBlindPayloadEnvelope(ctx context.Context, env *ethpb.SignedBlindPayloadEnvelope) error { | ||
ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveBlindPayloadEnvelope") | ||
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 | ||
} | ||
|
||
// SignedBlindPayloadEnvelope retrieves a signed execution payload envelope blind from the database. | ||
func (s *Store) SignedBlindPayloadEnvelope(ctx context.Context, blockRoot []byte) (*ethpb.SignedBlindPayloadEnvelope, error) { | ||
ctx, span := trace.StartSpan(ctx, "BeaconDB.SignedBlindPayloadEnvelope") | ||
defer span.End() | ||
|
||
env := ðpb.SignedBlindPayloadEnvelope{} | ||
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_SignedBlindPayloadEnvelope(t *testing.T) { | ||
db := setupDB(t) | ||
ctx := context.Background() | ||
_, err := db.SignedBlindPayloadEnvelope(ctx, []byte("test")) | ||
require.ErrorIs(t, err, ErrNotFound) | ||
|
||
env := random.SignedBlindPayloadEnvelope(t) | ||
err = db.SaveBlindPayloadEnvelope(ctx, env) | ||
require.NoError(t, err) | ||
got, err := db.SignedBlindPayloadEnvelope(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.