Skip to content

Commit

Permalink
rename DUpgrade to Durango (#1029)
Browse files Browse the repository at this point in the history
* rename DUpgrade to Durango

* Update core/evm.go

Signed-off-by: Darioush Jalali <[email protected]>

* Update x/warp/contract.go

Signed-off-by: Darioush Jalali <[email protected]>

* Update precompile/contracts/nativeminter/contract.go

Signed-off-by: Darioush Jalali <[email protected]>

* Update predicate/predicate_bytes.go

Signed-off-by: Darioush Jalali <[email protected]>

* Update precompile/precompileconfig/config.go

Signed-off-by: Darioush Jalali <[email protected]>

* Update x/warp/config.go

Signed-off-by: Darioush Jalali <[email protected]>

* Update x/warp/contract.go

Signed-off-by: Darioush Jalali <[email protected]>

* Update x/warp/contract.go

Signed-off-by: Darioush Jalali <[email protected]>

---------

Signed-off-by: Darioush Jalali <[email protected]>
Co-authored-by: Darioush Jalali <[email protected]>
  • Loading branch information
ceyonur and darioush committed Jan 4, 2024
1 parent 491ffc2 commit 36120e9
Show file tree
Hide file tree
Showing 45 changed files with 169 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestVerify(t *testing.T) {
Config: NewConfig(utils.NewUint64(3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}),
ChainConfig: func() precompileconfig.ChainConfig {
config := precompileconfig.NewMockChainConfig(gomock.NewController(t))
config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes()
config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes()
return config
}(),
ExpectedError: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func Set{{.Contract.Type}}AllowListStatus(stateDB contract.StateDB, address comm
// assumes that [input] does not include selector (omits first 4 func signature bytes)
func Unpack{{capitalise .Normalized.Name}}Input(input []byte) ({{capitalise .Normalized.Name}}Input, error) {
inputStruct := {{capitalise .Normalized.Name}}Input{}
// The strict mode in decoding is disabled after DUpgrade. You can re-enable by changing the last argument to true.
// The strict mode in decoding is disabled after Durango. You can re-enable by changing the last argument to true.
err := {{$contract.Type}}ABI.UnpackInputIntoInterface(&inputStruct, "{{.Original.Name}}", input, false)
return inputStruct, err
Expand All @@ -160,7 +160,7 @@ func Pack{{.Normalized.Name}}(inputStruct {{capitalise .Normalized.Name}}Input)
// Unpack{{capitalise .Normalized.Name}}Input attempts to unpack [input] into the {{$bindedType}} type argument
// assumes that [input] does not include selector (omits first 4 func signature bytes)
func Unpack{{capitalise .Normalized.Name}}Input(input []byte)({{$bindedType}}, error) {
// The strict mode in decoding is disabled after DUpgrade. You can re-enable by changing the last argument to true.
// The strict mode in decoding is disabled after Durango. You can re-enable by changing the last argument to true.
res, err := {{$contract.Type}}ABI.UnpackInput("{{$method.Original.Name}}", input, false)
if err != nil {
return {{bindtypenew $input.Type $structs}}, err
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func Transaction(ctx *cli.Context) error {
r.Error = errors.New("gas * maxFeePerGas exceeds 256 bits")
}
// Check whether the init code size has been exceeded.
if chainConfig.IsDUpgrade(0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
if chainConfig.IsDurango(0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
r.Error = errors.New("max initcode size exceeded")
}
results = append(results, r)
Expand Down
2 changes: 1 addition & 1 deletion consensus/dummy/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (self *DummyEngine) verifyHeader(chain consensus.ChainHeaderReader, header
return errUnclesUnsupported
}
switch {
case config.IsDUpgrade(header.Time):
case config.IsDurango(header.Time):
if len(header.Extra) < params.DynamicFeeExtraDataSize {
return fmt.Errorf("expected extra-data field length >= %d, found %d", params.DynamicFeeExtraDataSize, len(header.Extra))
}
Expand Down
4 changes: 2 additions & 2 deletions core/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
if !ok {
return newEVMBlockContext(header, chain, author, nil)
}
// Prior to the DUpgrade, the VM enforces the extra data is smaller than or
// equal to this size. After the DUpgrade, the VM pre-verifies the extra
// Prior to Durango, the VM enforces the extra data is smaller than or
// equal to this size. After Durango, the VM pre-verifies the extra
// data past the dynamic fee rollup window is valid.
predicateResults, err := predicate.ParseResults(predicateBytes)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ func (s *StateDB) commit(deleteEmptyObjects bool, snaps *snapshot.Tree, blockHas
//
// Potential EIPs:
// - Reset access list (Berlin)
// - Add coinbase to access list (EIP-3651/DUpgrade)
// - Add coinbase to access list (EIP-3651/Durango)
// - Reset transient storage (EIP-1153)
func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) {
if rules.IsSubnetEVM {
Expand All @@ -1191,7 +1191,7 @@ func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, d
al.AddSlot(el.Address, key)
}
}
if rules.IsDUpgrade { // EIP-3651: warm coinbase
if rules.IsDurango { // EIP-3651: warm coinbase
al.AddAddress(coinbase)
}

Expand Down
4 changes: 2 additions & 2 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func TestStateProcessorErrors(t *testing.T) {
}
}

// ErrMaxInitCodeSizeExceeded, for this we need extra Shanghai (DUpgrade/EIP-3860) enabled.
// ErrMaxInitCodeSizeExceeded, for this we need extra Shanghai (Durango/EIP-3860) enabled.
{
var (
db = rawdb.NewMemoryDatabase()
Expand All @@ -320,7 +320,7 @@ func TestStateProcessorErrors(t *testing.T) {
MuirGlacierBlock: big.NewInt(0),
MandatoryNetworkUpgrades: params.MandatoryNetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
DUpgradeTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
},
FeeConfig: params.DefaultFeeConfig,
},
Expand Down
4 changes: 2 additions & 2 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b
}
gas += z * params.TxDataZeroGas

if isContractCreation && rules.IsDUpgrade {
if isContractCreation && rules.IsDurango {
lenWords := toWordSize(dataLen)
if (math.MaxUint64-gas)/params.InitCodeWordGas < lenWords {
return 0, ErrGasUintOverflow
Expand Down Expand Up @@ -425,7 +425,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}

// Check whether the init code size has been exceeded.
if rules.IsDUpgrade && contractCreation && len(msg.Data) > params.MaxInitCodeSize {
if rules.IsDurango && contractCreation && len(msg.Data) > params.MaxInitCodeSize {
return nil, fmt.Errorf("%w: code size %v limit %v", vmerrs.ErrMaxInitCodeSizeExceeded, len(msg.Data), params.MaxInitCodeSize)
}

Expand Down
2 changes: 1 addition & 1 deletion core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
pool.rules.Store(&rules)
pool.eip2718.Store(rules.IsSubnetEVM)
pool.eip1559.Store(rules.IsSubnetEVM)
pool.eip3860.Store(rules.IsDUpgrade)
pool.eip3860.Store(rules.IsDurango)
}

// promoteExecutables moves transactions that have become processable from the
Expand Down
4 changes: 2 additions & 2 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
// If jump table was not initialised we set the default one.
var table *JumpTable
switch {
case evm.chainRules.IsDUpgrade:
table = &dUpgradeInstructionSet
case evm.chainRules.IsDurango:
table = &durangoInstructionSet
case evm.chainRules.IsSubnetEVM:
table = &subnetEVMInstructionSet
case evm.chainRules.IsIstanbul:
Expand Down
8 changes: 4 additions & 4 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var (
constantinopleInstructionSet = newConstantinopleInstructionSet()
istanbulInstructionSet = newIstanbulInstructionSet()
subnetEVMInstructionSet = newSubnetEVMInstructionSet()
dUpgradeInstructionSet = newDUpgradeInstructionSet()
durangoInstructionSet = newDurangoInstructionSet()
)

// JumpTable contains the EVM opcodes supported at a given fork.
Expand All @@ -87,9 +87,9 @@ func validate(jt JumpTable) JumpTable {
return jt
}

// newDUpgradeInstructionSet returns the frontier, homestead, byzantium,
// constantinople, istanbul, petersburg, subnet-evm, d-upgrade instructions.
func newDUpgradeInstructionSet() JumpTable {
// newDurangoInstructionSet returns the frontier, homestead, byzantium,
// constantinople, istanbul, petersburg, subnet-evm, durango instructions.
func newDurangoInstructionSet() JumpTable {
instructionSet := newSubnetEVMInstructionSet()
enable3855(&instructionSet) // PUSH0 instruction
enable3860(&instructionSet) // Limit and meter initcode
Expand Down
4 changes: 2 additions & 2 deletions core/vm/jump_table_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
// the rules.
func LookupInstructionSet(rules params.Rules) (JumpTable, error) {
switch {
case rules.IsDUpgrade:
return newDUpgradeInstructionSet(), nil
case rules.IsDurango:
return newDurangoInstructionSet(), nil
case rules.IsSubnetEVM:
return newSubnetEVMInstructionSet(), nil
case rules.IsIstanbul:
Expand Down
2 changes: 1 addition & 1 deletion core/vm/jump_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

// TestJumpTableCopy tests that deep copy is necessery to prevent modify shared jump table
func TestJumpTableCopy(t *testing.T) {
tbl := newDUpgradeInstructionSet()
tbl := newDurangoInstructionSet()
require.Equal(t, uint64(0), tbl[SLOAD].constantGas)

// a deep copy won't modify the shared jump table
Expand Down
4 changes: 2 additions & 2 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,8 @@ func overrideConfig(original *params.ChainConfig, override *params.ChainConfig)
copy.SubnetEVMTimestamp = timestamp
canon = false
}
if timestamp := override.DUpgradeTimestamp; timestamp != nil {
copy.DUpgradeTimestamp = timestamp
if timestamp := override.DurangoTimestamp; timestamp != nil {
copy.DurangoTimestamp = timestamp
canon = false
}
if timestamp := override.CancunTime; timestamp != nil {
Expand Down
4 changes: 2 additions & 2 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (w *worker) commitTransaction(env *environment, tx *types.Transaction, coin
blockContext vm.BlockContext
)

if env.rules.IsDUpgrade {
if env.rules.IsDurango {
results, err := core.CheckPredicates(env.rules, env.predicateContext, tx)
if err != nil {
log.Debug("Transaction predicate failed verification in miner", "tx", tx.Hash(), "err", err)
Expand Down Expand Up @@ -337,7 +337,7 @@ func (w *worker) commitTransactions(env *environment, txs *types.TransactionsByP
// commit runs any post-transaction state modifications, assembles the final block
// and commits new work if consensus engine is running.
func (w *worker) commit(env *environment) (*types.Block, error) {
if env.rules.IsDUpgrade {
if env.rules.IsDurango {
predicateResultsBytes, err := env.predicateResults.Bytes()
if err != nil {
return nil, fmt.Errorf("failed to marshal predicate results: %w", err)
Expand Down
16 changes: 8 additions & 8 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var (
MuirGlacierBlock: big.NewInt(0),
MandatoryNetworkUpgrades: MandatoryNetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
DUpgradeTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
},
GenesisPrecompiles: Precompiles{},
UpgradeConfig: UpgradeConfig{},
Expand Down Expand Up @@ -279,7 +279,7 @@ func (c *ChainConfig) Description() string {
}
banner += "Mandatory Upgrades:\n"
banner += fmt.Sprintf(" - SubnetEVM Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.10.0)\n", ptrToString(c.SubnetEVMTimestamp))
banner += fmt.Sprintf(" - DUpgrade Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0)\n", ptrToString(c.DUpgradeTimestamp))
banner += fmt.Sprintf(" - Durango Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0)\n", ptrToString(c.DurangoTimestamp))
banner += fmt.Sprintf(" - Cancun Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0)\n", ptrToString(c.CancunTime))
banner += "\n"

Expand Down Expand Up @@ -370,10 +370,10 @@ func (c *ChainConfig) IsSubnetEVM(time uint64) bool {
return utils.IsTimestampForked(c.SubnetEVMTimestamp, time)
}

// IsDUpgrade returns whether [time] represents a block
// with a timestamp after the DUpgrade upgrade time.
func (c *ChainConfig) IsDUpgrade(time uint64) bool {
return utils.IsTimestampForked(c.DUpgradeTimestamp, time)
// IsDurango returns whether [time] represents a block
// with a timestamp after the Durango upgrade time.
func (c *ChainConfig) IsDurango(time uint64) bool {
return utils.IsTimestampForked(c.DurangoTimestamp, time)
}

// IsCancun returns whether [time] represents a block
Expand Down Expand Up @@ -717,7 +717,7 @@ type Rules struct {

// Rules for Avalanche releases
IsSubnetEVM bool
IsDUpgrade bool
IsDurango bool

// ActivePrecompiles maps addresses to stateful precompiled contracts that are enabled
// for this rule set.
Expand Down Expand Up @@ -764,7 +764,7 @@ func (c *ChainConfig) AvalancheRules(blockNum *big.Int, timestamp uint64) Rules
rules := c.rules(blockNum, timestamp)

rules.IsSubnetEVM = c.IsSubnetEVM(timestamp)
rules.IsDUpgrade = c.IsDUpgrade(timestamp)
rules.IsDurango = c.IsDurango(timestamp)

// Initialize the stateful precompiles that should be enabled at [blockTimestamp].
rules.ActivePrecompiles = make(map[common.Address]precompileconfig.Config)
Expand Down
4 changes: 2 additions & 2 deletions params/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func TestChainConfigMarshalWithUpgrades(t *testing.T) {
MuirGlacierBlock: big.NewInt(0),
MandatoryNetworkUpgrades: MandatoryNetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
DUpgradeTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
},
GenesisPrecompiles: Precompiles{},
},
Expand Down Expand Up @@ -310,7 +310,7 @@ func TestChainConfigMarshalWithUpgrades(t *testing.T) {
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"subnetEVMTimestamp": 0,
"dUpgradeTimestamp": 0,
"durangoTimestamp": 0,
"upgrades": {
"precompileUpgrades": [
{
Expand Down
18 changes: 9 additions & 9 deletions params/network_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import (
var (
LocalNetworkUpgrades = MandatoryNetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
DUpgradeTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
}

FujiNetworkUpgrades = MandatoryNetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
// DUpgradeTimestamp: utils.NewUint64(0), // TODO: Uncomment and set this to the correct value
// DurangoTimestamp: utils.NewUint64(0), // TODO: Uncomment and set this to the correct value
}

MainnetNetworkUpgrades = MandatoryNetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
// DUpgradeTimestamp: utils.NewUint64(0), // TODO: Uncomment and set this to the correct value
// DurangoTimestamp: utils.NewUint64(0), // TODO: Uncomment and set this to the correct value
}

UnitTestNetworkUpgrades = MandatoryNetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
DUpgradeTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0),
}
)

Expand All @@ -36,10 +36,10 @@ var (
type MandatoryNetworkUpgrades struct {
// SubnetEVMTimestamp is a placeholder that activates Avalanche Upgrades prior to ApricotPhase6 (nil = no fork, 0 = already activated)
SubnetEVMTimestamp *uint64 `json:"subnetEVMTimestamp,omitempty"`
// DUpgrade activates the Shanghai Execution Spec Upgrade from Ethereum (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md#included-eips)
// Durango activates the Shanghai Execution Spec Upgrade from Ethereum (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md#included-eips)
// and Avalanche Warp Messaging. (nil = no fork, 0 = already activated)
// Note: EIP-4895 is excluded since withdrawals are not relevant to the Avalanche C-Chain or Subnets running the EVM.
DUpgradeTimestamp *uint64 `json:"dUpgradeTimestamp,omitempty"`
DurangoTimestamp *uint64 `json:"durangoTimestamp,omitempty"`
// Cancun activates the Cancun upgrade from Ethereum. (nil = no fork, 0 = already activated)
CancunTime *uint64 `json:"cancunTime,omitempty"`
}
Expand All @@ -48,8 +48,8 @@ func (m *MandatoryNetworkUpgrades) CheckMandatoryCompatible(newcfg *MandatoryNet
if isForkTimestampIncompatible(m.SubnetEVMTimestamp, newcfg.SubnetEVMTimestamp, time) {
return newTimestampCompatError("SubnetEVM fork block timestamp", m.SubnetEVMTimestamp, newcfg.SubnetEVMTimestamp)
}
if isForkTimestampIncompatible(m.DUpgradeTimestamp, newcfg.DUpgradeTimestamp, time) {
return newTimestampCompatError("DUpgrade fork block timestamp", m.DUpgradeTimestamp, newcfg.DUpgradeTimestamp)
if isForkTimestampIncompatible(m.DurangoTimestamp, newcfg.DurangoTimestamp, time) {
return newTimestampCompatError("Durango fork block timestamp", m.DurangoTimestamp, newcfg.DurangoTimestamp)
}
if isForkTimestampIncompatible(m.CancunTime, newcfg.CancunTime, time) {
return newTimestampCompatError("Cancun fork block timestamp", m.CancunTime, m.CancunTime)
Expand All @@ -60,7 +60,7 @@ func (m *MandatoryNetworkUpgrades) CheckMandatoryCompatible(newcfg *MandatoryNet
func (m *MandatoryNetworkUpgrades) mandatoryForkOrder() []fork {
return []fork{
{name: "subnetEVMTimestamp", timestamp: m.SubnetEVMTimestamp},
{name: "dUpgradeTimestamp", timestamp: m.DUpgradeTimestamp},
{name: "durangoTimestamp", timestamp: m.DurangoTimestamp},
}
}

Expand Down
6 changes: 3 additions & 3 deletions plugin/evm/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ func (b *Block) verifyPredicates(predicateContext *precompileconfig.PredicateCon
rules := b.vm.chainConfig.AvalancheRules(b.ethBlock.Number(), b.ethBlock.Timestamp())

switch {
case !rules.IsDUpgrade && rules.PredicatersExist():
return errors.New("cannot enable predicates before DUpgrade activation")
case !rules.IsDUpgrade:
case !rules.IsDurango && rules.PredicatersExist():
return errors.New("cannot enable predicates before Durango activation")
case !rules.IsDurango:
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/block_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (v blockValidator) SyntacticVerify(b *Block, rules params.Rules) error {
}

switch {
case rules.IsDUpgrade:
case rules.IsDurango:
if len(ethHeader.Extra) < params.DynamicFeeExtraDataSize {
return fmt.Errorf(
"expected header ExtraData to be len >= %d but got %d",
Expand Down
Loading

0 comments on commit 36120e9

Please sign in to comment.