Skip to content

Commit

Permalink
Add Etna logging (#3454)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored and tsachiherman committed Jan 29, 2025
1 parent 30a6c64 commit d274987
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
3 changes: 3 additions & 0 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ava-labs/avalanchego/app"
"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/version"
"github.com/ava-labs/avalanchego/vms/platformvm/block/executor"
)

func main() {
Expand Down Expand Up @@ -59,6 +60,8 @@ func main() {

if term.IsTerminal(int(os.Stdout.Fd())) {
fmt.Println(app.Header)
} else {
executor.EtnaActivationWasLogged.Set(true)
}

nodeApp, err := app.New(nodeConfig)
Expand Down
36 changes: 35 additions & 1 deletion vms/platformvm/block/executor/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,35 @@ package executor

import (
"context"
"fmt"
"time"

"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/vms/platformvm/block"

smblock "github.com/ava-labs/avalanchego/snow/engine/snowman/block"
)

const ActivationLog = `
_____ .__ .__ .____ ____
/ _ \___ _______ | | _____ ____ ____ | |__ ____ | | /_ | ______
/ /_\ \ \/ /\__ \ | | \__ \ / \_/ ___\| | \_/ __ \ | | | |/ ___/
/ | \ / / __ \| |__/ __ \| | \ \___| Y \ ___/ | |___| |\___ \
\____|__ /\_/ (____ /____(____ /___| /\___ >___| /\___ > |_______ \___/____ >
\/ \/ \/ \/ \/ \/ \/ \/ \/
___ _____ __ .__ __ .___ ___
/ _ \_/\ / _ \ _____/ |_|__|__ _______ _/ |_ ____ __| _/ / _ \_/\
\/ \___/ / /_\ \_/ ___\ __\ \ \/ /\__ \\ __\/ __ \ / __ | \/ \___/ ,_ o
/ | \ \___| | | |\ / / __ \| | \ ___// /_/ | / //\,
\____|__ /\___ >__| |__| \_/ (____ /__| \___ >____ | \>> |
\/ \/ \/ \/ \/ \\
`

// TODO: Remove after Etna is activated
var EtnaActivationWasLogged = utils.NewAtomic(false)

var (
_ snowman.Block = (*Block)(nil)
_ snowman.OracleBlock = (*Block)(nil)
Expand Down Expand Up @@ -75,7 +96,20 @@ func (b *Block) Verify(ctx context.Context) error {
}

func (b *Block) Accept(context.Context) error {
return b.Visit(b.manager.acceptor)
if err := b.Visit(b.manager.acceptor); err != nil {
return err
}

currentTime := b.manager.state.GetTimestamp()
if !b.manager.txExecutorBackend.Config.UpgradeConfig.IsEtnaActivated(currentTime) {
return nil
}

if !EtnaActivationWasLogged.Get() && b.manager.txExecutorBackend.Bootstrapped.Get() {
fmt.Print(ActivationLog)
}
EtnaActivationWasLogged.Set(true)
return nil
}

func (b *Block) Reject(context.Context) error {
Expand Down
4 changes: 4 additions & 0 deletions vms/platformvm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ func (vm *VM) Initialize(
return err
}

if currentTime := vm.state.GetTimestamp(); vm.Internal.UpgradeConfig.IsEtnaActivated(currentTime) {
blockexecutor.EtnaActivationWasLogged.Set(true)
}

validatorManager := pvalidators.NewManager(chainCtx.Log, vm.Internal, vm.state, vm.metrics, &vm.clock)
vm.State = validatorManager
utxoVerifier := utxo.NewVerifier(vm.ctx, &vm.clock, vm.fx)
Expand Down

0 comments on commit d274987

Please # to comment.