events: Fix called with confidence on null round
This commit is contained in:
parent
e5a0252126
commit
1ade0e7b92
@ -142,6 +142,8 @@ func (e *Events) listenHeadChangesOnce(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
e.readyOnce.Do(func() {
|
e.readyOnce.Do(func() {
|
||||||
|
e.at = cur[0].Val.Height()
|
||||||
|
|
||||||
e.ready.Done()
|
e.ready.Done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ type calledEvents struct {
|
|||||||
ctx context.Context
|
ctx context.Context
|
||||||
gcConfidence uint64
|
gcConfidence uint64
|
||||||
|
|
||||||
|
at abi.ChainEpoch
|
||||||
|
|
||||||
lk sync.Mutex
|
lk sync.Mutex
|
||||||
|
|
||||||
ctr triggerId
|
ctr triggerId
|
||||||
@ -83,15 +85,17 @@ type calledEvents struct {
|
|||||||
func (e *calledEvents) headChangeCalled(rev, app []*types.TipSet) error {
|
func (e *calledEvents) headChangeCalled(rev, app []*types.TipSet) error {
|
||||||
for _, ts := range rev {
|
for _, ts := range rev {
|
||||||
e.handleReverts(ts)
|
e.handleReverts(ts)
|
||||||
|
e.at = ts.Height()
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ts := range app {
|
for _, ts := range app {
|
||||||
// called triggers
|
// called triggers
|
||||||
|
|
||||||
e.checkNewCalls(ts)
|
e.checkNewCalls(ts)
|
||||||
e.applyWithConfidence(ts)
|
for ; e.at <= ts.Height(); e.at++ {
|
||||||
|
e.applyWithConfidence(ts, e.at)
|
||||||
e.applyTimeouts(ts)
|
e.applyTimeouts(ts)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -170,8 +174,8 @@ func (e *calledEvents) queueForConfidence(triggerId uint64, msg *types.Message,
|
|||||||
e.revertQueue[appliedH] = append(e.revertQueue[appliedH], triggerH)
|
e.revertQueue[appliedH] = append(e.revertQueue[appliedH], triggerH)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *calledEvents) applyWithConfidence(ts *types.TipSet) {
|
func (e *calledEvents) applyWithConfidence(ts *types.TipSet, height abi.ChainEpoch) {
|
||||||
byOrigH, ok := e.confQueue[ts.Height()]
|
byOrigH, ok := e.confQueue[height]
|
||||||
if !ok {
|
if !ok {
|
||||||
return // no triggers at thin height
|
return // no triggers at thin height
|
||||||
}
|
}
|
||||||
@ -179,7 +183,7 @@ func (e *calledEvents) applyWithConfidence(ts *types.TipSet) {
|
|||||||
for origH, events := range byOrigH {
|
for origH, events := range byOrigH {
|
||||||
triggerTs, err := e.tsc.get(origH)
|
triggerTs, err := e.tsc.get(origH)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("events: applyWithConfidence didn't find tipset for event; wanted %d; current %d", origH, ts.Height())
|
log.Errorf("events: applyWithConfidence didn't find tipset for event; wanted %d; current %d", origH, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, event := range events {
|
for _, event := range events {
|
||||||
@ -198,9 +202,9 @@ func (e *calledEvents) applyWithConfidence(ts *types.TipSet) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
more, err := trigger.handle(event.msg, rec, triggerTs, ts.Height())
|
more, err := trigger.handle(event.msg, rec, triggerTs, height)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("chain trigger (call %s.%d() @H %d, called @ %d) failed: %s", event.msg.To, event.msg.Method, origH, ts.Height(), err)
|
log.Errorf("chain trigger (call %s.%d() @H %d, called @ %d) failed: %s", event.msg.To, event.msg.Method, origH, height, err)
|
||||||
continue // don't revert failed calls
|
continue // don't revert failed calls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -942,4 +942,10 @@ func TestCalledNull(t *testing.T) {
|
|||||||
|
|
||||||
require.Equal(t, true, applied)
|
require.Equal(t, true, applied)
|
||||||
require.Equal(t, false, reverted)
|
require.Equal(t, false, reverted)
|
||||||
|
applied = false
|
||||||
|
|
||||||
|
fcs.advance(5, 1, nil, 10)
|
||||||
|
|
||||||
|
require.Equal(t, false, applied)
|
||||||
|
require.Equal(t, true, reverted)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user