-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #588 from oasisprotocol/pro-wh/feature/roothash
consensus roothash events specialization
- Loading branch information
Showing
38 changed files
with
905 additions
and
590 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package consensus | ||
|
||
import ( | ||
"bytes" | ||
"encoding/hex" | ||
|
||
coreCommon "github.com/oasisprotocol/oasis-core/go/common" | ||
sdkConfig "github.com/oasisprotocol/oasis-sdk/client-sdk/go/config" | ||
|
||
"github.com/oasisprotocol/nexus/common" | ||
) | ||
|
||
func RuntimeFromID(rtid coreCommon.Namespace, network sdkConfig.Network) *common.Runtime { | ||
for name, pt := range network.ParaTimes.All { | ||
id, err := hex.DecodeString(pt.ID) | ||
if err != nil { | ||
return nil | ||
} | ||
if bytes.Equal(id, rtid[:]) { | ||
return common.Ptr(common.Runtime(name)) | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
scripts/vendor-oasis-core/patches/v23.0/discrepancy_round.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/coreapi/v23.0/roothash/api/api.go b/coreapi/v23.0/roothash/api/api.go | ||
index e7653d7d..e6a88db5 100644 | ||
--- a/coreapi/v23.0/roothash/api/api.go | ||
+++ b/coreapi/v23.0/roothash/api/api.go | ||
@@ -192,6 +192,8 @@ type ExecutorCommittedEvent struct { | ||
|
||
// ExecutionDiscrepancyDetectedEvent is an execute discrepancy detected event. | ||
type ExecutionDiscrepancyDetectedEvent struct { | ||
+ // Round is the round in which the discrepancy was detected. | ||
+ Round *uint64 `json:"round,omitempty"` | ||
// Rank is the rank of the transaction scheduler. | ||
Rank uint64 `json:"rank"` | ||
// Timeout signals whether the discrepancy was due to a timeout. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE chain.events | ||
-- There's some mismatch between oasis-core's style in Go and nexus's | ||
-- style in SQL and JSON. oasis-core likes structures filled with nilable | ||
-- pointers, where one pointer is non-nil. nexus likes a type string plus | ||
-- a "body" blob. In roothash events though, the roothash/api Event | ||
-- structure additionally has a RuntimeID field, which nexus otherwise | ||
-- loses when it extracts the one non-nil event next to it. In the nexus, | ||
-- database, we're storing that runtime identifier in a column. | ||
-- | ||
-- This is a runtime identifier, which is a binary "namespace," e.g. | ||
-- `000000000000000000000000000000000000000000000000f80306c9858e7279` for | ||
-- Sapphire on Mainnet. This is taken from the event from the node, and it | ||
-- is set even for runtimes that nexus isn't configured to analyze. | ||
ADD COLUMN roothash_runtime_id HEX64, | ||
-- This is a nexus runtime name, for example `sapphire`. This is only set | ||
-- for supported runtimes. | ||
ADD COLUMN roothash_runtime runtime, | ||
ADD COLUMN roothash_runtime_round UINT63; | ||
|
||
-- ix_events_roothash is the link between runtime blocks and consensus blocks. | ||
-- Given a runtime block (runtime, round), you can look up the roothash events | ||
-- with this index and find the events when the block was proposed (first | ||
-- executor commit), committed to, and finalized. | ||
CREATE INDEX ix_events_roothash | ||
ON chain.events (roothash_runtime, roothash_runtime_round) | ||
WHERE | ||
roothash_runtime IS NOT NULL AND | ||
roothash_runtime_round IS NOT NULL; | ||
|
||
COMMIT; |
Oops, something went wrong.