-
Notifications
You must be signed in to change notification settings - Fork 115
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
Remove stateful block from dsmr and move execute into node #1800
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,9 +99,9 @@ type Node[T Tx] struct { | |
storage *chunkStorage[T] | ||
} | ||
|
||
// NewChunk builds transactions into a Chunk | ||
// BuildChunk builds transactions into a Chunk | ||
// TODO handle frozen sponsor + validator assignments | ||
func (n *Node[T]) NewChunk( | ||
func (n *Node[T]) BuildChunk( | ||
ctx context.Context, | ||
txs []T, | ||
expiry int64, | ||
|
@@ -171,7 +171,7 @@ func (n *Node[T]) NewChunk( | |
return chunk, n.storage.AddLocalChunkWithCert(chunk, &chunkCert) | ||
} | ||
|
||
func (n *Node[T]) NewBlock(parent Block, timestamp int64) (Block, error) { | ||
func (n *Node[T]) BuildBlock(parent Block, timestamp int64) (Block, error) { | ||
if timestamp <= parent.Timestamp { | ||
return Block{}, ErrTimestampNotMonotonicallyIncreasing | ||
} | ||
|
@@ -207,6 +207,19 @@ func (n *Node[T]) NewBlock(parent Block, timestamp int64) (Block, error) { | |
return blk, nil | ||
} | ||
|
||
func (*Node[T]) Execute(ctx context.Context, _ Block, block Block) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was previously called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is meant to be renamed to
|
||
// TODO: Verify header fields | ||
// TODO: de-duplicate chunk certificates (internal to block and across history) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use general validity window to de-duplicate chunk certs |
||
for _, chunkCert := range block.ChunkCerts { | ||
// TODO: verify chunks within a provided context | ||
if err := chunkCert.Verify(ctx, struct{}{}); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (n *Node[T]) Accept(ctx context.Context, block Block) error { | ||
chunkIDs := make([]ids.ID, 0, len(block.ChunkCerts)) | ||
for _, chunkCert := range block.ChunkCerts { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to name this
BuildBlock
we should also renameNewChunk
toBuildChunk
to be consistentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do