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

Use Blob Serialization to Construct Collation Instances #125

Closed
rauljordan opened this issue May 18, 2018 · 1 comment
Closed

Use Blob Serialization to Construct Collation Instances #125

rauljordan opened this issue May 18, 2018 · 1 comment
Labels
Good First Issue Good for newcomers

Comments

@rauljordan
Copy link
Contributor

rauljordan commented May 18, 2018

We can resolve some TODO's by taking advantage of the blob serialization algorithm created in #92 by @nisdas. When creating a new collation object and having access to the collation's byte serialized body, we can deserialize that body into a slice of transactions that we can pass into the NewCollation function.

An example of this is in shard.go, but there are other similar todo's.

// CollationByHash fetches full collation.
func (s *Shard) CollationByHash(headerHash *common.Hash) (*Collation, error) {
	header, err := s.HeaderByHash(headerHash)
	if err != nil {
		return nil, fmt.Errorf("cannot fetch header by hash: %v", err)
	}

	body, err := s.BodyByChunkRoot(header.ChunkRoot())
	if err != nil {
		return nil, fmt.Errorf("cannot fetch body by chunk root: %v", err)
	}
	// TODO: deserializes the body into a txs slice instead of using
	// nil as the third arg to MakeCollation.
	col := NewCollation(header, body, nil)
	return col, nil
}

Another one occurs when saving the collation's body:

// SaveBody adds the collation body to the shardDB and sets availability.
func (s *Shard) SaveBody(body []byte) error {
	// TODO: check if body is empty and throw error.
	// TODO: dependent on blob serialization.
	// right now we will just take the raw keccak256 of the body until #92 is merged.
	chunkRoot := common.BytesToHash(body)
	s.SetAvailability(&chunkRoot, true)
	return s.shardDB.Put(chunkRoot, body)
}
@nisdas
Copy link
Member

nisdas commented May 24, 2018

Assigned to Eli

Collation Proposals automation moved this from To do to Done Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue Good for newcomers
Projects
No open projects
Development

No branches or pull requests

2 participants