Skip to content
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

go: rename compute -> executor #2525

Merged
merged 2 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changelog/2525.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
go: Rename compute -> executor.

It was proposed that we rename the "compute" phase (of the txnscheduler, _compute_, merge workflow) to "executor."

Things that remain as "compute":
- the registry node role
- the registry runtime kind
- the staking threshold kind
- things actually referring to processing inputs to outputs
- one of the drbg contexts

So among things that are renamed are fields of the on-chain state and command line flags.
14 changes: 7 additions & 7 deletions go/consensus/tendermint/apps/roothash/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ var (
// merge discrepancy detected events (value is a CBOR serialized
// ValueMergeDiscrepancyDetected).
KeyMergeDiscrepancyDetected = []byte("merge-discrepancy")
// KeyComputeDiscrepancyDetected is an ABCI event attribute key for
// KeyExecutionDiscrepancyDetected is an ABCI event attribute key for
// merge discrepancy detected events (value is a CBOR serialized
// ValueComputeDiscrepancyDetected).
KeyComputeDiscrepancyDetected = []byte("compute-discrepancy")
// ValueExecutionDiscrepancyDetected).
KeyExecutionDiscrepancyDetected = []byte("execution-discrepancy")
// KeyFinalized is an ABCI event attribute key for finalized blocks
// (value is a CBOR serialized ValueFinalized).
KeyFinalized = []byte("finalized")
Expand All @@ -48,9 +48,9 @@ type ValueMergeDiscrepancyDetected struct {
ID common.Namespace `json:"id"`
}

// ValueComputeDiscrepancyDetected is the value component of a
// ValueExecutionDiscrepancyDetected is the value component of a
// TagMergeDiscrepancyDetected.
type ValueComputeDiscrepancyDetected struct {
ID common.Namespace `json:"id"`
Event roothash.ComputeDiscrepancyDetectedEvent `json:"event"`
type ValueExecutionDiscrepancyDetected struct {
ID common.Namespace `json:"id"`
Event roothash.ExecutionDiscrepancyDetectedEvent `json:"event"`
}
88 changes: 44 additions & 44 deletions go/consensus/tendermint/apps/roothash/roothash.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (app *rootHashApplication) onCommitteeChanged(ctx *abci.Context, epoch epoc
rtState.Suspended = false

// Prepare new runtime committees based on what the scheduler did.
committeeID, computePool, mergePool, empty, err := app.prepareNewCommittees(ctx, epoch, rtState, schedState, regState)
committeeID, executorPool, mergePool, empty, err := app.prepareNewCommittees(ctx, epoch, rtState, schedState, regState)
if err != nil {
return err
}
Expand Down Expand Up @@ -152,7 +152,7 @@ func (app *rootHashApplication) onCommitteeChanged(ctx *abci.Context, epoch epoc
app.emitEmptyBlock(ctx, rtState, block.EpochTransition)

// Create a new round.
rtState.Round = roothashState.NewRound(committeeID, computePool, mergePool, rtState.CurrentBlock)
rtState.Round = roothashState.NewRound(committeeID, executorPool, mergePool, rtState.CurrentBlock)
}

// Update the runtime descriptor to the latest per-epoch value.
Expand Down Expand Up @@ -194,7 +194,7 @@ func (app *rootHashApplication) prepareNewCommittees(
regState *registryState.MutableState,
) (
committeeID hash.Hash,
computePool *commitment.MultiPool,
executorPool *commitment.MultiPool,
mergePool *commitment.Pool,
empty bool,
err error,
Expand All @@ -205,50 +205,50 @@ func (app *rootHashApplication) prepareNewCommittees(
// of all committees. We need this to be able to quickly see if any
// committee members have changed.
//
// We first include the current epoch, then all compute committee member
// We first include the current epoch, then all executor committee member
// hashes and then the merge committee member hash:
//
// [little-endian epoch]
// "compute committees follow"
// [compute committe 1 members hash]
// [compute committe 2 members hash]
// "executor committees follow"
// [executor committe 1 members hash]
// [executor committe 2 members hash]
// ...
// [compute committe n members hash]
// [executor committe n members hash]
// "merge committee follows"
// [merge committee members hash]
//
var committeeIDParts [][]byte
var rawEpoch [8]byte
binary.LittleEndian.PutUint64(rawEpoch[:], uint64(epoch))
committeeIDParts = append(committeeIDParts, rawEpoch[:])
committeeIDParts = append(committeeIDParts, []byte("compute committees follow"))
committeeIDParts = append(committeeIDParts, []byte("executor committees follow"))

// NOTE: There will later be multiple compute committees.
var computeCommittees []*scheduler.Committee
cc1, err := schedState.Committee(scheduler.KindCompute, rtID)
// NOTE: There will later be multiple executor committees.
var executorCommittees []*scheduler.Committee
xc1, err := schedState.Committee(scheduler.KindExecutor, rtID)
if err != nil {
app.logger.Error("checkCommittees: failed to get compute committee from scheduler",
app.logger.Error("checkCommittees: failed to get executor committee from scheduler",
"err", err,
"runtime", rtID,
)
return
}
if cc1 != nil {
computeCommittees = append(computeCommittees, cc1)
if xc1 != nil {
executorCommittees = append(executorCommittees, xc1)
}

computePool = &commitment.MultiPool{
executorPool = &commitment.MultiPool{
Committees: make(map[hash.Hash]*commitment.Pool),
}
if len(computeCommittees) == 0 {
app.logger.Warn("checkCommittees: no compute committees",
if len(executorCommittees) == 0 {
app.logger.Warn("checkCommittees: no executor committees",
"runtime", rtID,
)
empty = true
}
for _, computeCommittee := range computeCommittees {
computeNodeInfo := make(map[signature.PublicKey]commitment.NodeInfo)
for idx, n := range computeCommittee.Members {
for _, executorCommittee := range executorCommittees {
executorNodeInfo := make(map[signature.PublicKey]commitment.NodeInfo)
for idx, n := range executorCommittee.Members {
var nodeRuntime *node.Runtime
node, err1 := regState.Node(n.PublicKey)
if err1 != nil {
Expand All @@ -269,18 +269,18 @@ func (app *rootHashApplication) prepareNewCommittees(
)
continue
}
computeNodeInfo[n.PublicKey] = commitment.NodeInfo{
executorNodeInfo[n.PublicKey] = commitment.NodeInfo{
CommitteeNode: idx,
Runtime: nodeRuntime,
}
}
computeCommitteeID := computeCommittee.EncodedMembersHash()
committeeIDParts = append(committeeIDParts, computeCommitteeID[:])
executorCommitteeID := executorCommittee.EncodedMembersHash()
committeeIDParts = append(committeeIDParts, executorCommitteeID[:])

computePool.Committees[computeCommitteeID] = &commitment.Pool{
executorPool.Committees[executorCommitteeID] = &commitment.Pool{
Runtime: rtState.Runtime,
Committee: computeCommittee,
NodeInfo: computeNodeInfo,
Committee: executorCommittee,
NodeInfo: executorNodeInfo,
}
}

Expand Down Expand Up @@ -336,13 +336,13 @@ func (app *rootHashApplication) ExecuteTx(ctx *abci.Context, tx *transaction.Tra
state := roothashState.NewMutableState(ctx.State())

switch tx.Method {
case roothash.MethodComputeCommit:
var cc roothash.ComputeCommit
if err := cbor.Unmarshal(tx.Body, &cc); err != nil {
case roothash.MethodExecutorCommit:
var xc roothash.ExecutorCommit
if err := cbor.Unmarshal(tx.Body, &xc); err != nil {
return err
}

return app.computeCommit(ctx, state, &cc)
return app.executorCommit(ctx, state, &xc)
case roothash.MethodMergeCommit:
var mc roothash.MergeCommit
if err := cbor.Unmarshal(tx.Body, &mc); err != nil {
Expand Down Expand Up @@ -500,8 +500,8 @@ func (app *rootHashApplication) FireTimer(ctx *abci.Context, timer *abci.Timer)
panic(err)
}
}
for _, pool := range rtState.Round.ComputePool.GetTimeoutCommittees(ctx.Now()) {
app.tryFinalizeCompute(ctx, rtState, pool, true)
for _, pool := range rtState.Round.ExecutorPool.GetTimeoutCommittees(ctx.Now()) {
app.tryFinalizeExecute(ctx, rtState, pool, true)
}

return nil
Expand Down Expand Up @@ -534,7 +534,7 @@ func (app *rootHashApplication) updateTimer(
}
}

func (app *rootHashApplication) tryFinalizeCompute(
func (app *rootHashApplication) tryFinalizeExecute(
ctx *abci.Context,
rtState *roothashState.RuntimeState,
pool *commitment.Pool,
Expand All @@ -548,22 +548,22 @@ func (app *rootHashApplication) tryFinalizeCompute(
defer app.updateTimer(ctx, rtState, blockNr)

if rtState.Round.Finalized {
app.logger.Error("attempted to finalize compute when block already finalized",
app.logger.Error("attempted to finalize execute when block already finalized",
"round", blockNr,
"committee_id", committeeID,
)
return
}

_, err := pool.TryFinalize(ctx.Now(), runtime.Compute.RoundTimeout, forced, true)
_, err := pool.TryFinalize(ctx.Now(), runtime.Executor.RoundTimeout, forced, true)
switch err {
case nil:
// No error -- there is no discrepancy. But only the merge committee
// can make progress even if we have all compute commitments.
// can make progress even if we have all executor commitments.

// TODO: Check if we need to punish the merge committee.

app.logger.Warn("no compute discrepancy, but only merge committee can make progress",
app.logger.Warn("no execution discrepancy, but only merge committee can make progress",
"round", blockNr,
"committee_id", committeeID,
)
Expand All @@ -578,20 +578,20 @@ func (app *rootHashApplication) tryFinalizeCompute(
return
case commitment.ErrDiscrepancyDetected:
// Discrepancy has been detected.
app.logger.Warn("compute discrepancy detected",
app.logger.Warn("execution discrepancy detected",
"round", blockNr,
"committee_id", committeeID,
logging.LogEvent, roothash.LogEventComputeDiscrepancyDetected,
logging.LogEvent, roothash.LogEventExecutionDiscrepancyDetected,
)

tagV := ValueComputeDiscrepancyDetected{
tagV := ValueExecutionDiscrepancyDetected{
ID: runtime.ID,
Event: roothash.ComputeDiscrepancyDetectedEvent{
Event: roothash.ExecutionDiscrepancyDetectedEvent{
CommitteeID: pool.GetCommitteeID(),
Timeout: forced,
},
}
ctx.EmitEvent(tmapi.NewEventBuilder(app.Name()).Attribute(KeyComputeDiscrepancyDetected, cbor.Marshal(tagV)))
ctx.EmitEvent(tmapi.NewEventBuilder(app.Name()).Attribute(KeyExecutionDiscrepancyDetected, cbor.Marshal(tagV)))
return
default:
}
Expand Down Expand Up @@ -641,7 +641,7 @@ func (app *rootHashApplication) tryFinalizeMerge(
blk.Header.Timestamp = uint64(ctx.Now().Unix())

rtState.Round.MergePool.ResetCommitments()
rtState.Round.ComputePool.ResetCommitments()
rtState.Round.ExecutorPool.ResetCommitments()
rtState.Round.Finalized = true

return blk
Expand Down
20 changes: 10 additions & 10 deletions go/consensus/tendermint/apps/roothash/state/round.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,40 @@ import (

// Round is a roothash round.
type Round struct {
CommitteeID hash.Hash `json:"committee_id"`
ComputePool *commitment.MultiPool `json:"compute_pool"`
MergePool *commitment.Pool `json:"merge_pool"`
CommitteeID hash.Hash `json:"committee_id"`
ExecutorPool *commitment.MultiPool `json:"executor_pool"`
MergePool *commitment.Pool `json:"merge_pool"`

CurrentBlock *block.Block `json:"current_block"`
Finalized bool `json:"finalized"`
}

func (r *Round) Reset() {
r.ComputePool.ResetCommitments()
r.ExecutorPool.ResetCommitments()
r.MergePool.ResetCommitments()
r.Finalized = false
}

func (r *Round) GetNextTimeout() (timeout time.Time) {
timeout = r.ComputePool.GetNextTimeout()
timeout = r.ExecutorPool.GetNextTimeout()
if timeout.IsZero() || (!r.MergePool.NextTimeout.IsZero() && r.MergePool.NextTimeout.Before(timeout)) {
timeout = r.MergePool.NextTimeout
}
return
}

func (r *Round) AddComputeCommitment(commitment *commitment.ComputeCommitment, sv commitment.SignatureVerifier) (*commitment.Pool, error) {
func (r *Round) AddExecutorCommitment(commitment *commitment.ExecutorCommitment, sv commitment.SignatureVerifier) (*commitment.Pool, error) {
if r.Finalized {
return nil, errors.New("tendermint/roothash: round is already finalized, can't commit")
}
return r.ComputePool.AddComputeCommitment(r.CurrentBlock, sv, commitment)
return r.ExecutorPool.AddExecutorCommitment(r.CurrentBlock, sv, commitment)
}

func (r *Round) AddMergeCommitment(commitment *commitment.MergeCommitment, sv commitment.SignatureVerifier) error {
if r.Finalized {
return errors.New("tendermint/roothash: round is already finalized, can't commit")
}
return r.MergePool.AddMergeCommitment(r.CurrentBlock, sv, commitment, r.ComputePool)
return r.MergePool.AddMergeCommitment(r.CurrentBlock, sv, commitment, r.ExecutorPool)
}

func (r *Round) Transition(blk *block.Block) {
Expand All @@ -54,14 +54,14 @@ func (r *Round) Transition(blk *block.Block) {

func NewRound(
committeeID hash.Hash,
computePool *commitment.MultiPool,
executorPool *commitment.MultiPool,
mergePool *commitment.Pool,
blk *block.Block,
) *Round {
r := &Round{
CommitteeID: committeeID,
CurrentBlock: blk,
ComputePool: computePool,
ExecutorPool: executorPool,
MergePool: mergePool,
}
r.Reset()
Expand Down
8 changes: 4 additions & 4 deletions go/consensus/tendermint/apps/roothash/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ func (app *rootHashApplication) getRuntimeState(
return rtState, sv, nil
}

func (app *rootHashApplication) computeCommit(
func (app *rootHashApplication) executorCommit(
ctx *abci.Context,
state *roothashState.MutableState,
cc *roothash.ComputeCommit,
cc *roothash.ExecutorCommit,
) error {
if ctx.IsCheckOnly() {
return nil
Expand All @@ -120,7 +120,7 @@ func (app *rootHashApplication) computeCommit(
pools := make(map[*commitment.Pool]bool)
for _, commit := range cc.Commits {
var pool *commitment.Pool
if pool, err = rtState.Round.AddComputeCommitment(&commit, sv); err != nil {
if pool, err = rtState.Round.AddExecutorCommitment(&commit, sv); err != nil {
app.logger.Error("failed to add compute commitment to round",
"err", err,
"round", rtState.CurrentBlock.Header.Round,
Expand All @@ -133,7 +133,7 @@ func (app *rootHashApplication) computeCommit(

// Try to finalize compute rounds.
for pool := range pools {
app.tryFinalizeCompute(ctx, rtState, pool, false)
app.tryFinalizeExecute(ctx, rtState, pool, false)
}

return nil
Expand Down
Loading