diff --git a/consensus/XDPoS/api.go b/consensus/XDPoS/api.go index 67a9d7698a98..3bace2c902b6 100644 --- a/consensus/XDPoS/api.go +++ b/consensus/XDPoS/api.go @@ -580,7 +580,7 @@ func (api *API) getRewardFileNamesInRange(begin, end *rpc.BlockNumber) ([]reward // compact the slice's memory ret := rewardFileNames[startIndex:endIndex] - return ret[:len(ret):len(ret)], nil + return slices.Clip(ret), nil } func getEpochReward(account common.Address, header *types.Header) (AccountEpochReward, error) { diff --git a/core/vm/evm.go b/core/vm/evm.go index f9101f2718c6..6bec1cf1c0d0 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -19,6 +19,7 @@ package vm import ( "errors" "math/big" + "slices" "sync/atomic" "github.com/XinFinOrg/XDPoSChain/XDCx/tradingstate" @@ -170,20 +171,20 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, tradingStat default: evm.table = &frontierInstructionSet } + var extraEips []int if len(evm.Config.ExtraEips) > 0 { // Deep-copy jumptable to prevent modification of opcodes in other tables evm.table = copyJumpTable(evm.table) - } - extraEips := make([]int, 0, len(evm.Config.ExtraEips)) - for _, eip := range evm.Config.ExtraEips { - if err := EnableEIP(eip, evm.table); err != nil { - // Disable it, so caller can check if it's activated or not - log.Error("EIP activation failed", "eip", eip, "error", err) - } else { - extraEips = append(extraEips, eip) + for _, eip := range evm.Config.ExtraEips { + if err := EnableEIP(eip, evm.table); err != nil { + // Disable it, so caller can check if it's activated or not + log.Error("EIP activation failed", "eip", eip, "error", err) + } else { + extraEips = append(extraEips, eip) + } } } - evm.Config.ExtraEips = extraEips[0:len(extraEips):len(extraEips)] + evm.Config.ExtraEips = slices.Clip(extraEips) return evm }