Skip to content

Commit

Permalink
Merge pull request #183 from VenusProtocol/record-bad-trusted-remote
Browse files Browse the repository at this point in the history
feat: save untrusted remote for completion and transparency
  • Loading branch information
coreyar authored Oct 2, 2024
2 parents 7673687 + f0da525 commit 445169d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion subgraphs/venus-governance/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ type RemoteProposal @entity {
proposalId: BigInt

"Remote ChainId where the proposal was sent"
trustedRemote: TrustedRemote
trustedRemote: TrustedRemote!

"Targets data for the change"
targets: [Bytes!]
Expand Down
15 changes: 12 additions & 3 deletions subgraphs/venus-governance/src/operations/createRemoteProposals.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Address, BigInt, Bytes, ethereum } from '@graphprotocol/graph-ts';

import { ProposalCreated as ProposalCreatedV2 } from '../../generated/GovernorBravoDelegate2/GovernorBravoDelegate2';
import { RemoteProposal } from '../../generated/schema';
import { RemoteProposal, TrustedRemote } from '../../generated/schema';
import { DYNAMIC_TUPLE_BYTES_PREFIX } from '../constants';
import { nullAddress } from '../constants/addresses';

class RemoteCommandMap {
sourceProposalId: BigInt;
Expand Down Expand Up @@ -40,8 +41,16 @@ const createRemoteProposals = (event: ProposalCreatedV2): void => {
Bytes.fromByteArray(Bytes.fromBigInt(acc.sourceProposalId)),
);
const remoteProposal = new RemoteProposal(remoteProposalId);

remoteProposal.trustedRemote = Bytes.fromI32(layerZeroChainId); // default value replaced in event handler
const trustRemoteId = Bytes.fromI32(layerZeroChainId);
let trustedRemote = TrustedRemote.load(trustRemoteId);
if (!trustedRemote) {
trustedRemote = new TrustedRemote(trustRemoteId);
trustedRemote.layerZeroChainId = layerZeroChainId;
trustedRemote.address = nullAddress;
trustedRemote.active = false;
trustedRemote.save();
}
remoteProposal.trustedRemote = trustRemoteId;
remoteProposal.sourceProposal = acc.sourceProposalId.toString();
const targets = payloadDecoded[0]
.toAddressArray()
Expand Down

0 comments on commit 445169d

Please sign in to comment.