Skip to content

Commit

Permalink
getStorageAt whitelist implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanIliev545 committed Jul 11, 2024
1 parent fd59ed7 commit c7517c1
Show file tree
Hide file tree
Showing 14 changed files with 683 additions and 302 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
28 changes: 28 additions & 0 deletions go/common/privacy/whitelist.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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

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
}
Loading

0 comments on commit c7517c1

Please sign in to comment.