Skip to content

Commit

Permalink
Merge branch 'master' into qdm12/libevm/metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 authored Jan 31, 2025
2 parents addccf9 + 2718ad1 commit 82af695
Show file tree
Hide file tree
Showing 21 changed files with 190 additions and 102 deletions.
11 changes: 5 additions & 6 deletions consensus/dummy/dynamic_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var (
ApricotPhase4BlockGasCostStep = big.NewInt(50_000)
ApricotPhase4TargetBlockRate uint64 = 2 // in seconds
ApricotPhase5BlockGasCostStep = big.NewInt(200_000)
rollupWindow uint64 = 10
)

// CalcBaseFee takes the previous header and the timestamp of its child block
Expand Down Expand Up @@ -87,7 +86,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, timestamp uin
// Add in the gas used by the parent block in the correct place
// If the parent consumed gas within the rollup window, add the consumed
// gas in.
if roll < rollupWindow {
if roll < params.RollupWindow {
var blockGasCost, parentExtraStateGasUsed uint64
switch {
case isApricotPhase5:
Expand Down Expand Up @@ -133,13 +132,13 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, timestamp uin
}
}

slot := rollupWindow - 1 - roll
slot := params.RollupWindow - 1 - roll
start := slot * wrappers.LongLen
updateLongWindow(newRollupWindow, start, addedGas)
}

// Calculate the amount of gas consumed within the rollup window.
totalGas := sumLongWindow(newRollupWindow, int(rollupWindow))
totalGas := sumLongWindow(newRollupWindow, params.RollupWindow)

if totalGas == parentGasTarget {
return newRollupWindow, baseFee, nil
Expand Down Expand Up @@ -167,9 +166,9 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, timestamp uin
// for the interval during which no blocks were produced.
// We use roll/rollupWindow, so that the transition is applied for every [rollupWindow] seconds
// that has elapsed between the parent and this block.
if roll > rollupWindow {
if roll > params.RollupWindow {
// Note: roll/rollupWindow must be greater than 1 since we've checked that roll > rollupWindow
baseFeeDelta = new(big.Int).Mul(baseFeeDelta, new(big.Int).SetUint64(roll/rollupWindow))
baseFeeDelta = new(big.Int).Mul(baseFeeDelta, new(big.Int).SetUint64(roll/params.RollupWindow))
}
baseFee.Sub(baseFee, baseFeeDelta)
}
Expand Down
4 changes: 4 additions & 0 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,10 @@ func overrideConfig(original *params.ChainConfig, override *params.ChainConfig)
copy.EtnaTimestamp = timestamp
canon = false
}
if timestamp := override.FUpgradeTimestamp; timestamp != nil {
copy.FUpgradeTimestamp = timestamp
canon = false
}
if timestamp := override.CancunTime; timestamp != nil {
copy.CancunTime = timestamp
canon = false
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.8

require (
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/ava-labs/avalanchego v1.12.2-0.20250116172728-54d8b06b8625
github.com/ava-labs/avalanchego v1.12.3-warp-verify4
github.com/cespare/cp v0.1.0
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233
github.com/davecgh/go-spew v1.1.1
Expand Down Expand Up @@ -90,7 +90,6 @@ require (
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.12.2-0.20250116172728-54d8b06b8625 h1:sbmfwhpetCKI7Unzw9jJ+2HWLRFM7vq7th0pH2LclCQ=
github.com/ava-labs/avalanchego v1.12.2-0.20250116172728-54d8b06b8625/go.mod h1:oK/C7ZGo5cAEayBKBoawh2EpOo3E9gD1rpd9NAM0RkQ=
github.com/ava-labs/avalanchego v1.12.3-warp-verify4 h1:8YsFAZUC7PyvgZVpZe+kwpHBa7p1e3pDedS8/NeXQhU=
github.com/ava-labs/avalanchego v1.12.3-warp-verify4/go.mod h1:Er2qCyxI4qQKDlNjwwWdOa+/cxCbuEy/z8WgxtXy0N0=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down Expand Up @@ -416,8 +416,6 @@ github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5Vgl
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d h1:AREM5mwr4u1ORQBMvzfzBgpsctsbQikCVpvC+tX285E=
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
Expand Down
5 changes: 3 additions & 2 deletions params/avalanche_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math/big"

"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/utils/wrappers"
)

// Minimum Gas Price
Expand All @@ -32,8 +33,8 @@ const (
ApricotPhase5BaseFeeChangeDenominator uint64 = 36
EtnaMinBaseFee int64 = GWei

DynamicFeeExtraDataSize = 80
RollupWindow uint64 = 10
RollupWindow = 10 // in seconds
DynamicFeeExtraDataSize = wrappers.LongLen * RollupWindow

// The base cost to charge per atomic transaction. Added in Apricot Phase 5.
AtomicTxBaseCost uint64 = 10_000
Expand Down
49 changes: 49 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var (
CortinaBlockTimestamp: utils.NewUint64(0),
DurangoBlockTimestamp: utils.NewUint64(0),
EtnaTimestamp: utils.NewUint64(0),
FUpgradeTimestamp: utils.NewUint64(0),
},
}

Expand Down Expand Up @@ -107,6 +108,7 @@ var (
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -137,6 +139,7 @@ var (
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -168,6 +171,7 @@ var (
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -200,6 +204,7 @@ var (
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -232,6 +237,7 @@ var (
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -264,6 +270,7 @@ var (
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -296,6 +303,7 @@ var (
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -328,6 +336,7 @@ var (
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -360,6 +369,7 @@ var (
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -392,6 +402,7 @@ var (
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -424,6 +435,7 @@ var (
CortinaBlockTimestamp: utils.NewUint64(0),
DurangoBlockTimestamp: nil,
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -457,6 +469,7 @@ var (
CortinaBlockTimestamp: utils.NewUint64(0),
DurangoBlockTimestamp: utils.NewUint64(0),
EtnaTimestamp: nil,
FUpgradeTimestamp: nil,
},
}

Expand Down Expand Up @@ -491,6 +504,42 @@ var (
CortinaBlockTimestamp: utils.NewUint64(0),
DurangoBlockTimestamp: utils.NewUint64(0),
EtnaTimestamp: utils.NewUint64(0),
FUpgradeTimestamp: nil,
},
}

TestFUpgradeChainConfig = &ChainConfig{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ShanghaiTime: utils.NewUint64(0),
CancunTime: utils.NewUint64(0),
NetworkUpgrades: NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
ApricotPhase4BlockTimestamp: utils.NewUint64(0),
ApricotPhase5BlockTimestamp: utils.NewUint64(0),
ApricotPhasePre6BlockTimestamp: utils.NewUint64(0),
ApricotPhase6BlockTimestamp: utils.NewUint64(0),
ApricotPhasePost6BlockTimestamp: utils.NewUint64(0),
BanffBlockTimestamp: utils.NewUint64(0),
CortinaBlockTimestamp: utils.NewUint64(0),
DurangoBlockTimestamp: utils.NewUint64(0),
EtnaTimestamp: utils.NewUint64(0),
FUpgradeTimestamp: utils.NewUint64(0),
},
}

Expand Down
19 changes: 18 additions & 1 deletion params/network_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type NetworkUpgrades struct {
// Note: EIP-4844 BlobTxs are not enabled in the mempool and blocks are not
// allowed to contain them. For details see https://github.com/avalanche-foundation/ACPs/pull/131
EtnaTimestamp *uint64 `json:"etnaTimestamp,omitempty"`
// FUpgrade is a placeholder for the next upgrade.
// (nil = no fork, 0 = already activated)
FUpgradeTimestamp *uint64 `json:"fUpgradeTimestamp,omitempty"`
}

func (n *NetworkUpgrades) Equal(other *NetworkUpgrades) bool {
Expand Down Expand Up @@ -84,6 +87,9 @@ func (n *NetworkUpgrades) CheckNetworkUpgradesCompatible(newcfg *NetworkUpgrades
if isForkTimestampIncompatible(n.EtnaTimestamp, newcfg.EtnaTimestamp, time) {
return newTimestampCompatError("Etna fork block timestamp", n.EtnaTimestamp, newcfg.EtnaTimestamp)
}
if isForkTimestampIncompatible(n.FUpgradeTimestamp, newcfg.FUpgradeTimestamp, time) {
return newTimestampCompatError("F-Upgrade fork block timestamp", n.FUpgradeTimestamp, newcfg.FUpgradeTimestamp)
}

return nil
}
Expand All @@ -102,6 +108,7 @@ func (n *NetworkUpgrades) forkOrder() []fork {
{name: "cortinaBlockTimestamp", timestamp: n.CortinaBlockTimestamp},
{name: "durangoBlockTimestamp", timestamp: n.DurangoBlockTimestamp},
{name: "etnaTimestamp", timestamp: n.EtnaTimestamp},
{name: "fUpgradeTimestamp", timestamp: n.FUpgradeTimestamp},
}
}

Expand Down Expand Up @@ -177,6 +184,12 @@ func (n *NetworkUpgrades) IsEtna(time uint64) bool {
return isTimestampForked(n.EtnaTimestamp, time)
}

// IsFUpgrade returns whether [time] represents a block
// with a timestamp after the F upgrade time.
func (n *NetworkUpgrades) IsFUpgrade(time uint64) bool {
return isTimestampForked(n.FUpgradeTimestamp, time)
}

func (n *NetworkUpgrades) Description() string {
var banner string
banner += fmt.Sprintf(" - Apricot Phase 1 Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.3.0)\n", ptrToString(n.ApricotPhase1BlockTimestamp))
Expand All @@ -190,7 +203,8 @@ func (n *NetworkUpgrades) Description() string {
banner += fmt.Sprintf(" - Banff Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.9.0)\n", ptrToString(n.BanffBlockTimestamp))
banner += fmt.Sprintf(" - Cortina Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.10.0)\n", ptrToString(n.CortinaBlockTimestamp))
banner += fmt.Sprintf(" - Durango Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0)\n", ptrToString(n.DurangoBlockTimestamp))
banner += fmt.Sprintf(" - Etna Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.12.0)\n", ptrToString(n.EtnaTimestamp))
banner += fmt.Sprintf(" - Etna Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.12.0)\n", ptrToString(n.EtnaTimestamp))
banner += fmt.Sprintf(" - F-Upgrade Timestamp: @%-10v (Unscheduled)\n", ptrToString(n.FUpgradeTimestamp))
return banner
}

Expand All @@ -208,6 +222,7 @@ func getNetworkUpgrades(agoUpgrade upgrade.Config) NetworkUpgrades {
CortinaBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.CortinaTime),
DurangoBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.DurangoTime),
EtnaTimestamp: utils.TimeToNewUint64(agoUpgrade.EtnaTime),
FUpgradeTimestamp: utils.TimeToNewUint64(agoUpgrade.FUpgradeTime),
}
}

Expand All @@ -218,6 +233,7 @@ type AvalancheRules struct {
IsCortina bool
IsDurango bool
IsEtna bool
IsFUpgrade bool
}

func (n *NetworkUpgrades) GetAvalancheRules(timestamp uint64) AvalancheRules {
Expand All @@ -234,5 +250,6 @@ func (n *NetworkUpgrades) GetAvalancheRules(timestamp uint64) AvalancheRules {
IsCortina: n.IsCortina(timestamp),
IsDurango: n.IsDurango(timestamp),
IsEtna: n.IsEtna(timestamp),
IsFUpgrade: n.IsFUpgrade(timestamp),
}
}
7 changes: 4 additions & 3 deletions plugin/evm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"github.com/ava-labs/avalanchego/snow/validators/validatorstest"
"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils/cb58"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/crypto/bls/signer/localsigner"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/utils/formatting"
"github.com/ava-labs/avalanchego/utils/hashing"
Expand Down Expand Up @@ -126,7 +126,8 @@ var (
genesisJSONCortina = genesisJSON(params.TestCortinaChainConfig)
genesisJSONDurango = genesisJSON(params.TestDurangoChainConfig)
genesisJSONEtna = genesisJSON(params.TestEtnaChainConfig)
genesisJSONLatest = genesisJSONEtna
genesisJSONFUpgrade = genesisJSON(params.TestFUpgradeChainConfig)
genesisJSONLatest = genesisJSONFUpgrade

genesisJSONCancun = genesisJSON(activateCancun(params.TestChainConfig))

Expand Down Expand Up @@ -220,7 +221,7 @@ func NewContext() *snow.Context {
return subnetID, nil
},
}
blsSecretKey, err := bls.NewSigner()
blsSecretKey, err := localsigner.New()
if err != nil {
panic(err)
}
Expand Down
7 changes: 4 additions & 3 deletions plugin/evm/vm_warp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
avagoUtils "github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/crypto/bls/signer/localsigner"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/vms/components/chain"
avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp"
Expand Down Expand Up @@ -265,13 +266,13 @@ func testWarpVMTransaction(t *testing.T, unsignedMessage *avalancheWarp.Unsigned
defer logsSub.Unsubscribe()

nodeID1 := ids.GenerateTestNodeID()
blsSecretKey1, err := bls.NewSigner()
blsSecretKey1, err := localsigner.New()
require.NoError(err)
blsPublicKey1 := blsSecretKey1.PublicKey()
blsSignature1 := blsSecretKey1.Sign(unsignedMessage.Bytes())

nodeID2 := ids.GenerateTestNodeID()
blsSecretKey2, err := bls.NewSigner()
blsSecretKey2, err := localsigner.New()
require.NoError(err)
blsPublicKey2 := blsSecretKey2.PublicKey()
blsSignature2 := blsSecretKey2.Sign(unsignedMessage.Bytes())
Expand Down Expand Up @@ -528,7 +529,7 @@ func testReceiveWarpMessage(
weight uint64
}
newSigner := func(networkID ids.ID, weight uint64) signer {
secret, err := bls.NewSigner()
secret, err := localsigner.New()
require.NoError(err)
return signer{
networkID: networkID,
Expand Down
Loading

0 comments on commit 82af695

Please sign in to comment.