Receiving error below when adding events from a timestamp that should be within the allowed timestamp range:
["OK","1fa30db9ed533b4e5934e6f0809f3d8952611db0b8b1acd5838a552894768b40",false,"invalid: event created_at timestamp is out of allowed range"]
Steps to reproduce
Start GRAIN relay
Immediately post an EVENT
EVENT is accepted
Wait 5+ minutes, post another EVENT
EVENT is rejected due to created_at timestamp out of allowed range
Example
GRAIN log
Received message: ["EVENT", {"id": "1fa30db9ed533b4e5934e6f0809f3d8952611db0b8b1acd5838a552894768b40", "pubkey": "4503baa127bdfd0b054384dc5ba82cb0e2a8367cbdb0629179f00db1a34caacc", "kind": 1, "created_at": 1730059414, "tags": [], "content": "test", "sig": "9a7e6c2f15e172855cbb7fabd8fbfb00013a267e3fea77ec1623141870349be4cd0071f82ebed3c0ff5448231a8cb5bb892e0008d5ea75b623feda718e9a253c"}]
Event 1fa30db9ed533b4e5934e6f0809f3d8952611db0b8b1acd5838a552894768b40 created_at timestamp 1730059414 is out of range [1577836800, 1730058724]
OK note returned to client
nostpy-cli send_event -privkey <REDACTED> -kind 1 -content "test" --relay ws://localhost:8181
Verification successful for event: 1fa30db9ed533b4e5934e6f0809f3d8952611db0b8b1acd5838a552894768b40
Sending event:
('EVENT', {'id': '1fa30db9ed533b4e5934e6f0809f3d8952611db0b8b1acd5838a552894768b40', 'pubkey': '4503baa127bdfd0b054384dc5ba82cb0e2a8367cbdb0629179f00db1a34caacc', 'kind': 1, 'created_at': 1730059414, 'tags': [], 'content': 'test', 'sig': '9a7e6c2f15e172855cbb7fabd8fbfb00013a267e3fea77ec1623141870349be4cd0071f82ebed3c0ff5448231a8cb5bb892e0008d5ea75b623feda718e9a253c'})
to ws://localhost:8181
Response from ws://localhost:8181 is :
["OK","1fa30db9ed533b4e5934e6f0809f3d8952611db0b8b1acd5838a552894768b40",false,"invalid: event created_at timestamp is out of allowed range"]
Observations
It looks like the function below is setting the value of cfg.EventTimeConstraints.MaxCreatedAt to 5 minutes ahead of now.Unix() but that value is stuck at 5 minutes ahead of the relay start time.
// Adjust max_created_at based on string value or default to current time
if strings.HasPrefix(cfg.EventTimeConstraints.MaxCreatedAtString, "now") {
offset := strings.TrimPrefix(cfg.EventTimeConstraints.MaxCreatedAtString, "now")
fmt.Printf("Offset is: %s", offset)
duration, err := time.ParseDuration(offset)
if err != nil {
fmt.Printf("Invalid time offset for max_created_at: %s\n", offset)
cfg.EventTimeConstraints.MaxCreatedAt = now.Unix() // Default to now if parsing fails
} else {
cfg.EventTimeConstraints.MaxCreatedAt = now.Add(duration).Unix()
}
} else if cfg.EventTimeConstraints.MaxCreatedAt == 0 {
// Default to the current time if it's set to zero and no "now" keyword is used
cfg.EventTimeConstraints.MaxCreatedAt = now.Unix()
}
}
What happened
Receiving error below when adding events from a timestamp that should be within the allowed timestamp range:
Steps to reproduce
EVENT
EVENT
is acceptedEVENT
EVENT
is rejected due tocreated_at
timestamp out of allowed rangeExample
GRAIN log
OK note returned to client
Observations
It looks like the function below is setting the value of
cfg.EventTimeConstraints.MaxCreatedAt
to 5 minutes ahead ofnow.Unix()
but that value is stuck at 5 minutes ahead of the relay start time.Example
maxCreatedAt
remains at1730061143