Skip to content

SDK Gotcha Doc #13171

Open
Open
@AdityaSripal

Description

It would be nice to have a single place to collate all gotchas on the SDK/blockchain development in general. There are plenty of hard-learned lessons that every SDK veteran goes through and learns, but afaik we don't have a single place for beginners to look through them and quickly avoid common mistakes.

I think it would be nice to have a running document where we can add any common mistakes and how to avoid them so new people don't have to make the same ones over and over again.

I think there should be the general rule/guidelines and an explanation of why the rule exists.

Examples:

  1. Do not use randomness within the state machine
    Rationale: Any randomness will cause different nodes on the same network to arrive at different results leading to network divergence. The state machine output must be completely deterministic given the same list of state transitions (transactions).

  2. Do not use time.Now(), use ctx.BlockTime() instead
    Rationale: time.Now() will be different on each node which will again lead to divergence. The context has a time that has been agreed upon by the validator set that you can use within the state machine safely: ctx.BlockTime()

Perhaps, such a thing already exists! Please point me to it and close this issue if so

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    T: Dev UXUX for SDK developers (i.e. how to call our code)T:DocsChanges and features related to documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions