Skip to content

Commit

Permalink
explicit event and improved comment
Browse files Browse the repository at this point in the history
  • Loading branch information
RensR committed Sep 27, 2024
1 parent a1e7cbe commit 5cf7ccb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions contracts/src/v0.8/ccip/rmn/RMNHome.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import {OwnerIsCreator} from "../../shared/access/OwnerIsCreator.sol";
/// config as candidate and promote that, but fully clearing it is cleaner.
contract RMNHome is OwnerIsCreator, ITypeAndVersion {
event ConfigSet(bytes32 indexed configDigest, uint32 version, StaticConfig staticConfig, DynamicConfig dynamicConfig);
event ConfigRevoked(bytes32 indexed configDigest);
event ActiveConfigRevoked(bytes32 indexed configDigest);
event CandidateConfigRevoked(bytes32 indexed configDigest);
event DynamicConfigSet(bytes32 indexed configDigest, DynamicConfig dynamicConfig);
event ConfigPromoted(bytes32 indexed configDigest);

Expand All @@ -63,7 +64,8 @@ contract RMNHome is OwnerIsCreator, ITypeAndVersion {
struct SourceChain {
uint64 chainSelector; // ─────╮ The Source chain selector.
uint64 minObservers; // ──────╯ Required number of observers to agree on an observation for this source chain.
uint256 observerNodesBitmap; // ObserverNodesBitmap & (1<<i) == (1<<i) iff nodes[i] is an observer for this source chain.
// ObserverNodesBitmap & (1<<i) == (1<<i) iff StaticConfig.nodes[i] is an observer for this source chain.
uint256 observerNodesBitmap;
}

struct StaticConfig {
Expand Down Expand Up @@ -195,7 +197,7 @@ contract RMNHome is OwnerIsCreator, ITypeAndVersion {

// are we going to overwrite a config? If so, emit an event.
if (existingDigest != ZERO_DIGEST) {
emit ConfigRevoked(digestToOverwrite);
emit CandidateConfigRevoked(digestToOverwrite);
}

uint32 newVersion = ++s_currentVersion;
Expand Down Expand Up @@ -226,7 +228,7 @@ contract RMNHome is OwnerIsCreator, ITypeAndVersion {
revert ConfigDigestMismatch(s_configs[candidateConfigIndex].configDigest, configDigest);
}

emit ConfigRevoked(configDigest);
emit CandidateConfigRevoked(configDigest);
// Delete only the digest, as that's what's used to determine if a config is active. This means the actual
// config stays in storage which should significantly reduce the gas cost of overwriting that storage space in
// the future.
Expand Down Expand Up @@ -258,7 +260,7 @@ contract RMNHome is OwnerIsCreator, ITypeAndVersion {

s_activeConfigIndex ^= 1;
if (digestToRevoke != ZERO_DIGEST) {
emit ConfigRevoked(digestToRevoke);
emit ActiveConfigRevoked(digestToRevoke);
}
emit ConfigPromoted(digestToPromote);
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/ccip/test/rmn/RMNHome.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ contract RMNHome_setCandidate is RMNHomeTest {
s_rmnHome.setCandidate(config.staticConfig, config.dynamicConfig, ZERO_DIGEST);

vm.expectEmit();
emit RMNHome.ConfigRevoked(digest);
emit RMNHome.CandidateConfigRevoked(digest);

s_rmnHome.setCandidate(config.staticConfig, config.dynamicConfig, digest);
}
Expand Down Expand Up @@ -160,7 +160,7 @@ contract RMNHome_revokeCandidate is RMNHomeTest {
(bytes32 priorActiveDigest, bytes32 priorCandidateDigest) = s_rmnHome.getConfigDigests();

vm.expectEmit();
emit RMNHome.ConfigRevoked(priorCandidateDigest);
emit RMNHome.CandidateConfigRevoked(priorCandidateDigest);

s_rmnHome.revokeCandidate(priorCandidateDigest);

Expand Down Expand Up @@ -220,7 +220,7 @@ contract RMNHome_promoteCandidateAndRevokeActive is RMNHomeTest {
bytes32 secondConfigToPromote = s_rmnHome.setCandidate(config.staticConfig, config.dynamicConfig, ZERO_DIGEST);

vm.expectEmit();
emit RMNHome.ConfigRevoked(firstConfigToPromote);
emit RMNHome.ActiveConfigRevoked(firstConfigToPromote);

vm.expectEmit();
emit RMNHome.ConfigPromoted(secondConfigToPromote);
Expand Down

0 comments on commit 5cf7ccb

Please sign in to comment.