From dbea2493e5891d1c2be1dee9d043c8e9a6ea5c0c Mon Sep 17 00:00:00 2001 From: David Date: Wed, 8 Nov 2023 12:34:48 +0800 Subject: [PATCH] Remove Get from method name --- fhevm/evm.go | 6 +++--- fhevm/instructions.go | 12 ++++++------ fhevm/interface.go | 2 +- fhevm/precompiles.go | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fhevm/evm.go b/fhevm/evm.go index 66e4dfd..12822fd 100644 --- a/fhevm/evm.go +++ b/fhevm/evm.go @@ -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 @@ -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 } } @@ -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) diff --git a/fhevm/instructions.go b/fhevm/instructions.go index 7ccef83..643c104 100644 --- a/fhevm/instructions.go +++ b/fhevm/instructions.go @@ -133,7 +133,7 @@ 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 } @@ -141,7 +141,7 @@ func getVerifiedCiphertextFromEVM(environment EVMEnvironment, ciphertextHash com } 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. // @@ -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", @@ -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", @@ -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(), diff --git a/fhevm/interface.go b/fhevm/interface.go index 92b6633..dd814ac 100644 --- a/fhevm/interface.go +++ b/fhevm/interface.go @@ -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 } diff --git a/fhevm/precompiles.go b/fhevm/precompiles.go index 0963e33..7a9535a 100644 --- a/fhevm/precompiles.go +++ b/fhevm/precompiles.go @@ -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] @@ -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 } @@ -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 {