Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/consensus/source/commit-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class CommitState implements Contracts.Processor.ProcessableUnit {
#processorResult?: Contracts.Processor.BlockProcessorResult;
#validators = new Map<string, Contracts.State.ValidatorWallet>();
#accountUpdates: Array<Contracts.Evm.AccountUpdate> = [];
#contractEvents: Array<Contracts.Evm.ContractEvent> = [];

public get blockNumber(): number {
return this.#commit.block.number;
Expand Down Expand Up @@ -65,6 +66,14 @@ export class CommitState implements Contracts.Processor.ProcessableUnit {
this.#accountUpdates = accounts;
}

public getContractEvents(): Array<Contracts.Evm.ContractEvent> {
return this.#contractEvents;
}

public setContractEvents(events: Array<Contracts.Evm.ContractEvent>): void {
this.#contractEvents = events;
}

public async getCommit(): Promise<Contracts.Crypto.Commit> {
return this.#commit;
}
Expand Down
9 changes: 9 additions & 0 deletions packages/consensus/source/round-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class RoundState implements Contracts.Consensus.RoundState {
#proposal?: Contracts.Crypto.Proposal;
#processorResult?: Contracts.Processor.BlockProcessorResult;
#accountUpdates: Array<Contracts.Evm.AccountUpdate> = [];
#contractEvents: Array<Contracts.Evm.ContractEvent> = [];
#prevotes = new Map<number, Contracts.Crypto.Message>();
#prevotesCount = new Map<string | undefined, number>();
#precommits = new Map<number, Contracts.Crypto.Message>();
Expand Down Expand Up @@ -163,6 +164,14 @@ export class RoundState implements Contracts.Consensus.RoundState {
this.#accountUpdates = accounts;
}

public getContractEvents(): Array<Contracts.Evm.ContractEvent> {
return this.#contractEvents;
}

public setContractEvents(events: Array<Contracts.Evm.ContractEvent>): void {
this.#contractEvents = events;
}

public hasPrevote(validatorIndex: number): boolean {
return this.#prevotes.has(validatorIndex);
}
Expand Down
18 changes: 18 additions & 0 deletions packages/contracts/source/contracts/evm/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ export interface AccountUpdate {
readonly legacyMergeInfo?: AccountMergeInfo;
}

export type ContractEvent = {
readonly txHash: string;
readonly txIndex: number;
} & (
| { readonly event: "Voted"; readonly voter: string; readonly validator: string }
| { readonly event: "Unvoted"; readonly voter: string; readonly validator: string }
| { readonly event: "ValidatorRegistered"; readonly addr: string; readonly blsPublicKey: string }
| { readonly event: "ValidatorResigned"; readonly addr: string }
| { readonly event: "ValidatorUpdated"; readonly addr: string; readonly blsPublicKey: string }
| {
readonly event: "UsernameRegistered";
readonly addr: string;
readonly username: string;
readonly previousUsername?: string;
}
| { readonly event: "UsernameResigned"; readonly addr: string; readonly username: string }
);

export interface AccountUpdateContext {
readonly account: string;
readonly commitKey: CommitKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Block } from "../crypto/block.js";
import type { Commit } from "../crypto/commit.js";
import type { AccountUpdate } from "../evm/evm.js";
import type { AccountUpdate, ContractEvent } from "../evm/evm.js";
import type { BlockProcessorResult } from "./block-processor-result.js";

export interface ProcessableUnit {
Expand All @@ -11,6 +11,8 @@ export interface ProcessableUnit {
setProcessorResult(processorResult: BlockProcessorResult): void;
setAccountUpdates(accounts: Array<AccountUpdate>): void;
getAccountUpdates(): Array<AccountUpdate>;
setContractEvents(events: Array<ContractEvent>): void;
getContractEvents(): Array<ContractEvent>;
getBlock(): Block;
getCommit(): Promise<Commit>;
}
1 change: 1 addition & 0 deletions packages/evm-consensus/source/deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class Deployer implements Contracts.EvmConsensus.Deployer {
commitKey,
getBlock: () => ({ ...commitKey, number: commitKey.blockNumber }),
setAccountUpdates: () => ({}),
setContractEvents: () => ({}),
} as unknown as Contracts.Processor.ProcessableUnit);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/evm-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@mainsail/crypto-transaction": "workspace:*",
"@mainsail/crypto-validation": "workspace:*",
"@mainsail/crypto-wif": "workspace:*",
"@mainsail/evm-contracts": "workspace:*",
"@mainsail/serializer": "workspace:*",
"@mainsail/test-runner": "workspace:*",
"@mainsail/validation": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions packages/evm-service/source/instances/evm-boundary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ describe<{
({
blockNumber: genesisCommit.block.number,
getAccountUpdates: () => [],
getContractEvents: () => [],
getBlock: () => genesisCommit.block,
getCommit: async () => genesisCommit,
round: genesisCommit.block.round,
setAccountUpdates: () => {},
setContractEvents: () => {},
}) as unknown as Contracts.Processor.ProcessableUnit;

// Valid legacy (base58check) addresses: one imported as a cold wallet by the tests
Expand Down
Loading
Loading