-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reserve address spaces for custom precompiles (#176)
* Reserve address spaces for custom precompiles * Add comment documenting the reason for reserving address prefix 0x01 for coreth precompiles
- Loading branch information
1 parent
1a02bee
commit bf21bdc
Showing
3 changed files
with
75 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// (c) 2019-2020, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package precompile | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
// Gas costs for stateful precompiles | ||
// can be added here eg. | ||
// const MintGasCost = 30_000 | ||
|
||
// AddressRange represents a continuous range of addresses | ||
type AddressRange struct { | ||
Start common.Address | ||
End common.Address | ||
} | ||
|
||
// Contains returns true iff [addr] is contained within the (inclusive) | ||
func (a *AddressRange) Contains(addr common.Address) bool { | ||
addrBytes := addr.Bytes() | ||
return bytes.Compare(addrBytes, a.Start[:]) >= 0 && bytes.Compare(addrBytes, a.End[:]) <= 0 | ||
} |