-
Notifications
You must be signed in to change notification settings - Fork 123
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
Bloch hash generation by merkle trie root of transactions, results and state root #689
base: main
Are you sure you want to change the base?
Conversation
New root generation with stateless merkledb was updated. One thing I'm not sure that will the |
The root generation has been made into a function, I put it under |
could you move it to its own package called |
utils/utils.go
Outdated
@@ -116,3 +122,43 @@ func LoadBytes(filename string, expectedSize int) ([]byte, error) { | |||
} | |||
return bytes, nil | |||
} | |||
|
|||
// Generate merkle root for a set of items | |||
func GenerateMerkleRoot(ctx context.Context, tracer trace.Tracer, merkleItems [][]byte, consumeBytes bool) ([]byte, merkledb.MerkleDB, error) { |
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.
❤️
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.
@dboehm-avalabs it would be great if you could confirm correctness here.
chain/block.go
Outdated
// transaction hash generation | ||
merkleItems := make([][]byte, 0, len(b.Txs)+len(b.results)) | ||
for _, tx := range b.Txs { | ||
merkleItems = append(merkleItems, tx.Bytes()) |
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.
Would it make sense to use txID
as key and then put something useful in the value?
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.
will the same type of transactions have distinct id for different actors? nor there will be collision
Root generation function has been moved to |
This PR has become stale because it has been open for 30 days with no activity. Adding the |
Having the transaction hashes concatenated with the transaction results doesn't look very idiomatic to me, and at the same time if we provide results in a flat data structure then it will do a collision. Do we really need to be able to prove that the result of a transaction given the current state is correct using the merkle tree ? If it's something that people really want to do, then they could execute the transactions in the block sequentially to find that their execution results matches the one stored in the block. |
I agree with that, and especially currently I see the transaction results won't get stored locally so when do hashing it's better without concatenating result along with the tx. |
This PR has become stale because it has been open for 30 days with no activity. Adding the |
Context
This PR covers #412 and #503, the goal is to generate block hash Based on Hash Trie of Transactions + State Root + Results Root + Warp Outputs Root . Several things aren't clear to me
builder.go
that seems the outputs from warp messages are results of transactions ifwarpMessage
field is not nil of a transactionTrieItems
or we hash the transactions/results and letting theTrieItem.x
to be the hash of each item then double hashing won't be needed.Testing
e2e tests under morpheusvm and tokenvm are passed
Dependencies
The merkletrie implementation borrowed from cbergoon/merkletree, which is a pure implementation so no more dependencies are introduced except itself