@@ -148,26 +148,6 @@ func (c *ChainConfig) verifyPrecompileUpgrades() error {
148148 return nil
149149}
150150
151- // verifyStateUpgrades checks [c.StateUpgrades] is well formed:
152- // - the specified blockTimestamps must monotonically increase
153- func (c * ChainConfig ) verifyStateUpgrades () error {
154- var previousUpgradeTimestamp * big.Int
155- for i , upgrade := range c .StateUpgrades {
156- upgradeTimestamp := upgrade .BlockTimestamp
157- // Verify the upgrade's timestamp is greater than 0 (to avoid confusion with genesis).
158- if upgradeTimestamp .Cmp (common .Big0 ) <= 0 {
159- return fmt .Errorf ("StateUpgrade[%d]: config block timestamp (%v) must be greater than 0" , i , upgradeTimestamp )
160- }
161-
162- // Verify specified timestamps are strictly monotonically increasing.
163- if previousUpgradeTimestamp != nil && upgradeTimestamp .Cmp (previousUpgradeTimestamp ) <= 0 {
164- return fmt .Errorf ("StateUpgrade[%d]: config block timestamp (%v) <= previous timestamp (%v)" , i , upgradeTimestamp , previousUpgradeTimestamp )
165- }
166- previousUpgradeTimestamp = upgradeTimestamp
167- }
168- return nil
169- }
170-
171151// getActivePrecompileConfig returns the most recent precompile config corresponding to [address].
172152// If none have occurred, returns nil.
173153func (c * ChainConfig ) getActivePrecompileConfig (address common.Address , blockTimestamp * big.Int ) precompileconfig.Config {
@@ -207,18 +187,6 @@ func (c *ChainConfig) GetActivatingPrecompileConfigs(address common.Address, fro
207187 return configs
208188}
209189
210- // GetActivatingStateUpgrades returns all state upgrades configured to activate during the
211- // state transition from a block with timestamp [from] to a block with timestamp [to].
212- func (c * ChainConfig ) GetActivatingStateUpgrades (from * big.Int , to * big.Int , upgrades []StateUpgrade ) []StateUpgrade {
213- activating := make ([]StateUpgrade , 0 )
214- for _ , upgrade := range upgrades {
215- if utils .IsForkTransition (upgrade .BlockTimestamp , from , to ) {
216- activating = append (activating , upgrade )
217- }
218- }
219- return activating
220- }
221-
222190// CheckPrecompilesCompatible checks if [precompileUpgrades] are compatible with [c] at [headTimestamp].
223191// Returns a ConfigCompatError if upgrades already activated at [headTimestamp] are missing from
224192// [precompileUpgrades]. Upgrades not already activated may be modified or absent from [precompileUpgrades].
@@ -277,44 +245,6 @@ func (c *ChainConfig) checkPrecompileCompatible(address common.Address, precompi
277245 return nil
278246}
279247
280- // CheckStateUpgradesCompatible checks if [stateUpgrades] are compatible with [c] at [headTimestamp].
281- func (c * ChainConfig ) CheckStateUpgradesCompatible (stateUpgrades []StateUpgrade , lastTimestamp * big.Int ) * ConfigCompatError {
282- // All active upgrades (from nil to [lastTimestamp]) must match.
283- activeUpgrades := c .GetActivatingStateUpgrades (nil , lastTimestamp , c .StateUpgrades )
284- newUpgrades := c .GetActivatingStateUpgrades (nil , lastTimestamp , stateUpgrades )
285-
286- // Check activated upgrades are still present.
287- for i , upgrade := range activeUpgrades {
288- if len (newUpgrades ) <= i {
289- // missing upgrade
290- return newCompatError (
291- fmt .Sprintf ("missing StateUpgrade[%d]" , i ),
292- upgrade .BlockTimestamp ,
293- nil ,
294- )
295- }
296- // All upgrades that have activated must be identical.
297- if ! upgrade .Equal (& newUpgrades [i ]) {
298- return newCompatError (
299- fmt .Sprintf ("StateUpgrade[%d]" , i ),
300- upgrade .BlockTimestamp ,
301- newUpgrades [i ].BlockTimestamp ,
302- )
303- }
304- }
305- // then, make sure newUpgrades does not have additional upgrades
306- // that are already activated. (cannot perform retroactive upgrade)
307- if len (newUpgrades ) > len (activeUpgrades ) {
308- return newCompatError (
309- fmt .Sprintf ("cannot retroactively enable StateUpgrade[%d]" , len (activeUpgrades )),
310- nil ,
311- newUpgrades [len (activeUpgrades )].BlockTimestamp , // this indexes to the first element in newUpgrades after the end of activeUpgrades
312- )
313- }
314-
315- return nil
316- }
317-
318248// EnabledStatefulPrecompiles returns current stateful precompile configs that are enabled at [blockTimestamp].
319249func (c * ChainConfig ) EnabledStatefulPrecompiles (blockTimestamp * big.Int ) Precompiles {
320250 statefulPrecompileConfigs := make (Precompiles )
0 commit comments