Skip to content

Risky Time.Now Usage #196

@Hellobloc

Description

@Hellobloc
Introduce

In the following code, the project use Time.now to do some validate process. this validate may perform different in each node which could been called as non_determinism. It will cause the consensus to fail.

if vestingAcc.GetEndTime() > time.Now().UTC().Unix() {
reason = "unexpired vesting account is not suitable for destroying"
return
}
}
if vestingAcc, ok := account.(vesting.VestingAccount); ok {
if vestingAcc.GetEndTime() > time.Now().UTC().Unix() {

Ref

https://github.com/crytic/building-secure-contracts/tree/master/not-so-smart-contracts/cosmos/non_determinism

Recommand

Don't use Time.now in your project

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