Skip to content

Commit 4c2f285

Browse files
Add Etna logging (#3454)
1 parent 3caddcf commit 4c2f285

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

main/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/ava-labs/avalanchego/app"
1616
"github.com/ava-labs/avalanchego/config"
1717
"github.com/ava-labs/avalanchego/version"
18+
"github.com/ava-labs/avalanchego/vms/platformvm/block/executor"
1819
)
1920

2021
func main() {
@@ -59,6 +60,8 @@ func main() {
5960

6061
if term.IsTerminal(int(os.Stdout.Fd())) {
6162
fmt.Println(app.Header)
63+
} else {
64+
executor.EtnaActivationWasLogged.Set(true)
6265
}
6366

6467
nodeApp, err := app.New(nodeConfig)

vms/platformvm/block/executor/block.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,35 @@ package executor
55

66
import (
77
"context"
8+
"fmt"
89
"time"
910

1011
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
12+
"github.com/ava-labs/avalanchego/utils"
1113
"github.com/ava-labs/avalanchego/vms/platformvm/block"
1214

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

18+
const ActivationLog = `
19+
_____ .__ .__ .____ ____
20+
/ _ \___ _______ | | _____ ____ ____ | |__ ____ | | /_ | ______
21+
/ /_\ \ \/ /\__ \ | | \__ \ / \_/ ___\| | \_/ __ \ | | | |/ ___/
22+
/ | \ / / __ \| |__/ __ \| | \ \___| Y \ ___/ | |___| |\___ \
23+
\____|__ /\_/ (____ /____(____ /___| /\___ >___| /\___ > |_______ \___/____ >
24+
\/ \/ \/ \/ \/ \/ \/ \/ \/
25+
___ _____ __ .__ __ .___ ___
26+
/ _ \_/\ / _ \ _____/ |_|__|__ _______ _/ |_ ____ __| _/ / _ \_/\
27+
\/ \___/ / /_\ \_/ ___\ __\ \ \/ /\__ \\ __\/ __ \ / __ | \/ \___/ ,_ o
28+
/ | \ \___| | | |\ / / __ \| | \ ___// /_/ | / //\,
29+
\____|__ /\___ >__| |__| \_/ (____ /__| \___ >____ | \>> |
30+
\/ \/ \/ \/ \/ \\
31+
32+
`
33+
34+
// TODO: Remove after Etna is activated
35+
var EtnaActivationWasLogged = utils.NewAtomic(false)
36+
1637
var (
1738
_ snowman.Block = (*Block)(nil)
1839
_ snowman.OracleBlock = (*Block)(nil)
@@ -75,7 +96,20 @@ func (b *Block) Verify(ctx context.Context) error {
7596
}
7697

7798
func (b *Block) Accept(context.Context) error {
78-
return b.Visit(b.manager.acceptor)
99+
if err := b.Visit(b.manager.acceptor); err != nil {
100+
return err
101+
}
102+
103+
currentTime := b.manager.state.GetTimestamp()
104+
if !b.manager.txExecutorBackend.Config.UpgradeConfig.IsEtnaActivated(currentTime) {
105+
return nil
106+
}
107+
108+
if !EtnaActivationWasLogged.Get() && b.manager.txExecutorBackend.Bootstrapped.Get() {
109+
fmt.Print(ActivationLog)
110+
}
111+
EtnaActivationWasLogged.Set(true)
112+
return nil
79113
}
80114

81115
func (b *Block) Reject(context.Context) error {

vms/platformvm/vm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ func (vm *VM) Initialize(
150150
return err
151151
}
152152

153+
if currentTime := vm.state.GetTimestamp(); vm.Internal.UpgradeConfig.IsEtnaActivated(currentTime) {
154+
blockexecutor.EtnaActivationWasLogged.Set(true)
155+
}
156+
153157
validatorManager := pvalidators.NewManager(chainCtx.Log, vm.Internal, vm.state, vm.metrics, &vm.clock)
154158
vm.State = validatorManager
155159
utxoVerifier := utxo.NewVerifier(vm.ctx, &vm.clock, vm.fx)

0 commit comments

Comments
 (0)