-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename EVMAccessControl to TransactionFilter and move validation to t…
…xpool
- Loading branch information
Showing
9 changed files
with
68 additions
and
69 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
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,38 @@ | ||
package txfilter | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/contracts/oasys" | ||
"github.com/ethereum/go-ethereum/crypto" | ||
) | ||
|
||
var ( | ||
txFilter = common.HexToAddress(oasys.TransactionFilter) | ||
emptyHash common.Hash | ||
) | ||
|
||
type statedb interface { | ||
GetState(addr common.Address, hash common.Hash) common.Hash | ||
} | ||
|
||
// Check the `_createAllowedList` mappings in the `TransactionFilter` contract | ||
func IsAllowedToCreate(state statedb, from common.Address) bool { | ||
hash := computeAddressMapStorageKey(from, 1) | ||
val := state.GetState(txFilter, hash) | ||
return val.Cmp(emptyHash) != 0 | ||
} | ||
|
||
// Check the `_callAllowedList` mappings in the `TransactionFilter` contract | ||
func IsDeniedToCall(state statedb, to common.Address) bool { | ||
hash := computeAddressMapStorageKey(to, 2) | ||
val := state.GetState(txFilter, hash) | ||
return val.Cmp(emptyHash) != 0 | ||
} | ||
|
||
func computeAddressMapStorageKey(address common.Address, slot uint64) common.Hash { | ||
paddedAddress := common.LeftPadBytes(address.Bytes(), 32) | ||
paddedSlot := common.LeftPadBytes(big.NewInt(int64(slot)).Bytes(), 32) | ||
return crypto.Keccak256Hash(paddedAddress, paddedSlot) | ||
} |
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
This file was deleted.
Oops, something went wrong.
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