Skip to content

Don't allow setting arbitrary PrevID for records #525

@merlinran

Description

@merlinran

Currently adding an arbitrary record is allowed (https://pkg.go.dev/github.com/textileio/go-threads@v1.0.2#readme-adding-a-thread-record) so I made the mistake of creating records using other logs' records as Prev in the testground test, and alas, the test passes sometimes, but causes all these problems of lock contention etc. So after clarifying w/ @sanderpick and @carsonfarmer it's pretty clear that when creating, a new record should only set the current log head as its Prev, because a log is just a chain of records created by the log's owner.

The simplest would be to remove the Prev field in the cbor.CreateRecordConfig, or, to avoid compatibility issues, override it and print a warning if it doesn't equal to the current head. In later stage we could probably have a better API which can get rid of AddRecord altogether.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions