Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetStorageAt with whitelist for proxies deployment #1987

Merged
merged 12 commits into from
Jul 16, 2024
2 changes: 2 additions & 0 deletions go/common/enclave.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ type Enclave interface {
// GetCode returns the code stored at the given address in the state for the given rollup hash.
GetCode(ctx context.Context, address gethcommon.Address, rollupHash *gethcommon.Hash) ([]byte, SystemError)

GetStorageSlot(ctx context.Context, encryptedParams EncryptedParamsGetStorageSlot) (*responses.EnclaveResponse, SystemError)

// Subscribe adds a log subscription to the enclave under the given ID, provided the request is authenticated
// correctly. The events will be populated in the BlockSubmissionResponse. If there is an existing subscription
// with the given ID, it is overwritten.
Expand Down
40 changes: 40 additions & 0 deletions go/common/privacy/whitelist.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package privacy

import (
"math/big"

"github.com/ethereum/go-ethereum/crypto"
)

type Whitelist struct {
AllowedStorageSlots map[string]bool
}

func NewWhitelist() *Whitelist {
whitelistMap := make(map[string]bool)
whitelistMap[toEip1967HashHex("eip1967.proxy.beacon")] = true
whitelistMap[toEip1967HashHex("eip1967.proxy.implementation")] = true
whitelistMap[toEip1967FallbackHashHex("org.zeppelinos.proxy.implementation")] = true
whitelistMap[toEip1967HashHex("eip1967.proxy.admin")] = true
whitelistMap[toEip1967FallbackHashHex("org.zeppelinos.proxy.admin")] = true

return &Whitelist{
AllowedStorageSlots: whitelistMap,
}
}

func toEip1967HashHex(key string) string {
hash := crypto.Keccak256Hash([]byte(key))
hashAsBig := hash.Big()
eipHashHex := "0x" + hashAsBig.Sub(hashAsBig, big.NewInt(1)).Text(16)

return eipHashHex
}

func toEip1967FallbackHashHex(key string) string {
hash := crypto.Keccak256Hash([]byte(key))
hashAsBig := hash.Big()
eipHashHex := "0x" + hashAsBig.Text(16)

return eipHashHex
}
Loading
Loading