From 824d6ea1290588e8259c66a88574218c051a2498 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Tue, 1 Oct 2024 11:04:40 +0300 Subject: [PATCH] clarifications --- go/enclave/evm/evm_facade.go | 47 ++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/go/enclave/evm/evm_facade.go b/go/enclave/evm/evm_facade.go index cfead8eed9..90c49cd152 100644 --- a/go/enclave/evm/evm_facade.go +++ b/go/enclave/evm/evm_facade.go @@ -279,29 +279,44 @@ func readVisibilityConfig(vmenv *vm.EVM, contractAddress *gethcommon.Address) *c EventConfigs: make(map[gethcommon.Hash]*core.EventVisibilityConfig), } + if transp { + return cfg + } + + // only check the config for non-transparent contracts for i := range visibilityRules.EventLogConfigs { logConfig := visibilityRules.EventLogConfigs[i] - relevantToMap := make(map[uint8]bool) - for _, field := range logConfig.VisibleTo { - relevantToMap[field] = true - } - t1 := relevantToMap[topic1] - t2 := relevantToMap[topic2] - t3 := relevantToMap[topic3] - s := relevantToMap[sender] - cfg.EventConfigs[logConfig.EventSignature] = &core.EventVisibilityConfig{ - AutoConfig: false, - Public: relevantToMap[everyone], - Topic1CanView: &t1, - Topic2CanView: &t2, - Topic3CanView: &t3, - SenderCanView: &s, - } + cfg.EventConfigs[logConfig.EventSignature] = eventCfg(logConfig) } return cfg } +func eventCfg(logConfig ContractTransparencyConfigEventLogConfig) *core.EventVisibilityConfig { + relevantToMap := make(map[uint8]bool) + for _, field := range logConfig.VisibleTo { + relevantToMap[field] = true + } + isPublic := relevantToMap[everyone] + + if isPublic { + return &core.EventVisibilityConfig{AutoConfig: false, Public: true} + } + + t1 := relevantToMap[topic1] + t2 := relevantToMap[topic2] + t3 := relevantToMap[topic3] + s := relevantToMap[sender] + return &core.EventVisibilityConfig{ + AutoConfig: false, + Public: false, + Topic1CanView: &t1, + Topic2CanView: &t2, + Topic3CanView: &t3, + SenderCanView: &s, + } +} + func logReceipt(r *types.Receipt, logger gethlog.Logger) { if logger.Enabled(context.Background(), gethlog.LevelTrace) { logger.Trace("Receipt", log.TxKey, r.TxHash, "Result", receiptToString(r))