Skip to content

Commit

Permalink
GetStorageAt with whitelist for proxies deployment (#1987)
Browse files Browse the repository at this point in the history
* TEN RPC: replace custom query with personal transactions

* update rpc method, add todo to do before PR ready

* getStorageAt whitelist implementation.

* Added more exceptions. Fixed null response. Hopefully

* Working proxy deployment.

* Fix for linter and build gate. Some comments.

* dumping progress.

* Fix for test.

* PR review comments.

* Addressed remaining PR comments.

* Removed old  comment.

---------

Co-authored-by: Matt Curtis <[email protected]>
Co-authored-by: StefanIliev545 <[email protected]>
  • Loading branch information
3 people authored Jul 16, 2024
1 parent e9b2977 commit 97792e4
Show file tree
Hide file tree
Showing 15 changed files with 719 additions and 301 deletions.
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

0 comments on commit 97792e4

Please sign in to comment.