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

Expose upgrade config in the info API #3266

Merged
merged 1 commit into from
Aug 3, 2024
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
8 changes: 8 additions & 0 deletions api/info/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils/rpc"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
)
Expand All @@ -27,6 +28,7 @@ type Client interface {
Peers(context.Context, ...rpc.Option) ([]Peer, error)
IsBootstrapped(context.Context, string, ...rpc.Option) (bool, error)
GetTxFee(context.Context, ...rpc.Option) (*GetTxFeeResponse, error)
Upgrades(context.Context, ...rpc.Option) (*upgrade.Config, error)
Uptime(context.Context, ids.ID, ...rpc.Option) (*UptimeResponse, error)
GetVMs(context.Context, ...rpc.Option) (map[ids.ID][]string, error)
}
Expand Down Expand Up @@ -101,6 +103,12 @@ func (c *client) GetTxFee(ctx context.Context, options ...rpc.Option) (*GetTxFee
return res, err
}

func (c *client) Upgrades(ctx context.Context, options ...rpc.Option) (*upgrade.Config, error) {
res := &upgrade.Config{}
err := c.requester.SendRequest(ctx, "info.upgrades", struct{}{}, res, options...)
return res, err
}

func (c *client) Uptime(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (*UptimeResponse, error) {
res := &UptimeResponse{}
err := c.requester.SendRequest(ctx, "info.uptime", &UptimeRequest{
Expand Down
13 changes: 13 additions & 0 deletions api/info/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/ava-labs/avalanchego/network/peer"
"github.com/ava-labs/avalanchego/snow/networking/benchlist"
"github.com/ava-labs/avalanchego/snow/validators"
"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/json"
Expand Down Expand Up @@ -53,6 +54,7 @@ type Parameters struct {
NetworkID uint32
TxFeeConfig genesis.TxFeeConfig
VMManager vms.Manager
Upgrades upgrade.Config
}

func NewService(
Expand Down Expand Up @@ -283,6 +285,17 @@ func (i *Info) IsBootstrapped(_ *http.Request, args *IsBootstrappedArgs, reply *
return nil
}

// Upgrades returns the upgrade schedule this node is running.
func (i *Info) Upgrades(_ *http.Request, _ *struct{}, reply *upgrade.Config) error {
i.log.Debug("API called",
zap.String("service", "info"),
zap.String("method", "upgrades"),
)

*reply = i.Parameters.Upgrades
return nil
}

// UptimeResponse are the results from calling Uptime
type UptimeResponse struct {
// RewardingStakePercentage shows what percent of network stake thinks we're
Expand Down
1 change: 1 addition & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,7 @@ func (n *Node) initInfoAPI() error {
NetworkID: n.Config.NetworkID,
TxFeeConfig: n.Config.TxFeeConfig,
VMManager: n.VMManager,
Upgrades: n.Config.UpgradeConfig,
},
n.Log,
n.vdrs,
Expand Down
2 changes: 1 addition & 1 deletion upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

var (
InitiallyActiveTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC)
UnscheduledActivationTime = time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC)
UnscheduledActivationTime = time.Date(9999, time.December, 1, 0, 0, 0, 0, time.UTC)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON marshaling actually doesn't support timestamps with years >9999 because the format is fixed width.


Mainnet = Config{
ApricotPhase1Time: time.Date(2021, time.March, 31, 14, 0, 0, 0, time.UTC),
Expand Down
Loading