Skip to content

Commit

Permalink
Merge branch 'main' into fix_safe
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan authored Sep 11, 2024
2 parents dcecf5b + b9a1a3b commit 5605c11
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions assertions/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,9 @@ func randUint64(max uint64) (uint64, error) {
}
return n.Uint64(), nil
}

func (m *Manager) LatestAgreedAssertion() protocol.AssertionHash {
m.assertionChainData.RLock()
defer m.assertionChainData.RUnlock()
return m.assertionChainData.latestAgreedAssertion
}
21 changes: 21 additions & 0 deletions challenge-manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,3 +520,24 @@ func (m *Manager) fastTickWhileCatchingUp(ctx context.Context) {
}
}
}

func (m *Manager) LatestConfirmedState(ctx context.Context) (protocol.GoGlobalState, error) {
latestConfirmed, err := m.chain.LatestConfirmed(ctx, m.chain.GetCallOptsWithDesiredRpcHeadBlockNumber(&bind.CallOpts{Context: ctx}))
if err != nil {
return protocol.GoGlobalState{}, err
}
info, err := m.chain.ReadAssertionCreationInfo(ctx, latestConfirmed.Id())
if err != nil {
return protocol.GoGlobalState{}, err
}
return protocol.GoExecutionStateFromSolidity(info.AfterState).GlobalState, nil
}

func (m *Manager) LatestAgreedState(ctx context.Context) (protocol.GoGlobalState, error) {
latestAgreedAssertion := m.assertionManager.LatestAgreedAssertion()
info, err := m.chain.ReadAssertionCreationInfo(ctx, latestAgreedAssertion)
if err != nil {
return protocol.GoGlobalState{}, err
}
return protocol.GoExecutionStateFromSolidity(info.AfterState).GlobalState, nil
}

0 comments on commit 5605c11

Please sign in to comment.