Skip to content

Commit

Permalink
Merge branch 'main' into testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
tak1827 committed Dec 3, 2024
2 parents 38a78a8 + 20e50be commit 3c9be7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 8 additions & 4 deletions contracts/oasys/oasys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ import (
)

const (
// Built-in contract prefixes.
BuiltInContractPrefix1 = "0x0000000000000000" // 8 bytes
BuiltInContractPrefix2 = "0x5200000000000000" // 8 bytes

// Address of contracts in genesis.
EnvironmentAddress = "0x0000000000000000000000000000000000001000"
StakeManagerAddress = "0x0000000000000000000000000000000000001001"
AllowListAddress = "0x0000000000000000000000000000000000001002"
EnvironmentAddress = BuiltInContractPrefix1 + "000000000000000000001000"
StakeManagerAddress = BuiltInContractPrefix1 + "000000000000000000001001"
AllowListAddress = BuiltInContractPrefix1 + "000000000000000000001002"

// Address of initial wallet in genesis.
mainnetGenesisWalletAddress = "0xdF3548cD5e355202AE92e766c7361eA4F6687A61"
testnetGenesisWalletAddress = "0xbf9Ec8a822519C00128f0c7C13f13cafF0501Aea"

// Address of contracts in `oasys-governance-contract`.
EVMAccessControl = "0x520000000000000000000000000000000000003F"
EVMAccessControl = BuiltInContractPrefix2 + "00000000000000000000003F"
)

var (
Expand Down
7 changes: 7 additions & 0 deletions core/vm/evm_access_control.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vm

import (
"bytes"
"errors"
"math/big"

Expand All @@ -18,6 +19,8 @@ var (

evmAccessControl = common.HexToAddress(oasys.EVMAccessControl)
emptyHash common.Hash
buildInPrefix1 = common.FromHex(oasys.BuiltInContractPrefix1)
buildInPrefix2 = common.FromHex(oasys.BuiltInContractPrefix2)
)

// Check the `_createAllowedList` mappings in the `EVMAccessControl` contract
Expand All @@ -29,6 +32,10 @@ func IsAllowedToCreate(state StateDB, from common.Address) bool {

// Check the `_callAllowedList` mappings in the `EVMAccessControl` contract
func IsDeniedToCall(state StateDB, to common.Address) bool {
// Don't deny calls to built-in contracts
if bytes.HasPrefix(to.Bytes(), buildInPrefix1) || bytes.HasPrefix(to.Bytes(), buildInPrefix2) {
return false
}
hash := computeAddressMapStorageKey(to, 2)
val := state.GetState(evmAccessControl, hash)
return val.Cmp(emptyHash) != 0
Expand Down

0 comments on commit 3c9be7b

Please sign in to comment.