github.com/dim4egster/coreth@v0.10.2/precompile/params.go (about)

     1  // (c) 2019-2020, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package precompile
     5  
     6  import (
     7  	"bytes"
     8  
     9  	"github.com/ethereum/go-ethereum/common"
    10  )
    11  
    12  // Gas costs for stateful precompiles
    13  // can be added here eg.
    14  // const MintGasCost = 30_000
    15  
    16  // AddressRange represents a continuous range of addresses
    17  type AddressRange struct {
    18  	Start common.Address
    19  	End   common.Address
    20  }
    21  
    22  // Contains returns true iff [addr] is contained within the (inclusive)
    23  func (a *AddressRange) Contains(addr common.Address) bool {
    24  	addrBytes := addr.Bytes()
    25  	return bytes.Compare(addrBytes, a.Start[:]) >= 0 && bytes.Compare(addrBytes, a.End[:]) <= 0
    26  }
    27  
    28  // Designated addresses of stateful precompiles
    29  // Note: it is important that none of these addresses conflict with each other or any other precompiles
    30  // in core/vm/contracts.go.
    31  // We start at 0x0100000000000000000000000000000000000000 and will increment by 1 from here to reduce
    32  // the risk of conflicts.
    33  var (
    34  	UsedAddresses = []common.Address{
    35  		// precompile contract addresses can be added here
    36  	}
    37  
    38  	// ReservedRanges contains addresses ranges that are reserved
    39  	// for precompiles and cannot be used as EOA or deployed contracts.
    40  	ReservedRanges = []AddressRange{
    41  		{
    42  			// reserved for coreth precompiles
    43  			common.HexToAddress("0x0100000000000000000000000000000000000000"),
    44  			common.HexToAddress("0x01000000000000000000000000000000000000ff"),
    45  		},
    46  	}
    47  )