Skip to content

Commit

Permalink
core/vm: surface some internal methods (ethereum#20958)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Aug 30, 2024
1 parent 1f45af0 commit 65c9a38
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions core/vm/eips.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,48 @@ package vm

import (
"fmt"
"sort"

"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/params"
"github.com/holiman/uint256"
)

var activators = map[int]func(*JumpTable){
3855: enable3855,
3198: enable3198,
2929: enable2929,
2200: enable2200,
1884: enable1884,
1344: enable1344,
}

// EnableEIP enables the given EIP on the config.
// This operation writes in-place, and callers need to ensure that the globally
// defined jump tables are not polluted.
func EnableEIP(eipNum int, jt *JumpTable) error {
switch eipNum {
case 3855:
enable3855(jt)
case 3198:
enable3198(jt)
case 2929:
enable2929(jt)
case 2200:
enable2200(jt)
case 1884:
enable1884(jt)
case 1344:
enable1344(jt)
default:
enablerFn, ok := activators[eipNum]
if !ok {
return fmt.Errorf("undefined eip %d", eipNum)
}
enablerFn(jt)
return nil
}

func ValidEip(eipNum int) bool {
_, ok := activators[eipNum]
return ok
}

func ActivateableEips() []string {
var nums []string
for k := range activators {
nums = append(nums, fmt.Sprintf("%d", k))
}
sort.Strings(nums)
return nums
}

// enable1884 applies EIP-1884 to the given jump table:
// - Increase cost of BALANCE to 700
// - Increase cost of EXTCODEHASH to 700
Expand Down

0 comments on commit 65c9a38

Please sign in to comment.