Skip to content

Commit

Permalink
Remove Get from method name
Browse files Browse the repository at this point in the history
  • Loading branch information
david-zk committed Nov 8, 2023
1 parent e8168df commit dbea249
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions fhevm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func getScalarOperands(environment EVMEnvironment, input []byte) (lhs *verifiedC
}

func importCiphertextToEVMAtDepth(environment EVMEnvironment, ct *tfheCiphertext, depth int) *verifiedCiphertext {
existing, ok := environment.GetFhevmData().verifiedCiphertexts[ct.getHash()]
existing, ok := environment.FhevmData().verifiedCiphertexts[ct.getHash()]
if ok {
existing.verifiedDepths.add(depth)
return existing
Expand All @@ -98,7 +98,7 @@ func importCiphertextToEVMAtDepth(environment EVMEnvironment, ct *tfheCiphertext
verifiedDepths,
ct,
}
environment.GetFhevmData().verifiedCiphertexts[ct.getHash()] = new
environment.FhevmData().verifiedCiphertexts[ct.getHash()] = new
return new
}
}
Expand All @@ -112,7 +112,7 @@ func importCiphertext(environment EVMEnvironment, ct *tfheCiphertext) *verifiedC
}

func importRandomCiphertext(environment EVMEnvironment, t FheUintType) []byte {
nextCtHash := &environment.GetFhevmData().nextCiphertextHashOnGasEst
nextCtHash := &environment.FhevmData().nextCiphertextHashOnGasEst
ctHashBytes := crypto.Keccak256(nextCtHash.Bytes())
handle := common.BytesToHash(ctHashBytes)
ct := new(tfheCiphertext)
Expand Down
12 changes: 6 additions & 6 deletions fhevm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ func isVerifiedAtCurrentDepth(environment EVMEnvironment, ct *verifiedCiphertext
// Returns a pointer to the ciphertext if the given hash points to a verified ciphertext.
// Else, it returns nil.
func getVerifiedCiphertextFromEVM(environment EVMEnvironment, ciphertextHash common.Hash) *verifiedCiphertext {
ct, ok := environment.GetFhevmData().verifiedCiphertexts[ciphertextHash]
ct, ok := environment.FhevmData().verifiedCiphertexts[ciphertextHash]
if ok && isVerifiedAtCurrentDepth(environment, ct) {
return ct
}
return nil
}

func verifyIfCiphertextHandle(handle common.Hash, env EVMEnvironment, contractAddress common.Address) error {
ct, ok := env.GetFhevmData().verifiedCiphertexts[handle]
ct, ok := env.FhevmData().verifiedCiphertexts[handle]
if ok {
// If already existing in memory, skip storage and import the same ciphertext at the current depth.
//
Expand Down Expand Up @@ -299,7 +299,7 @@ func OpSstore(pc *uint64, env EVMEnvironment, scope ScopeContext) ([]byte, error
// Return a map from ciphertext hash -> depthSet before delegation.
func DelegateCiphertextHandlesInArgs(env EVMEnvironment, args []byte) (verified map[common.Hash]*depthSet) {
verified = make(map[common.Hash]*depthSet)
for key, verifiedCiphertext := range env.GetFhevmData().verifiedCiphertexts {
for key, verifiedCiphertext := range env.FhevmData().verifiedCiphertexts {
if contains(args, key.Bytes()) && isVerifiedAtCurrentDepth(env, verifiedCiphertext) {
if env.IsCommitting() {
env.GetLogger().Info("delegateCiphertextHandlesInArgs",
Expand All @@ -316,12 +316,12 @@ func DelegateCiphertextHandlesInArgs(env EVMEnvironment, args []byte) (verified

func RestoreVerifiedDepths(env EVMEnvironment, verified map[common.Hash]*depthSet) {
for k, v := range verified {
env.GetFhevmData().verifiedCiphertexts[k].verifiedDepths = v
env.FhevmData().verifiedCiphertexts[k].verifiedDepths = v
}
}

func delegateCiphertextHandlesToCaller(env EVMEnvironment, ret []byte) {
for key, verifiedCiphertext := range env.GetFhevmData().verifiedCiphertexts {
for key, verifiedCiphertext := range env.FhevmData().verifiedCiphertexts {
if contains(ret, key.Bytes()) && isVerifiedAtCurrentDepth(env, verifiedCiphertext) {
if env.IsCommitting() {
env.GetLogger().Info("opReturn making ciphertext available to caller",
Expand All @@ -336,7 +336,7 @@ func delegateCiphertextHandlesToCaller(env EVMEnvironment, ret []byte) {
}

func RemoveVerifiedCipherextsAtCurrentDepth(env EVMEnvironment) {
for _, verifiedCiphertext := range env.GetFhevmData().verifiedCiphertexts {
for _, verifiedCiphertext := range env.FhevmData().verifiedCiphertexts {
if env.IsCommitting() {
env.GetLogger().Info("Run removing ciphertext from depth",
"handle", verifiedCiphertext.ciphertext.getHash().Hex(),
Expand Down
2 changes: 1 addition & 1 deletion fhevm/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type EVMEnvironment interface {
CreateContract(caller common.Address, code []byte, gas uint64, value *big.Int, address common.Address) ([]byte, common.Address, uint64, error)
CreateContract2(caller common.Address, code []byte, codeHash common.Hash, gas uint64, value *big.Int, address common.Address) ([]byte, common.Address, uint64, error)

GetFhevmData() *FhevmData
FhevmData() *FhevmData
FhevmParams() *FhevmParams
}

Expand Down
6 changes: 3 additions & 3 deletions fhevm/precompiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ func optimisticRequireRequiredGas(environment EVMEnvironment, input []byte) uint
"type", ct.ciphertext.fheUintType)
return 0
}
if len(environment.GetFhevmData().optimisticRequires) == 0 {
if len(environment.FhevmData().optimisticRequires) == 0 {
return environment.FhevmParams().GasCosts.FheOptRequire[FheUint8]
}
return environment.FhevmParams().GasCosts.FheOptRequireBitAnd[FheUint8]
Expand Down Expand Up @@ -1950,7 +1950,7 @@ func optimisticRequireRun(environment EVMEnvironment, caller common.Address, add
logger.Error(msg, "type", ct.ciphertext.fheUintType)
return nil, errors.New(msg)
}
environment.GetFhevmData().optimisticRequires = append(environment.GetFhevmData().optimisticRequires, ct.ciphertext)
environment.FhevmData().optimisticRequires = append(environment.FhevmData().optimisticRequires, ct.ciphertext)
return nil, nil
}

Expand Down Expand Up @@ -2001,7 +2001,7 @@ func decryptValue(ct *tfheCiphertext) (uint64, error) {
// That works, because we assume their values are either 0 or 1. If there is at least
// one 0, the result will be 0 (false).
func evaluateRemainingOptimisticRequires(environment EVMEnvironment) (bool, error) {
requires := environment.GetFhevmData().optimisticRequires
requires := environment.FhevmData().optimisticRequires
len := len(requires)
defer func() { requires = make([]*tfheCiphertext, 0) }()
if len != 0 {
Expand Down

0 comments on commit dbea249

Please sign in to comment.