Skip to content

Commit

Permalink
Merge pull request #123 from unicornultrafoundation/update/apply_heli…
Browse files Browse the repository at this point in the history
…os_consensus

Apply Helios consensus
  • Loading branch information
trinhdn97 authored Nov 26, 2024
2 parents 8d20248 + 1652fb6 commit aa87e72
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 78 deletions.
48 changes: 24 additions & 24 deletions cmd/u2u/launcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,26 @@ var tomlSettings = toml.Config{
}

type config struct {
Node node.Config
U2U gossip.Config
Emitter emitter.Config
TxPool evmcore.TxPoolConfig
U2UStore gossip.StoreConfig
Hashgraph consensus.Config
HashgraphStore consensus.StoreConfig
VectorClock vecmt.IndexConfig
DBs integration.DBsConfig
Monitoring monitoring.Config
Node node.Config
U2U gossip.Config
Emitter emitter.Config
TxPool evmcore.TxPoolConfig
U2UStore gossip.StoreConfig
Helios consensus.Config
HeliosStore consensus.StoreConfig
VectorClock vecmt.IndexConfig
DBs integration.DBsConfig
Monitoring monitoring.Config
}

func (c *config) AppConfigs() integration.Configs {
return integration.Configs{
U2U: c.U2U,
U2UStore: c.U2UStore,
Hashgraph: c.Hashgraph,
HashgraphStore: c.HashgraphStore,
VectorClock: c.VectorClock,
DBs: c.DBs,
U2U: c.U2U,
U2UStore: c.U2UStore,
Helios: c.Helios,
HeliosStore: c.HeliosStore,
VectorClock: c.VectorClock,
DBs: c.DBs,
}
}

Expand Down Expand Up @@ -495,14 +495,14 @@ func mayMakeAllConfigs(ctx *cli.Context) (*config, error) {
// Defaults (low priority)
cacheRatio := cacheScaler(ctx)
cfg := config{
Node: defaultNodeConfig(),
U2U: gossip.DefaultConfig(cacheRatio),
Emitter: emitter.DefaultConfig(),
TxPool: evmcore.DefaultTxPoolConfig,
U2UStore: gossip.DefaultStoreConfig(cacheRatio),
Hashgraph: consensus.DefaultConfig(),
HashgraphStore: consensus.DefaultStoreConfig(cacheRatio),
VectorClock: vecmt.DefaultConfig(cacheRatio),
Node: defaultNodeConfig(),
U2U: gossip.DefaultConfig(cacheRatio),
Emitter: emitter.DefaultConfig(),
TxPool: evmcore.DefaultTxPoolConfig,
U2UStore: gossip.DefaultStoreConfig(cacheRatio),
Helios: consensus.DefaultConfig(),
HeliosStore: consensus.DefaultStoreConfig(cacheRatio),
VectorClock: vecmt.DefaultConfig(cacheRatio),
}

if ctx.GlobalIsSet(FakeNetFlag.Name) {
Expand Down
16 changes: 8 additions & 8 deletions cmd/u2u/launcher/config_custom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ func TestConfigFile(t *testing.T) {
}

src := config{
Node: defaultNodeConfig(),
U2U: gossip.DefaultConfig(cacheRatio),
Emitter: emitter.DefaultConfig(),
TxPool: evmcore.DefaultTxPoolConfig,
U2UStore: gossip.DefaultStoreConfig(cacheRatio),
Hashgraph: consensus.DefaultConfig(),
HashgraphStore: consensus.DefaultStoreConfig(cacheRatio),
VectorClock: vecmt.DefaultConfig(cacheRatio),
Node: defaultNodeConfig(),
U2U: gossip.DefaultConfig(cacheRatio),
Emitter: emitter.DefaultConfig(),
TxPool: evmcore.DefaultTxPoolConfig,
U2UStore: gossip.DefaultStoreConfig(cacheRatio),
Helios: consensus.DefaultConfig(),
HeliosStore: consensus.DefaultStoreConfig(cacheRatio),
VectorClock: vecmt.DefaultConfig(cacheRatio),
}

canonical := func(nn []*enode.Node) []*enode.Node {
Expand Down
6 changes: 3 additions & 3 deletions cmd/u2u/launcher/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestConsoleWelcome(t *testing.T) {

// Verify the actual welcome message to the required template
cli.Expect(`
Welcome to the Hashgraph JavaScript console!
Welcome to the Helios JavaScript console!
instance: go-u2u/v{{version}}/{{goos}}-{{goarch}}/{{gover}}
coinbase: {{.Coinbase}}
Expand All @@ -58,7 +58,7 @@ func TestIPCAttachWelcome(t *testing.T) {
// Configure the instance for IPC attachement
var ipc string
if runtime.GOOS == "windows" {
ipc = `\\.\pipe\hashgraph.ipc`
ipc = `\\.\pipe\helios.ipc`
} else {
ws := tmpdir(t)
defer os.RemoveAll(ws)
Expand Down Expand Up @@ -121,7 +121,7 @@ func testAttachWelcome(t *testing.T, cli *testcli, endpoint, apis string) {

// Verify the actual welcome message to the required template
attach.Expect(`
Welcome to the Hashgraph JavaScript console!
Welcome to the Helios JavaScript console!
instance: go-u2u/v{{version}}/{{goos}}-{{goarch}}/{{gover}}
coinbase: {{coinbase}}
Expand Down
4 changes: 2 additions & 2 deletions cmd/u2u/launcher/fake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestFakeNetFlag_NonValidator(t *testing.T) {

// Verify the actual welcome message to the required template
cli.Expect(`
Welcome to the Hashgraph JavaScript console!
Welcome to the Helios JavaScript console!
instance: go-u2u/v{{version}}/{{goos}}-{{goarch}}/{{gover}}
coinbase: {{.Coinbase}}
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestFakeNetFlag_Validator(t *testing.T) {

// Verify the actual welcome message to the required template
cli.Expect(`
Welcome to the Hashgraph JavaScript console!
Welcome to the Helios JavaScript console!
instance: go-u2u/v{{version}}/{{goos}}-{{goarch}}/{{gover}}
coinbase: {{.Coinbase}}
Expand Down
4 changes: 2 additions & 2 deletions cmd/u2u/launcher/fixdirty.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ func healDirty(ctx *cli.Context) error {
}

// prepare consensus database from epochState
log.Info("Recreating hashgraph DB")
log.Info("Recreating helios DB")
cMainDb := mustOpenDB(multiProducer, "hashgraph")
cGetEpochDB := func(epoch idx.Epoch) u2udb.Store {
return mustOpenDB(multiProducer, fmt.Sprintf("hashgraph-%d", epoch))
}
cdb := consensus.NewStore(cMainDb, cGetEpochDB, panics("hashgraph store"), cfg.HashgraphStore)
cdb := consensus.NewStore(cMainDb, cGetEpochDB, panics("helios store"), cfg.HeliosStore)
err = cdb.ApplyGenesis(&consensus.Genesis{
Epoch: epochState.Epoch,
Validators: epochState.Validators,
Expand Down
4 changes: 2 additions & 2 deletions cmd/u2u/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func init() {

// App.

app.Action = hashgraphMain
app.Action = heliosMain
app.Version = params.VersionWithCommit(gitCommit, gitDate)
app.HideVersion = true // we have a command to print the version
app.Commands = []cli.Command{
Expand Down Expand Up @@ -251,7 +251,7 @@ func Launch(args []string) error {
// u2u is the main entry point into the system if no special subcommand is ran.
// It creates a default node based on the command line arguments and runs it in
// blocking mode, waiting for it to be shut down.
func hashgraphMain(ctx *cli.Context) error {
func heliosMain(ctx *cli.Context) error {
if args := ctx.Args(); len(args) > 0 {
return fmt.Errorf("invalid command: %q", args[0])
}
Expand Down
2 changes: 1 addition & 1 deletion console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, str
// Welcome shows summary of current u2u instance and some metadata about the
// console's available modules.
func (c *Console) Welcome() {
message := "Welcome to the Hashgraph JavaScript console!\n\n"
message := "Welcome to the Helios JavaScript console!\n\n"

// Print some generic u2u metadata
res, err := c.jsre.Run(`
Expand Down
2 changes: 1 addition & 1 deletion ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2537,7 +2537,7 @@ func (api *PrivateDebugAPI) ChaindbCompact() error {

// SetHead rewinds the head of the blockchain to a previous block.
func (api *PrivateDebugAPI) SetHead(number hexutil.Uint64) error {
return errors.New("hashgraph cannot rewind blocks due to the BFT algorithm")
return errors.New("helios cannot rewind blocks due to the BFT algorithm")
}

// PublicNetAPI offers network related RPC methods
Expand Down
4 changes: 2 additions & 2 deletions ethapi/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ type Backend interface {
ChainConfig() *params.ChainConfig
CurrentBlock() *evmcore.EvmBlock

// Hashgraph DAG API
// Helios DAG API
GetEventPayload(ctx context.Context, shortEventID string) (*native.EventPayload, error)
GetEvent(ctx context.Context, shortEventID string) (*native.Event, error)
GetHeads(ctx context.Context, epoch rpc.BlockNumber) (hash.Events, error)
CurrentEpoch(ctx context.Context) idx.Epoch
SealedEpochTiming(ctx context.Context) (start native.Timestamp, end native.Timestamp)

// Hashgraph aBFT API
// Helios aBFT API
GetEpochBlockState(ctx context.Context, epoch rpc.BlockNumber) (*iblockproc.BlockState, *iblockproc.EpochState, error)
GetDowntime(ctx context.Context, vid idx.ValidatorID) (idx.Block, native.Timestamp, error)
GetUptime(ctx context.Context, vid idx.ValidatorID) (*big.Int, error)
Expand Down
4 changes: 2 additions & 2 deletions ethapi/dag_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewPublicDAGChainAPI(b Backend) *PublicDAGChainAPI {
return &PublicDAGChainAPI{b}
}

// GetEvent returns the Hashgraph event header by hash or short ID.
// GetEvent returns the Helios event header by hash or short ID.
func (s *PublicDAGChainAPI) GetEvent(ctx context.Context, shortEventID string) (map[string]interface{}, error) {
header, err := s.b.GetEvent(ctx, shortEventID)
if err != nil {
Expand All @@ -36,7 +36,7 @@ func (s *PublicDAGChainAPI) GetEvent(ctx context.Context, shortEventID string) (
return native.RPCMarshalEvent(header), nil
}

// GetEventPayload returns Hashgraph event by hash or short ID.
// GetEventPayload returns Helios event by hash or short ID.
func (s *PublicDAGChainAPI) GetEventPayload(ctx context.Context, shortEventID string, inclTx bool) (map[string]interface{}, error) {
event, err := s.b.GetEventPayload(ctx, shortEventID)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion evmcore/dummy_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func ToEvmHeader(block *native.Block, index idx.Block, prevHash hash.Event, rule
}
}

// ConvertFromEthHeader converts ETH-formatted header to Hashgraph EVM header
// ConvertFromEthHeader converts ETH-formatted header to Helios EVM header
func ConvertFromEthHeader(h *types.Header) *EvmHeader {
// NOTE: incomplete conversion
return &EvmHeader{
Expand Down
2 changes: 1 addition & 1 deletion gossip/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func makeTestEngine(gdb *Store) (*consensus.Consensus, *vecmt.Index) {
Validators: gdb.GetValidators(),
})
vecClock := vecmt.NewIndex(panics("Vector clock"), vecmt.LiteConfig())
engine := consensus.NewConsensus(cdb, &testGossipStoreAdapter{gdb}, vecmt2dagidx.Wrap(vecClock), panics("Hashgraph"), consensus.LiteConfig())
engine := consensus.NewConsensus(cdb, &testGossipStoreAdapter{gdb}, vecmt2dagidx.Wrap(vecClock), panics("Helios"), consensus.LiteConfig())
return engine, vecClock
}

Expand Down
4 changes: 2 additions & 2 deletions gossip/ethapi_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (b *EthAPIBackend) GetFullEventID(shortEventID string) (hash.Event, error)
return options[0], nil
}

// GetEventPayload returns Hashgraph event by hash or short ID.
// GetEventPayload returns Helios event by hash or short ID.
func (b *EthAPIBackend) GetEventPayload(ctx context.Context, shortEventID string) (*native.EventPayload, error) {
id, err := b.GetFullEventID(shortEventID)
if err != nil {
Expand All @@ -211,7 +211,7 @@ func (b *EthAPIBackend) GetEventPayload(ctx context.Context, shortEventID string
return b.svc.store.GetEventPayload(id), nil
}

// GetEvent returns the Hashgraph event header by hash or short ID.
// GetEvent returns the Helios event header by hash or short ID.
func (b *EthAPIBackend) GetEvent(ctx context.Context, shortEventID string) (*native.Event, error) {
id, err := b.GetFullEventID(shortEventID)
if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions integration/assembly.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ func (e *GenesisMismatchError) Error() string {
}

type Configs struct {
U2U gossip.Config
U2UStore gossip.StoreConfig
Hashgraph consensus.Config
HashgraphStore consensus.StoreConfig
VectorClock vecmt.IndexConfig
DBs DBsConfig
U2U gossip.Config
U2UStore gossip.StoreConfig
Helios consensus.Config
HeliosStore consensus.StoreConfig
VectorClock vecmt.IndexConfig
DBs DBsConfig
}

func panics(name string) func(error) {
Expand All @@ -74,7 +74,7 @@ func getStores(producer u2udb.FlushableDBProducer, cfg Configs) (*gossip.Store,
cGetEpochDB := func(epoch idx.Epoch) u2udb.Store {
return mustOpenDB(producer, fmt.Sprintf("hashgraph-%d", epoch))
}
cdb := consensus.NewStore(cMainDb, cGetEpochDB, panics("Hashgraph store"), cfg.HashgraphStore)
cdb := consensus.NewStore(cMainDb, cGetEpochDB, panics("Helios store"), cfg.HeliosStore)
return gdb, cdb
}

Expand Down Expand Up @@ -103,13 +103,13 @@ func rawMakeEngine(gdb *gossip.Store, cdb *consensus.Store, g *genesis.Genesis,
Validators: gdb.GetValidators(),
})
if err != nil {
return nil, nil, blockProc, fmt.Errorf("failed to write Hashgraph genesis state: %v", err)
return nil, nil, blockProc, fmt.Errorf("failed to write Helios genesis state: %v", err)
}
}

// create consensus
vecClock := vecmt.NewIndex(panics("Vector clock"), cfg.VectorClock)
engine := consensus.NewConsensus(cdb, &GossipStoreAdapter{gdb}, vecmt2dagidx.Wrap(vecClock), panics("Hashgraph"), cfg.Hashgraph)
engine := consensus.NewConsensus(cdb, &GossipStoreAdapter{gdb}, vecmt2dagidx.Wrap(vecClock), panics("Helios"), cfg.Helios)
return engine, vecClock, blockProc, nil
}

Expand Down
12 changes: 6 additions & 6 deletions integration/bench_db_flush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ func BenchmarkFlushDBs(b *testing.B) {
genStore := makefakegenesis.FakeGenesisStore(1, utils.ToU2U(1), utils.ToU2U(1))
g := genStore.Genesis()
_, _, store, s2, _, closeDBs := MakeEngine(dir, &g, Configs{
U2U: gossip.DefaultConfig(cachescale.Identity),
U2UStore: gossip.DefaultStoreConfig(cachescale.Identity),
Hashgraph: consensus.DefaultConfig(),
HashgraphStore: consensus.DefaultStoreConfig(cachescale.Identity),
VectorClock: vecmt.DefaultConfig(cachescale.Identity),
DBs: DefaultDBsConfig(cachescale.Identity.U64, 512),
U2U: gossip.DefaultConfig(cachescale.Identity),
U2UStore: gossip.DefaultStoreConfig(cachescale.Identity),
Helios: consensus.DefaultConfig(),
HeliosStore: consensus.DefaultStoreConfig(cachescale.Identity),
VectorClock: vecmt.DefaultConfig(cachescale.Identity),
DBs: DefaultDBsConfig(cachescale.Identity.U64, 512),
})
defer closeDBs()
defer store.Close()
Expand Down
18 changes: 9 additions & 9 deletions integration/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ func TestGenericNameOfTmpDB(t *testing.T) {
require := require.New(t)

for name, exp := range map[string]string{
"": "",
"main": "main",
"main-single": "main-single",
"hashgraph-0": "hashgraph-tmp",
"hashgraph-0999": "hashgraph-tmp",
"gossip-50": "gossip-tmp",
"epoch-1": "epoch-tmp",
"xxx-1a": "xxx-1a",
"123": "123",
"": "",
"main": "main",
"main-single": "main-single",
"helios-0": "helios-tmp",
"helios-0999": "helios-tmp",
"gossip-50": "gossip-tmp",
"epoch-1": "epoch-tmp",
"xxx-1a": "xxx-1a",
"123": "123",
} {
got := genericNameOfTmpDB(name)
require.Equal(exp, got, name)
Expand Down
4 changes: 2 additions & 2 deletions native/client/dag_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/unicornultrafoundation/go-u2u/native"
)

// GetEvent returns Hashgraph event by hash or short ID.
// GetEvent returns Helios event by hash or short ID.
func (ec *Client) GetEvent(ctx context.Context, h hash.Event) (e native.EventI, err error) {
var raw map[string]interface{}
err = ec.c.CallContext(ctx, &raw, "dag_getEvent", h.Hex())
Expand All @@ -27,7 +27,7 @@ func (ec *Client) GetEvent(ctx context.Context, h hash.Event) (e native.EventI,
return
}

// GetEvent returns Hashgraph event by hash or short ID.
// GetEvent returns Helios event by hash or short ID.
func (ec *Client) GetEventPayload(ctx context.Context, h hash.Event, inclTx bool) (e native.EventI, txs []common.Hash, err error) {
var raw map[string]interface{}
err = ec.c.CallContext(ctx, &raw, "dag_getEventPayload", h.Hex(), inclTx)
Expand Down
2 changes: 1 addition & 1 deletion u2u/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type EpochsRules struct {
MaxEpochDuration native.Timestamp
}

// DagRules of Hashgraph DAG (directed acyclic graph).
// DagRules of Helios DAG (directed acyclic graph).
type DagRules struct {
MaxParents idx.Event
MaxFreeParents idx.Event // maximum number of parents with no gas cost
Expand Down

0 comments on commit aa87e72

Please sign in to comment.