-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Adjust actor event API after review #11649
Adjust actor event API after review #11649
Conversation
47548b4
to
ac997e6
Compare
ac997e6
to
90f1988
Compare
538dd6f
to
6a34c7d
Compare
6a34c7d
to
8a3a461
Compare
node/impl/full/actor_events.go
Outdated
} | ||
var buffer []*types.ActorEvent | ||
const α = 0.2 // decay factor for the events per height EMA | ||
var eventsPerHeightEma float64 = 256 // exponential moving average of events per height, initially guess at 256 |
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.
One problem we encounter at this point is if we've spent a lot of time sending historical data and we have a lot of new data backed up and ready to go we may blow our budget (almost) immediately. We could be more forgiving up front (according to what terms? how complicated do we want to get?). Or we could just say "bad luck, you shouldn't have requested so much historical data, use GetActorEvents
for that.
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.
See above. IMO, we wait one block time (30s) then give up.
@Stebalien I'm going to call this one "ready for review", but it's lacking some unit testing for the new stream backlog handling code (and maybe some other minor things). I don't want to invest in figuring out how to build something for that without getting agreement on the approach. |
Alternatively, we can just merge this in to #11618 and go from there. Whatever's easiest to review. |
// If `TipSetCid` is present in the filter criteria, then neither `FromEpoch` nor `ToEpoch` are allowed. | ||
TipSetCid *cid.Cid `json:"tipsetCid,omitempty"` | ||
// If `TipSetKey` is legt empty in the filter criteria, then neither `FromHeight` nor `ToHeight` are allowed. | ||
TipSetKey *TipSetKey `json:"tipsetKey,omitempty"` |
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.
Pointer here may not be idiomatic; I just wanted to avoid an unnecessary []
in the json form, mainly. I think maybe if []
is omitted on the input side that it may still resolve to the zero-value here, I'm not sure.
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.
Pointer is fine. I'm actually kind of surprised we don't marshal these to strings... but ok.
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.
if [] is omitted on the input side that it may still resolve to the zero-value here, I'm not sure.
It will.
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.
Ideally we'd be able to:
- Query for historical events.
- Send them.
- Query for more.
- Send them.
- Etc...
Then, when we're all caught up, we'd subscribe. But that seems like a lot of work. Also, I assume the limits will prevent that from really being an issues (we should never have to send that many events.
// If `TipSetCid` is present in the filter criteria, then neither `FromEpoch` nor `ToEpoch` are allowed. | ||
TipSetCid *cid.Cid `json:"tipsetCid,omitempty"` | ||
// If `TipSetKey` is legt empty in the filter criteria, then neither `FromHeight` nor `ToHeight` are allowed. | ||
TipSetKey *TipSetKey `json:"tipsetKey,omitempty"` |
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.
Pointer is fine. I'm actually kind of surprised we don't marshal these to strings... but ok.
// If `TipSetCid` is present in the filter criteria, then neither `FromEpoch` nor `ToEpoch` are allowed. | ||
TipSetCid *cid.Cid `json:"tipsetCid,omitempty"` | ||
// If `TipSetKey` is legt empty in the filter criteria, then neither `FromHeight` nor `ToHeight` are allowed. | ||
TipSetKey *TipSetKey `json:"tipsetKey,omitempty"` |
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.
if [] is omitted on the input side that it may still resolve to the zero-value here, I'm not sure.
It will.
node/impl/full/actor_events.go
Outdated
ticker := time.NewTicker(time.Second) | ||
defer ticker.Stop() | ||
|
||
const maxSlowTicks = 3 // slightly forgiving, allow 3 slow ticks (seconds) before giving up | ||
slowTicks := 0 | ||
sentEvents := 0.0 |
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.
Given that we're doing a single batch here, there's no need for a ticker. We can just have a global timeout.
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.
(I mean, the right way to handle slow reads is in the JSON-RPC library... anyways)
node/impl/full/actor_events.go
Outdated
} | ||
var buffer []*types.ActorEvent | ||
const α = 0.2 // decay factor for the events per height EMA | ||
var eventsPerHeightEma float64 = 256 // exponential moving average of events per height, initially guess at 256 |
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.
See above. IMO, we wait one block time (30s) then give up.
Use BlockDelay as the window for receiving events on the SubscribeActorEvents channel. We expect the user to have received the initial batch of historical events (if any) in one block's time. For real-time events we expect them to not fall behind by roughly one block's time.
31feee3
to
9fd3e02
Compare
Pretty rough coming up with nice unit tests for In response to last round of feedback we have two things for keeping track of "are you getting the events fast enough":
Basically: don't fall more than ~one block's time behind in receiving your events and you'll be dine. Bunch of related refactorings in the last commit. |
Going to take this back to #11618 and proceed from there |
From review discussions in #11618, WIP
TipSetCid
->TipSetKey
(this is still nillable on the filter because omitempty doesn't play as nice, but should confirm that this is reasonable given existing API precedents)EmitterAddr
->Emitter
Epoch
->Height
FromHeight
andToHeight
take nillableabi.ChainEpoch
s (ints) that must be >= 0 when setPrefill
option inSubscribeActorEvents
API and collapsed the argument structure,FromHeight
will do that work implicitly.nil
forFromHeight
will:GetActorEvents
be interpreted to mean "current epoch"SubscribeActorEvents
will be interpreted to mean "next epoch" (TODO: confirm we want to do this because current impl I think will just do a prefill of current epoch)nil
forToHeight
will:GetActorEvents
be interpreted to mean "current epoch"SubscribeActorEvents
be interpreted to mean that there is no height-based stopping conditionEnableActorEventsAPI
config option has been moved to a newActorEvents
top-level section; could also just beEvents
as per previous discussions?Events
section. (future TODO of moving other events config options into there so it won't be lonely)SubscribeActorEvents
when weToHeight
is set and we have reached that position; currently will just stay open giving you nothing.Add(Discussed here, I'm not sure I see a use for this given the global limit that's in place and the way you can use From and To as a user).Limit
option to the filter to limit the number of epochs to process, counting from whatever the start epoch is calculated to beSubscribeActorEvents
smarter: