diff --git a/scripts/check-chains-drift.mjs b/scripts/check-chains-drift.mjs index 37a975e..3b3d52e 100644 --- a/scripts/check-chains-drift.mjs +++ b/scripts/check-chains-drift.mjs @@ -23,7 +23,18 @@ const NETWORKS_BASE = `https://raw.githubusercontent.com/genlayerlabs/genlayer-n const CHAINS = [ { name: "asimov", deploymentKey: "deployment_asimov_phase5" }, - { name: "bradbury", deploymentKey: "deployment_bradbury" }, + // Bradbury Phase 2 is not in genlayer-networks yet. Its deployment file is a + // copy of genlayer-consensus deployments/bradbury-phase-2.json @ 7a46314 (a private + // repo), and its ABIs come from the explorer-verified implementations. + // Point this entry back at genlayer-networks once Phase 2 is published there. + { + name: "bradbury", + deploymentKey: "deployment_bradbury_phase_2", + networkKey: "genlayerOrbitTestnet", + deploymentsFile: "scripts/deployments/bradbury-phase-2.json", + abiUrl: (group, networksKey) => + `https://contracts.conduit.xyz/v2/contract/4221/${group[`${networksKey}Implementation`]}?fields=abi`, + }, ]; // For each contract: where to find the ABI in genlayer-networks and whether @@ -134,19 +145,19 @@ async function main() { const chains = await loadChains(); const failures = []; - for (const { name, deploymentKey } of CHAINS) { + for (const { name, deploymentKey, networkKey = "genlayerTestnet", deploymentsFile, abiUrl } of CHAINS) { const chain = chains[name]; if (!chain) { failures.push(`[${name}] chain export missing from dist/chains`); continue; } - const deployments = await fetchJson( - `${NETWORKS_BASE}/${name}/testnet_deployments.json`, - ); - const group = deployments.genlayerTestnet?.[deploymentKey]; + const deployments = deploymentsFile + ? JSON.parse(readFileSync(join(REPO_ROOT, deploymentsFile), "utf8")) + : await fetchJson(`${NETWORKS_BASE}/${name}/testnet_deployments.json`); + const group = deployments[networkKey]?.[deploymentKey]; if (!group) { failures.push( - `[${name}] testnet_deployments.json has no .genlayerTestnet.${deploymentKey}`, + `[${name}] deployments JSON has no .${networkKey}.${deploymentKey}`, ); continue; } @@ -172,7 +183,9 @@ async function main() { } const nwAbi = ( - await fetchJson(`${NETWORKS_BASE}/${name}/${abiPath}`) + await fetchJson( + abiUrl ? abiUrl(group, networksKey) : `${NETWORKS_BASE}/${name}/${abiPath}`, + ) ).abi; const jsSet = canonicalSet(jsContract.abi); const nwSet = canonicalSet(nwAbi); diff --git a/scripts/deployments/bradbury-phase-2.json b/scripts/deployments/bradbury-phase-2.json new file mode 100644 index 0000000..536062e --- /dev/null +++ b/scripts/deployments/bradbury-phase-2.json @@ -0,0 +1,224 @@ +{ + "genlayerOrbitTestnet": { + "deployment_bradbury_phase_2": { + "AddressManager": "0x3F71AE080BD6270A91dBcc7960d88797828538E0", + "AddressManagerImplementation": "0xDeb0D115881505393cabb6FC764eEe6Bb51ad944", + "VestingFactory": "0x82cA5e0e7A9345CF3ED5ee68A7fba41EF2202316", + "VestingFactoryImplementation": "0x1C7D938E3aEdB2E683E3F8cCAE9459ADd0eC3cD5", + "VestingBlueprint": "0xd52998F07eF136d44B41Dc73c131492c8985e204", + "VestingBeacon": "0x6A5f7bb80b8760B8978e3E2D57a4639111ebba05", + "ArrayUtils": "0x87B8BC807392DeD881b49d544032a3A8ac411613", + "RandomnessUtils": "0xd7DE7Feeed4B6f51D851AAf347CB0895D1275342", + "FeeProfileHelpers": "0x7EBa83806Cd72ba96A10995840B4Aefc2802F8EF", + "ConsensusHelpers": "0x9F757AeC38Bd4d217A3F05fC9c715112ca5279f6", + "AppealFundingHelpers": "0x6ea7466625A45272AC786bdCbED179C6fBcEc376", + "FeeAppealHelpers": "0x76F6ECdFb9256BD96bf7Da9Dc724873D8F78429f", + "MessagesPolicyHelpers": "0x6b8EEaF7258e3ef5476E0B835e1c832228bc1b7d", + "MessagePaymentsHelpers": "0x8101882d8a2Fea752Bf041Aaeb068C3B4FD62B97", + "FeeSplitUtils": "0x868D93f0f6ee923DD609788842e635ae27A16A0D", + "MessagePaymentsTerminalHelpers": "0x7534f102EF52EdC0FCb835eE58e8b15Df757092c", + "IdlenessHelpers": "0x894B9b1Fbc238318f10200cbE03eBf6e2ccCa637", + "IdlenessPolicyHelpers": "0xC15E310c030a33a070aF0A1B05651DA8d640a858", + "ResolutionKernel": "0x274663eB1F7E1c23E7192Fd102212F05dbb02e85", + "TerminalRoundKernel": "0x62d3aaBF65d58D51D32B8781C32ca40174a39a5F", + "ValidatorSelectionUtils": "0x549dC20c5F22D59b0F662Bb5bC800daE0a7b7a2F", + "ValidatorUtils": "0xe13742A806c532972964A25d5A3795FB1702eBc2", + "SnapshotSelectionKernel": "0x84c06bc3d53c5859334BA32d707604750D761196", + "DelegatorUtils": "0xddF2a0491745B238818bcc02CE71aD5145bfd93A", + "ValidatorPrimeUtils": "0x1CDE9c9f3a17cBeB6bCFBE1fd732745309f81576", + "ValidatorSlashProgress": "0x71fD566E1143cf97d3448e641D7A04f1e2C6dE41", + "RecoveryHelpers": "0x2dAE85871C61b8896Ec0485050E66F2Cba4925fB", + "QueueStepUtils": "0xb4d264c5f8D51FDfE48fd3b7dbd2F3943eC8c073", + "TribunalInitializationManager": "0xb80D257061358fF158B6F3e68CE659a3b74443Ff", + "TransitionEnforcer": "0xA30098a857e9246268cf9c8E7F126bDa882289aC", + "GovernanceVotingPowerLib": "0x9fae49037cB7E936749123509ca80415F74B9B53", + "GovernanceVotingLib": "0x01d2af0B247Db3914BD2A9fcc778ab132b4A5393", + "GovernanceElectionsLib": "0x430F5D133aF0b930b556E4D54132b69aeE73388A", + "ConsensusProposalHelpers": "0x06871c41b23D42E940dFD09CA84117d21dC88C8B", + "FeeManagerHelpers": "0x4b21cF7CDe9F4a72C618204aAA2509A1c37De2C6", + "ConsensusFinalizationHelpers": "0xa2F211EE0D1CcC372695766a47c18af3C4FE46fC", + "MinimumStakeTransitionManager": "0x37f083c99A72e71B9f564B85cAE9eFa26ebA59F8", + "RemedySelectionKernel": "0x0CB262aD8b7964CC88Ec3C96eb6E1474f16D5bf6", + "ValidatorSlashSettlement": "0x217530Bf7227CF6BC290Bab5ece5e9375E4fa3Cf", + "GovernancePostVoteLib": "0xC806625eC0a470FFBAA50342Ed723599513Bd4a7", + "GovernanceSettlementLib": "0xC35FAcFba561137FC302887a0F29fEF5BB1Aa65a", + "ConsensusManager": "0x3F748d4CbDA4FDfe8356690aFD73ac4cFc4eE56B", + "ConsensusManagerImplementation": "0x7927C4A3DF163c7772BB8d3019Fa16e6398Ec833", + "GhostFactory": "0x901ECAeFc35aed5Dd9967feF4E161d42199aAd9d", + "GhostFactoryImplementation": "0x9d297C8E1AD2A811b12ACD0AD6ea87190f55bA7a", + "GhostManager": "0x2E2766cbc3E5e61Ce93bBcdCBb3eAcB82082A019", + "GhostManagerImplementation": "0x7EfCEaE0cB2bEd3B2dA9209bd096d2F88E07343b", + "GhostBlueprint": "0x450d2B06aB240773d1E23e69d0c5d616bEF4Ba2d", + "GhostBlueprintImplementation": "0xdcF2Cfc7c6B848D6a9B5BCe9EBc10a50c911F55D", + "Messages": "0xD14B0489157FE420555F1e5A6AFBA031E978aCE5", + "MessagesImplementation": "0xC99Bc447AA1436D51F4eEc13992Fe0393Cc01464", + "Appeals": "0xdc953c3bCf8837987853ca05a78D52fFC3E18651", + "AppealsImplementation": "0xfA88c97083f51CCB498248a43f8E5e573CA5475f", + "Queues": "0xBfE2ece1f2c62Ab3700C94Ed6bB76286bccC8CB3", + "QueuesImplementation": "0x8a40F27F3706CEF9598E484cb98B278504ef904f", + "NFTMinter": "0xEe307BCE38733cD16c15A13FE7e928BBE40e96E1", + "NFTMinterImplementation": "0xf2872aB79F98177E19710d80567D3658C95d8971", + "DeepthoughtReserve": "0x9d8c991Fe71d27589f004c24505f4ce4C6fD3F78", + "DeepthoughtReserveImplementation": "0x978607b4d5bf19C5dB8FACe35c43EC8bCF01f64D", + "DeepthoughtFoundation": "0x9E02cE50C79A19D9c1A194B0daEE481394661D6A", + "Staking": "0xD8fBa96C0dBB0257028dBc0107060b958e5c7113", + "StakingImplementation": "0x5ed40150710C64318607CC684211ff6c7b3592Fa", + "TransactionManager": "0xaCe5e4191Bf408957538Caa9493aBB64F63D92c4", + "TransactionManagerImplementation": "0xBFD56eC25881170096470716Aa76dD0387D50090", + "RoundsStorage": "0x4038d4F72C7aAbA5a442cC0dA946012B9E3f4B8a", + "RoundsStorageImplementation": "0x9d1516378757dabd8E3DFd41894e1BCB2Df8b9D1", + "RoundsCreation": "0x35A36496861b11199486121621EEb86E0528630C", + "RoundsCreationImplementation": "0x2311F4EB06D4943b541925115C9Ae2110d02AFCA", + "RoundsVoting": "0xFBA6A1F9a1FB76Cdb1559241A7e0Ddeb4C1DF5a1", + "RoundsVotingImplementation": "0xe0c3bD4De52D2D492A29b619A0eB21507E5dA74C", + "RoundsLight": "0xe1B234B6959deA2AD0873fc7248a91a53a6185f9", + "RoundsLightImplementation": "0x6602415B303a238d62A23588326168BBFA150f2B", + "CreationPhase": "0x56a1517B263c849Be4a0c861540C14e1d51E6273", + "CreationPhaseImplementation": "0xD1F278b3a8156aa20A912a96bc0D06aaC9ff3654", + "ActivationPhase": "0x62541A8314b9112407E53B3bc5cf8970906E845c", + "ActivationPhaseImplementation": "0xb1A40372b630988738a27dD36cd5e3dA947625D9", + "ProposalPhase": "0x44aFCc45720c6ab951BabB726C07A651De9aA4b3", + "ProposalPhaseImplementation": "0x99591508acE2dddC93eC4d513719Ff93f237C557", + "CommittingPhase": "0xC08fDE7309d590e01FB93E37a808DEf2a8aB6bc2", + "CommittingPhaseImplementation": "0x27A1667Ad66787382207bF3d46e3B4367f7FBa05", + "RevealingPhase": "0x88c6D8Ff2BC235eEf758014dd92C2E45D1E5C8F7", + "RevealingPhaseImplementation": "0x3EE88E5Fb9fC44D6321D4903719E8114E14f0ee3", + "FinalizationPhase": "0x0c746f9c1b5F4cD135cB152fdb10CFd36d6560B5", + "FinalizationPhaseImplementation": "0x599138DfaB2e0eecA0Cf44d7664124f87edEf333", + "IdlenessPhase": "0xa2f3360c3359e45AD07E889018567BaBB914d3eB", + "IdlenessPhaseImplementation": "0x922afF75e65a5E4EA489923337F2bf8bBe655FF2", + "IdlenessCrank": "0xea447c0a9656cf5C6983578Da910bb88eF8e0e30", + "IdlenessCrankImplementation": "0xfb55C8a85F4a3e0DE7306E69dCeCE575B64824AD", + "IdlenessViews": "0x0861c1c7ACAAA2a56c6c49FB13261171DcB10855", + "ConsensusMain": "0x2E2766cbc3E5e61Ce93bBcdCBb3eAcB82082A019", + "ConsensusMainWithFees": "0x2E2766cbc3E5e61Ce93bBcdCBb3eAcB82082A019", + "ConsensusMainImplementation": "0xe9F572e836ea3640c022D09Aa41108fba3574731", + "ConsensusMainWithFeesImplementation": "0xe9F572e836ea3640c022D09Aa41108fba3574731", + "ConsensusData": "0xc5FA6f82BEe53598825d6edf7E3e24613082c75B", + "ConsensusDataImplementation": "0x7A92A2036102c27eE9989f1D2f2E16152338c4b0", + "ConsensusDataBigRounds": "0xc0aB228Ba46b4825fcd6461ea56d5B732AcA0E3B", + "ConsensusDataBigRoundsImplementation": "0x4e909C7A4fc1d7A68BB3C6B9f3948AD3438df434", + "Utils": "0x215952B66D801c805e68E2503AfC751cAA84Af7c", + "FeesVerifier": "0xE5DaA0860E1a1dc08a219762f96Fe2e5006504b3", + "MessageFeeAllocations": "0x1B1eA007C42C1087d889233Ff7157237e7DAe3A9", + "MessageFeeAllocationsImplementation": "0xD8f349b319eBe6f0D92ECD58c650219Db2155e9C", + "FeesRecorder": "0x8beE3d0b24e07183A840bd0B51041C1f71914797", + "FeesRecorderImplementation": "0x3A375E2bf2bA197CE5d51365b8226FA710c5e812", + "Idleness": "0x8f4167edC14Ce4E0640de65cF70DcdE3dfba9FF1", + "IdlenessImplementation": "0xBecCf4f68360FAb9ABbeb0bf177ed7c420270cfa", + "Voting": "0xB8E01fA102f91ec2E402CfBD23f162e088C2CD3A", + "TribunalAppeal": "0x7cf2D3Fa7f63F3547C5036dC955ba1a70235682a", + "TribunalAppealImplementation": "0xD713AcD6aAB0dEA91A79aDeEb3BAB679287bA1fB", + "Slash": "0x9C30189686B7d6ec5e525eA6f155B57987d2086f", + "SlashImplementation": "0x5cd0C14c7a8C0f326D8333fA36437A4fEB7B7002", + "StakingInflation": "0xF6e020677d4799281942BA868B04f824D9B194C1", + "StakingConfig": "0xe56D9dEdD88b600D36663c3E3a57099616Da1494", + "StakingDelegators": "0x05F3157E873dD68De43ED82920D6a799873Cf7F5", + "StakingBan": "0x9c251FB71832C470D7a30B08107fF8ad85825CFB", + "StakingValidators": "0x6750F65b74B73FA529a7A4fe283b705d509B3306", + "StakingEpoch": "0xdeF1262F9A0CFFD7Fc26F0C8F7Ef1af724136E19", + "StakingReadFacet": "0x47a404edE8F68F0b9253aB009e5Aa0362517B1e1", + "StakingReadModel": "0xf1fBdE733A9ceE2C0A44b8f724d944F89aE6D8A4", + "StakingData": "0x8951E93ae3E95F44Bc700fd8D145d30f5eeD408E", + "StakingDataImplementation": "0xb17160b160885616cac24CA46cDE0FCBf66DE2e8", + "ValidatorWalletFactory": "0x399FCBe6b442903cbA4d3B647B4b30EddF729314", + "ValidatorWalletFactoryImplementation": "0xf9451abD90122A7f0DE1fF35F337Ff31344cdd50", + "ValidatorWalletBlueprint": "0xAE308333af9e4aB7418E0CA6f1Fd5fAb8915BAf2", + "ValidatorWalletBeacon": "0xb9F17C1799DdCd26C0e621d65D8Ce0A3191B0495", + "MessagePayments": "0x5Ac4717C772107c335f2db699e2cDA4ebC192faE", + "MessagePaymentsImplementation": "0xc2Fc56fC211eCE37Eb97402184498Cdb086c63DF", + "FeeManager": "0x7678587A847712f2A96082AC07883A88D0fc7245", + "FeeManagerImplementation": "0x8797Ef886ebBd2492A137f5279E537ba29B1E542", + "FeesProcessor": "0x040a455CA9c6A8Cdc696F6fE603152692D4CA775", + "FeesProcessorImplementation": "0x085565c4ae049D47E2485D5Db0c82fC443Ec6De4", + "TransactionFeesManager": "0xd122de4CB6704C0FDdbb061275F0171e1119A429", + "TransactionFeesManagerImplementation": "0x462ff7E2Ea6323Ee7C1DA466f5c1fdb13B2a5747", + "ContributionLedger": "0x9dC6642157b88da4E05ec2F57a186d5F2C03c106", + "ContributionLedgerImplementation": "0x9e778cc1B60Cf173f151Fa8FF6F4d98fA2A04cDD", + "BatchTransactionHandler": "0x318d04EbeB53d121e0a8566a9448ffE84af0D1C4", + "BatchTransactionHandlerImplementation": "0x09A2aa555C15018e521E538Bc3E7f330E93B2955", + "StakingInvariant": "0xf9F9bed2008EcD50AdbB101eA455CBe42F1b6Be4", + "GovernanceClock": "0xBDb6b4cAEdF3Bfca166745c2a4C16053351A57a6", + "GovernanceClockImplementation": "0xcf53D59DcdC59D54D00941cB7B0B8E2425Eb49E0", + "GovernanceClockProxyAdmin": "0x472C1929AB55eEf95C50560Ef849799Da7450D40", + "GovernanceGESRegistry": "0x9a59348e756f9dD54C58B31ac764fB0130B51e06", + "GovernanceGESRegistryImplementation": "0x735702b10ccAC8279a37e9394a5d3B484C1F239b", + "GovernanceGESRegistryProxyAdmin": "0xD5B5767cF38B61DD5CA6Bf708E10C74e5E52AFcc", + "GovernanceVotingPower": "0xc42590416fF93dD12a038b601088Ff2629559aBf", + "GovernanceVotingPowerImplementation": "0x7360e90Fa3E29eAAF223912E186A99726de9102B", + "GovernanceVotingPowerProxyAdmin": "0xF8da3FD735023416ABba6Eb45B5C33bE640Ba65d", + "Governance": "0x14b647BE7358aE0678DB5B60eC8B8fd90e895917", + "GovernanceImplementation": "0xB6321e2b3AaE08Af76e3f7F13863625645bd5055", + "GovernanceProxyAdmin": "0xF6ad1F88B554758c251D357B586c293A708Ce0F2", + "GovernanceL1Bridge": "0x94b1907087590241e3B55e6655A7EdaFfEC10300", + "GovernanceL1BridgeImplementation": "0x83F71F679195fEDb7f191FF05489f78212eAD9f3", + "GovernanceL1BridgeProxyAdmin": "0x8da7c4C83f9A43277C529185f58D45A746aBA3a7", + "GovernancePause": "0x57b84903112c958b5561d56393e76BD227ba97cF", + "GovernanceVoting": "0xF4Fbb5C9FEe31cF45ECb37a3578699F8E88A52C3", + "GovernanceVotingImplementation": "0xBfDe0360107644d95cb7c27FB7750829A76f3e6A", + "GovernanceVotingProxyAdmin": "0x1C9EDA1A813D02FEAc4776edb90462A0A9A15e5f", + "SecurityCouncil": "0x48713683CdB19ece4f6f9601Ffe64c8862827cFC", + "SecurityCouncilImplementation": "0x21062076A29568272C0E404922aa5ba3ceACCD90", + "SecurityCouncilProxyAdmin": "0xDf26e1836FCB9696884f3B1c08C933026E1Cb080", + "GovernanceCouncilElections": "0xFF203aBb22412c81Fa04Dfb1F9620790F7ca581c", + "GovernanceCouncilElectionsImplementation": "0x4fFF3b79b90625c225999Ee6C77E9a4A21Ba33d0", + "GovernanceCouncilElectionsProxyAdmin": "0x079e7d3DE30A0aD906977b89EDFFd227F578f299", + "AddressManagerProxyAdmin": "0x80DC73b233Cc4aBd70F437b93bC1054C8089f8BA", + "VestingFactoryProxyAdmin": "0x12117A1B794F472E4Cc8258a435827dBDF7C1F4A", + "ConsensusManagerProxyAdmin": "0x3a262c10A07cAAF1C26101ce2701190D57963A00", + "GhostFactoryProxyAdmin": "0x8c661D78E43293808115c259d4f82c113d800dC9", + "GhostManagerProxyAdmin": "0xc9AAa53dA179484f163Fae427bf8a26a9Cc676E9", + "GhostBlueprintProxyAdmin": "0x97B5deA1a474d4788eEEeF46acbB77D207ba1722", + "MessagesProxyAdmin": "0x840CBd2572C18293981572AbAa0707adA547d965", + "AppealsProxyAdmin": "0x961E1a426A0BFbA5A0Ba935F5de7f295992aABE5", + "QueuesProxyAdmin": "0xaaF7FB4e70d3f1C15bBc1a6e615bcbba53BBe5B8", + "NFTMinterProxyAdmin": "0x474e4855851b9F29C91331c8dA4f02f8a0857a94", + "StakingProxyAdmin": "0xCEd58676939229fD3d4cD326895CeA0178fd7F8C", + "TransactionManagerProxyAdmin": "0xE8FF47d66816649888421Bab2BeaABC12994C55E", + "RoundsStorageProxyAdmin": "0xd0E773ee7b6c6192C2d70cAAa93C5165B8a22145", + "RoundsCreationProxyAdmin": "0xA39183AE982fE0E877150a1e76D6B8565b82FfCc", + "RoundsVotingProxyAdmin": "0xdBC786CD6E6Cd361679926b37b3614904354Ea24", + "RoundsLightProxyAdmin": "0x12cb7b6292874db45db43E79ca23c26fe698795b", + "CreationPhaseProxyAdmin": "0x0A88507285bD16Ac6CF56876dA3Fa0524026D16C", + "ActivationPhaseProxyAdmin": "0xe64d26507E9e141DdceDA41c9ad976D3857a35Ea", + "ProposalPhaseProxyAdmin": "0xa1ee03197D6fB2420d91FF5bab2e511d4F92C66d", + "CommittingPhaseProxyAdmin": "0x42ceF82065adB99c0dEf2A75Bb2C2f6702f3B439", + "RevealingPhaseProxyAdmin": "0x817FdA6125cB3d1Ed76670619052620b55d6fBE2", + "FinalizationPhaseProxyAdmin": "0xB98dD719f706eDF6F2b04A0d4C42e1C6B1F18cA9", + "IdlenessPhaseProxyAdmin": "0x0E60BABa88fA034dfA4386506fB6B857Fe2a6D6c", + "IdlenessCrankProxyAdmin": "0x2F161945c92119ADA4959DbCCb64d2E1b8DF302c", + "ConsensusMainProxyAdmin": "0x2Eb0145d43dbC3A889c0Fd1076506627e2f3c896", + "ConsensusMainWithFeesProxyAdmin": "0x2Eb0145d43dbC3A889c0Fd1076506627e2f3c896", + "ConsensusDataProxyAdmin": "0xE5B9D629C206097b05d9337c72011615F624D0d8", + "ConsensusDataBigRoundsProxyAdmin": "0x79aCeb3AaEA6B5962BA2B81a56a4A9f918662d11", + "MessageFeeAllocationsProxyAdmin": "0xaFC1Bf1d448E474D5828F64Efda535C220d91BB3", + "FeesRecorderProxyAdmin": "0xBbf1B21097f1D909451c6ea95cC7d1C4Db20C875", + "IdlenessProxyAdmin": "0x944E5534a8CFDE821365e332Ba2Fc166f6380cF9", + "TribunalAppealProxyAdmin": "0xcF9f7C59147dC23f4294d66DA0DC308EB7d72E89", + "SlashProxyAdmin": "0xf9C9B13dA73887733Bbf99988ceb42dc2bf6809D", + "StakingDataProxyAdmin": "0xE8cB25a095699B391ccc6e7F792c8b4cC375f88c", + "ValidatorWalletFactoryProxyAdmin": "0x5E3dC20BfBB5803D73E944F339F7c93e350Df8A3", + "MessagePaymentsProxyAdmin": "0xB6f7a73D0Fd54BB8c667809792b0cc48d2f20684", + "FeeManagerProxyAdmin": "0x7aD053c9A00a835Ae453678AAf107092115BD103", + "FeesProcessorProxyAdmin": "0xfD43C59E56C2d25A13537D85D79b42F03B0d2d71", + "TransactionFeesManagerProxyAdmin": "0xd158244416Ba9aC4804eb6dcB64adB5eB7D56162", + "ContributionLedgerProxyAdmin": "0x458ce937D8c966E43410Ec4894c4a07d319C0dcf", + "BatchTransactionHandlerProxyAdmin": "0x4147652857E738f3Ffe13ABd2546C6F3178A4688", + "GovernanceClassRegistry": "0x172AE46D9eceE2f7c93c2e0226D78266DB77270f", + "GovernanceClassRegistryImplementation": "0x10FC285bcf5d7A5862B0B4bD6fE640B941d649B9", + "GovernanceClassRegistryProxyAdmin": "0x3F8D418E867F714F57220BbFBC0b8ce58d79590b", + "GhostFleetInitialImplementation": "0x74C9617e5Ec6EFAD6c7793064877CFfDb6E736e5", + "Gen": "0x424242424b68330CcFb022881d25a6acC29852ea", + "GhostManagerSupersededRecord": "0x6309BF331Acf5287AaDe8334D29C75EFAa96F863", + "GenManager": "0x3F748d4CbDA4FDfe8356690aFD73ac4cFc4eE56B", + "Rounds": "0xe1B234B6959deA2AD0873fc7248a91a53a6185f9", + "Slashing": "0x9C30189686B7d6ec5e525eA6f155B57987d2086f", + "IGenLayerStaking": "0xD8fBa96C0dBB0257028dBc0107060b958e5c7113", + "StakingViews": "0xf1fBdE733A9ceE2C0A44b8f724d944F89aE6D8A4", + "Transactions": "0xaCe5e4191Bf408957538Caa9493aBB64F63D92c4", + "Vesting": "0xd52998F07eF136d44B41Dc73c131492c8985e204", + "ArbitrumInflationEscrow": "0xe7Dc9f8ed1b21f76215635254F01FC02D740AD13", + "InflationFeeVault": "0x7e47934AAD662Abc8294e1e412440Ac0DA1Fe206" + } + } +} \ No newline at end of file diff --git a/src/chains/testnetBradbury.ts b/src/chains/testnetBradbury.ts index f6b0e00..a4deca3 100644 --- a/src/chains/testnetBradbury.ts +++ b/src/chains/testnetBradbury.ts @@ -2,15 +2,15 @@ import {Address, defineChain} from "viem"; import {GenLayerChain} from "@/types"; import {STAKING_ABI} from "@/abi/staking"; -const TESTNET_JSON_RPC_URL = "https://rpc-bradbury.genlayer.com"; +const TESTNET_JSON_RPC_URL = "https://rpc.testnet-chain.genlayer.com"; // WebSocket not available on testnet GenLayer RPC nodes const STAKING_CONTRACT = { - address: "0x4A4449E617F8D10FDeD0b461CadEf83939E821A5" as Address, + address: "0xD8fBa96C0dBB0257028dBc0107060b958e5c7113" as Address, abi: STAKING_ABI, }; const FEE_MANAGER_CONTRACT = { - address: "0xF205868bf5db79d2162843742D18D0900A9E462a" as Address, + address: "0x7678587A847712f2A96082AC07883A88D0fc7245" as Address, abi: [ { type: "function" as const, @@ -28,7 +28,7 @@ const FEE_MANAGER_CONTRACT = { ], }; const ROUNDS_STORAGE_CONTRACT = { - address: "0x7134D05af13A14c0b66Fe129fb930b1d0C420e33" as Address, + address: "0x4038d4F72C7aAbA5a442cC0dA946012B9E3f4B8a" as Address, abi: [ { type: "function" as const, @@ -100,7 +100,7 @@ const ROUNDS_STORAGE_CONTRACT = { ], }; const APPEALS_CONTRACT = { - address: "0xbb8C35AA878D09b9830aFF9e5aAC6492BFbd5471" as Address, + address: "0xdc953c3bCf8837987853ca05a78D52fFC3E18651" as Address, abi: [ { type: "function" as const, @@ -108,6 +108,7 @@ const APPEALS_CONTRACT = { stateMutability: "view" as const, inputs: [ { name: "_txId", type: "bytes32" }, + { name: "_expectedDecisionId", type: "uint256" }, ], outputs: [ { name: "", type: "bool" }, @@ -115,9 +116,9 @@ const APPEALS_CONTRACT = { }, ], }; -const EXPLORER_URL = "https://explorer-bradbury.genlayer.com/"; +const EXPLORER_URL = "https://scan.testnet-chain.genlayer.com"; const CONSENSUS_MAIN_CONTRACT = { - address: "0x0112Bf6e83497965A5fdD6Dad1E447a6E004271D" as Address, + address: "0x2E2766cbc3E5e61Ce93bBcdCBb3eAcB82082A019" as Address, abi: [ { "inputs": [], @@ -129,6 +130,32 @@ const CONSENSUS_MAIN_CONTRACT = { "name": "CallerNotMessages", "type": "error" }, + { + "inputs": [], + "name": "CanNotAppeal", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "attemptedConsumption", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "budget", + "type": "uint256" + } + ], + "name": "ExecutionBudgetExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientFees", + "type": "error" + }, { "inputs": [], "name": "InvalidDeploymentWithSalt", @@ -139,6 +166,11 @@ const CONSENSUS_MAIN_CONTRACT = { "name": "InvalidInitialization", "type": "error" }, + { + "inputs": [], + "name": "InvalidRegistry", + "type": "error" + }, { "inputs": [], "name": "InvalidRevealLeaderData", @@ -146,7 +178,17 @@ const CONSENSUS_MAIN_CONTRACT = { }, { "inputs": [], - "name": "InvalidVote", + "name": "LegacyProposeReceiptRetired", + "type": "error" + }, + { + "inputs": [], + "name": "MessageEnvelopeRequired", + "type": "error" + }, + { + "inputs": [], + "name": "MessageFeesTotalMustBeNonZero", "type": "error" }, { @@ -176,6 +218,11 @@ const CONSENSUS_MAIN_CONTRACT = { "name": "OwnableUnauthorizedAccount", "type": "error" }, + { + "inputs": [], + "name": "ProtocolNotSealed", + "type": "error" + }, { "inputs": [], "name": "ReentrancyGuardReentrantCall", @@ -183,7 +230,12 @@ const CONSENSUS_MAIN_CONTRACT = { }, { "inputs": [], - "name": "TransactionNotFinalized", + "name": "RegistryBindingLocked", + "type": "error" + }, + { + "inputs": [], + "name": "RollupBudgetBelowFloor", "type": "error" }, { @@ -248,6 +300,31 @@ const CONSENSUS_MAIN_CONTRACT = { "name": "AllVotesCommitted", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "appealer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "AppealBondReturned", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -279,6 +356,68 @@ const CONSENSUS_MAIN_CONTRACT = { "name": "AppealStarted", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "appealer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bondReturned", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "profitUnpaid", + "type": "uint256" + } + ], + "name": "AppealerProfitPayoutFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "uint8", + "name": "commandKind", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes4", + "name": "errorSelector", + "type": "bytes4" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "failureFingerprint", + "type": "bytes32" + } + ], + "name": "BatchCommandFailed", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -291,7 +430,13 @@ const CONSENSUS_MAIN_CONTRACT = { { "indexed": false, "internalType": "uint256", - "name": "succeeded", + "name": "finalized", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "progressed", "type": "uint256" }, { @@ -304,6 +449,31 @@ const CONSENSUS_MAIN_CONTRACT = { "name": "BatchFinalizationCompleted", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "attempted", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "resolved", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "failed", + "type": "uint256" + } + ], + "name": "BatchResolutionCompleted", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -323,6 +493,56 @@ const CONSENSUS_MAIN_CONTRACT = { "name": "CreatedTransaction", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "FeesRefunded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "decisionId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "FinalizationEffectsDeferred", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -495,9 +715,33 @@ const CONSENSUS_MAIN_CONTRACT = { "internalType": "bytes32", "name": "txId", "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "receiptFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "gasPrice", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "estimatedGas", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "receiptBytes", + "type": "uint256" } ], - "name": "TransactionAccepted", + "name": "ReceiptFeeEstimated", "type": "event" }, { @@ -508,15 +752,9 @@ const CONSENSUS_MAIN_CONTRACT = { "internalType": "bytes32", "name": "txId", "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "leader", - "type": "address" } ], - "name": "TransactionActivated", + "name": "TransactionAccepted", "type": "event" }, { @@ -531,11 +769,11 @@ const CONSENSUS_MAIN_CONTRACT = { { "indexed": true, "internalType": "address", - "name": "cancelledBy", + "name": "leader", "type": "address" } ], - "name": "TransactionCancelled", + "name": "TransactionActivated", "type": "event" }, { @@ -546,9 +784,15 @@ const CONSENSUS_MAIN_CONTRACT = { "internalType": "bytes32", "name": "txId", "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "cancelledBy", + "type": "address" } ], - "name": "TransactionFinalizationFailed", + "name": "TransactionCancelled", "type": "event" }, { @@ -666,17 +910,17 @@ const CONSENSUS_MAIN_CONTRACT = { { "indexed": false, "internalType": "uint256", - "name": "totalUnissuedValue", + "name": "tribunalIndex", "type": "uint256" }, { - "indexed": false, - "internalType": "uint256", - "name": "unissuedCount", - "type": "uint256" + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" } ], - "name": "UnissuedMessagesAtFinalization", + "name": "TribunalAppealVoteCommitted", "type": "event" }, { @@ -689,25 +933,25 @@ const CONSENSUS_MAIN_CONTRACT = { "type": "bytes32" }, { - "indexed": true, - "internalType": "address", - "name": "oldValidator", - "type": "address" + "indexed": false, + "internalType": "uint256", + "name": "tribunalIndex", + "type": "uint256" }, { "indexed": true, "internalType": "address", - "name": "newValidator", + "name": "validator", "type": "address" }, { "indexed": false, - "internalType": "uint256", - "name": "validatorIndex", - "type": "uint256" + "internalType": "enum ITransactions.VoteType", + "name": "voteType", + "type": "uint8" } ], - "name": "ValidatorReplaced", + "name": "TribunalAppealVoteRevealed", "type": "event" }, { @@ -720,9 +964,96 @@ const CONSENSUS_MAIN_CONTRACT = { "type": "bytes32" }, { - "indexed": true, - "internalType": "address", - "name": "recipient", + "indexed": false, + "internalType": "uint256", + "name": "chunkIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "recipients", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "UnifiedFeesDistributed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "UserValueRefunded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "oldValidator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newValidator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "validatorIndex", + "type": "uint256" + } + ], + "name": "ValidatorReplaced", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", "type": "address" }, { @@ -837,15 +1168,15 @@ const CONSENSUS_MAIN_CONTRACT = { "name": "_txId", "type": "bytes32" }, - { - "internalType": "address", - "name": "_operator", - "type": "address" - }, { "internalType": "bytes", "name": "_vrfProof", "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "_expectedAttemptId", + "type": "bytes32" } ], "name": "activateTransaction", @@ -856,38 +1187,178 @@ const CONSENSUS_MAIN_CONTRACT = { { "inputs": [ { - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_numOfInitialValidators", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_maxRotations", - "type": "uint256" + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" }, { - "internalType": "bytes", - "name": "_calldata", - "type": "bytes" - }, + "internalType": "bytes32", + "name": "_expectedAttemptId", + "type": "bytes32" + } + ], + "name": "activatorIdleness", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ { - "internalType": "uint256", - "name": "_validUntil", - "type": "uint256" + "components": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "numOfInitialValidators", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxRotations", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "validUntil", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userValue", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "leaderTimeunitsAllocation", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "validatorTimeunitsAllocation", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealRounds", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "executionBudgetPerRound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "executionConsumed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalMessageFees", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "rotations", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "maxPriceGenPerTimeUnit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "storageFeeMaxGasPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "receiptFeeMaxGasPrice", + "type": "uint256" + } + ], + "internalType": "struct IFeeManager.FeesDistribution", + "name": "feesDistribution", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "txCalldata", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "enum IMessages.MessageType", + "name": "messageType", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "onAcceptance", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "parentIndex", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "callKey", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "budget", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "feeParams", + "type": "bytes" + } + ], + "internalType": "struct IMessages.MessageFeeAllocationNode[]", + "name": "messageAllocations", + "type": "tuple[]" + } + ], + "internalType": "struct IConsensusMainWithFees.AddTransactionParams", + "name": "_params", + "type": "tuple" } ], "name": "addTransaction", - "outputs": [], + "outputs": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + } + ], "stateMutability": "payable", "type": "function" }, @@ -933,6 +1404,11 @@ const CONSENSUS_MAIN_CONTRACT = { "internalType": "uint256", "name": "_validatorIndex", "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_expectedAttemptId", + "type": "bytes32" } ], "name": "commitVote", @@ -943,39 +1419,226 @@ const CONSENSUS_MAIN_CONTRACT = { { "inputs": [ { - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { "internalType": "uint256", - "name": "_numOfInitialValidators", + "name": "expectedDecisionId", "type": "uint256" }, { "internalType": "uint256", - "name": "_maxRotations", + "name": "expectedGeneration", "type": "uint256" - }, + } + ], + "name": "continueAcceptanceMessages", + "outputs": [ { - "internalType": "bytes", - "name": "_calldata", - "type": "bytes" + "internalType": "bool", + "name": "complete", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "continueRecomputation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "numOfInitialValidators", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxRotations", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "validUntil", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userValue", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "leaderTimeunitsAllocation", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "validatorTimeunitsAllocation", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealRounds", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "executionBudgetPerRound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "executionConsumed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalMessageFees", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "rotations", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "maxPriceGenPerTimeUnit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "storageFeeMaxGasPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "receiptFeeMaxGasPrice", + "type": "uint256" + } + ], + "internalType": "struct IFeeManager.FeesDistribution", + "name": "feesDistribution", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "txCalldata", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "enum IMessages.MessageType", + "name": "messageType", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "onAcceptance", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "parentIndex", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "callKey", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "budget", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "feeParams", + "type": "bytes" + } + ], + "internalType": "struct IMessages.MessageFeeAllocationNode[]", + "name": "messageAllocations", + "type": "tuple[]" + } + ], + "internalType": "struct IConsensusMainWithFees.AddTransactionParams", + "name": "_params", + "type": "tuple" + } + ], + "name": "deploySalted", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" }, { "internalType": "uint256", - "name": "_saltNonce", + "name": "_expectedDecisionId", + "type": "uint256" + } + ], + "name": "estimateAppealCharge", + "outputs": [ + { + "internalType": "uint256", + "name": "bond", "type": "uint256" }, { "internalType": "uint256", - "name": "_validUntil", + "name": "funding", "type": "uint256" } ], - "name": "deploySalted", - "outputs": [], - "stateMutability": "payable", + "stateMutability": "view", "type": "function" }, { @@ -994,6 +1657,11 @@ const CONSENSUS_MAIN_CONTRACT = { "internalType": "bytes", "name": "_data", "type": "bytes" + }, + { + "internalType": "uint256", + "name": "_gasLimit", + "type": "uint256" } ], "name": "executeMessage", @@ -1010,12 +1678,55 @@ const CONSENSUS_MAIN_CONTRACT = { { "inputs": [ { - "internalType": "bytes32[]", - "name": "_txIds", - "type": "bytes32[]" + "components": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "expectedDecisionId", + "type": "uint256" + } + ], + "internalType": "struct IFinalizationPhase.FinalizeTransactionParams", + "name": "command", + "type": "tuple" } ], - "name": "finalizeIdlenessTxs", + "name": "finalizeDecisionBatchItem", + "outputs": [ + { + "internalType": "uint8", + "name": "outcome", + "type": "uint8" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "expectedDecisionId", + "type": "uint256" + } + ], + "internalType": "struct IFinalizationPhase.FinalizeTransactionParams[]", + "name": "_commands", + "type": "tuple[]" + } + ], + "name": "finalizeDecisions", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -1026,6 +1737,11 @@ const CONSENSUS_MAIN_CONTRACT = { "internalType": "bytes32", "name": "_txId", "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_expectedDecisionId", + "type": "uint256" } ], "name": "finalizeTransaction", @@ -1033,6 +1749,24 @@ const CONSENSUS_MAIN_CONTRACT = { "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "expectedDecisionId", + "type": "uint256" + } + ], + "name": "finalizeTransactionDeferred", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, { "inputs": [ { @@ -1046,6 +1780,19 @@ const CONSENSUS_MAIN_CONTRACT = { "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "flushInternalMessages", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "getAddressManager", @@ -1094,12 +1841,44 @@ const CONSENSUS_MAIN_CONTRACT = { { "inputs": [ { - "internalType": "address", - "name": "addr", - "type": "address" + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" } ], - "name": "isGhostContract", + "name": "invalidatePreemptedHead", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "caller", + "type": "address" + } + ], + "name": "isAuthorizedGhostCaller", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "isGhostContract", "outputs": [ { "internalType": "bool", @@ -1116,6 +1895,11 @@ const CONSENSUS_MAIN_CONTRACT = { "internalType": "bytes32", "name": "_txId", "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_expectedAttemptId", + "type": "bytes32" } ], "name": "leaderIdleness", @@ -1132,6 +1916,11 @@ const CONSENSUS_MAIN_CONTRACT = { "name": "txId", "type": "bytes32" }, + { + "internalType": "bytes32", + "name": "expectedAttemptId", + "type": "bytes32" + }, { "internalType": "uint256", "name": "saltAsAValidator", @@ -1188,6 +1977,31 @@ const CONSENSUS_MAIN_CONTRACT = { "internalType": "uint256", "name": "saltNonce", "type": "uint256" + }, + { + "internalType": "bytes", + "name": "feeParams", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "declaredBudget", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "allocationSubtree", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "callKey", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "useBalance", + "type": "bool" } ], "internalType": "struct IMessages.SubmittedMessage[]", @@ -1195,7 +2009,7 @@ const CONSENSUS_MAIN_CONTRACT = { "type": "tuple[]" } ], - "internalType": "struct IConsensusMain.LeaderRevealVoteParams", + "internalType": "struct IConsensusMainWithFees.LeaderRevealVoteParams", "name": "leaderRevealVoteParams", "type": "tuple" } @@ -1237,6 +2051,11 @@ const CONSENSUS_MAIN_CONTRACT = { "internalType": "bytes32", "name": "_txId", "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_expectedAttemptId", + "type": "bytes32" } ], "name": "processIdleness", @@ -1248,7 +2067,7 @@ const CONSENSUS_MAIN_CONTRACT = { "inputs": [ { "internalType": "address[]", - "name": "affectedRecipients", + "name": "recipients", "type": "address[]" } ], @@ -1261,49 +2080,79 @@ const CONSENSUS_MAIN_CONTRACT = { "inputs": [ { "internalType": "bytes32", - "name": "_txId", + "name": "", "type": "bytes32" }, { "internalType": "bytes32", - "name": "_txExecutionHash", + "name": "", "type": "bytes32" }, { "internalType": "uint256", - "name": "_processingBlock", + "name": "", "type": "uint256" }, { "internalType": "address", - "name": "_operator", + "name": "", "type": "address" }, { "internalType": "bytes", - "name": "_eqBlocksOutputs", + "name": "", "type": "bytes" }, { "internalType": "bytes", - "name": "_vrfProof", + "name": "", "type": "bytes" } ], "name": "proposeReceipt", "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "pure", "type": "function" }, { "inputs": [ { - "internalType": "bytes32[]", - "name": "_txIds", - "type": "bytes32[]" + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_processingBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_storageFeeUsed", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_eqBlocksOutputs", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "_vrfProof", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "_expectedAttemptId", + "type": "bytes32" } ], - "name": "redButtonFinalize", + "name": "proposeReceipt", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -1311,19 +2160,102 @@ const CONSENSUS_MAIN_CONTRACT = { { "inputs": [ { - "internalType": "address", - "name": "ghost", - "type": "address" + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_processingBlock", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_eqBlocksOutputs", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "_vrfProof", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "_expectedAttemptId", + "type": "bytes32" } ], - "name": "registerGhostContract", + "name": "proposeReceipt", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [], - "name": "renounceOwnership", + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "processingBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "storageFeeUsed", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "eqBlocksOutputs", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "vrfProof", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "reportedMessageFeesTotal", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "expectedAttemptId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "messageBytes", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "messageCount", + "type": "uint256" + } + ], + "internalType": "struct IConsensusMainWithFees.MessageEnvelopeProposal", + "name": "p", + "type": "tuple" + } + ], + "name": "proposeReceiptWithMessageEnvelope", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -1332,90 +2264,448 @@ const CONSENSUS_MAIN_CONTRACT = { "inputs": [ { "internalType": "bytes32", - "name": "_txId", + "name": "", "type": "bytes32" }, { "internalType": "bytes32", - "name": "_voteHash", + "name": "", "type": "bytes32" }, { - "internalType": "enum ITransactions.VoteType", - "name": "_voteType", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "_otherExecutionFieldsHash", - "type": "bytes32" + "internalType": "uint256", + "name": "", + "type": "uint256" }, { "internalType": "uint256", - "name": "_nonce", + "name": "", "type": "uint256" }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + }, { "internalType": "uint256", - "name": "_validatorIndex", + "name": "reportedTotal", "type": "uint256" - } - ], - "name": "revealVote", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ + }, { - "internalType": "address", - "name": "_addressManager", - "type": "address" + "internalType": "bytes32", + "name": "", + "type": "bytes32" } ], - "name": "setAddressManager", + "name": "proposeReceiptWithMessages", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [ + "inputs": [], + "name": "protocolComponentId", + "outputs": [ { "internalType": "bytes32", - "name": "_txId", + "name": "", "type": "bytes32" } ], - "name": "submitAppeal", - "outputs": [], - "stateMutability": "payable", + "stateMutability": "pure", "type": "function" }, { "inputs": [ { "internalType": "address", - "name": "newOwner", + "name": "ghost", "type": "address" } ], - "name": "transferOwnership", + "name": "registerGhostContract", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "stateMutability": "payable", - "type": "receive" - } -], - bytecode: "", -}; - -const CONSENSUS_DATA_CONTRACT = { - address: "0x85D7bf947A512Fc640C75327A780c90847267697" as Address, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "expectedAttemptId", + "type": "bytes32" + } + ], + "internalType": "struct IIdlenessPhase.ProcessIdlenessParams", + "name": "command", + "type": "tuple" + } + ], + "name": "resolveTransactionBatchItem", + "outputs": [ + { + "internalType": "uint8", + "name": "outcome", + "type": "uint8" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "expectedAttemptId", + "type": "bytes32" + } + ], + "internalType": "struct IIdlenessPhase.ProcessIdlenessParams[]", + "name": "_commands", + "type": "tuple[]" + } + ], + "name": "resolveTransactions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + } + ], + "name": "retryFinalizationPromotion", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_voteHash", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.VoteType", + "name": "_voteType", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "_otherExecutionFieldsHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_validatorIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_expectedAttemptId", + "type": "bytes32" + } + ], + "name": "revealVote", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_addressManager", + "type": "address" + } + ], + "name": "setAddressManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_expectedDecisionId", + "type": "uint256" + } + ], + "name": "submitAppeal", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_expectedDecisionId", + "type": "uint256" + } + ], + "name": "topUpAndProgressFinalization", + "outputs": [ + { + "internalType": "bool", + "name": "finalized", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_expectedDecisionId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "leaderTimeunitsAllocation", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "validatorTimeunitsAllocation", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealRounds", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "executionBudgetPerRound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "executionConsumed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalMessageFees", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "rotations", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "maxPriceGenPerTimeUnit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "storageFeeMaxGasPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "receiptFeeMaxGasPrice", + "type": "uint256" + } + ], + "internalType": "struct IFeeManager.FeesDistribution", + "name": "", + "type": "tuple" + } + ], + "name": "topUpAndSubmitAppeal", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "leaderTimeunitsAllocation", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "validatorTimeunitsAllocation", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealRounds", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "executionBudgetPerRound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "executionConsumed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalMessageFees", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "rotations", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "maxPriceGenPerTimeUnit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "storageFeeMaxGasPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "receiptFeeMaxGasPrice", + "type": "uint256" + } + ], + "internalType": "struct IFeeManager.FeesDistribution", + "name": "_feesDistribution", + "type": "tuple" + } + ], + "name": "topUpFees", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferEthOnBehalf", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +], + bytecode: "", +}; + +const CONSENSUS_DATA_CONTRACT = { + address: "0xc5FA6f82BEe53598825d6edf7E3e24613082c75B" as Address, abi: [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, { "inputs": [], "name": "AccessControlBadConfirmation", @@ -1442,6 +2732,16 @@ const CONSENSUS_DATA_CONTRACT = { "name": "InvalidInitialization", "type": "error" }, + { + "inputs": [], + "name": "InvalidRegistry", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTransactionStatus", + "type": "error" + }, { "inputs": [], "name": "NotInitializing", @@ -1469,11 +2769,32 @@ const CONSENSUS_DATA_CONTRACT = { "name": "OwnableUnauthorizedAccount", "type": "error" }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "status", + "type": "uint8" + } + ], + "name": "PhaseDeadlineNotInitialized", + "type": "error" + }, { "inputs": [], "name": "ReentrancyGuardReentrantCall", "type": "error" }, + { + "inputs": [], + "name": "RegistryBindingLocked", + "type": "error" + }, { "anonymous": false, "inputs": [ @@ -1636,52 +2957,514 @@ const CONSENSUS_DATA_CONTRACT = { { "inputs": [ { - "internalType": "bytes32", - "name": "_txId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "_currentTimestamp", - "type": "uint256" - } - ], - "name": "canFinalize", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_currentTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_expectedDecisionId", + "type": "uint256" + } + ], + "name": "canFinalize", + "outputs": [ + { + "internalType": "bool", + "name": "ready", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "evaluatedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealDeadline", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "estimateAppealBond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "estimateLatestAppealCharge", + "outputs": [ + { + "internalType": "uint256", + "name": "decisionId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "funding", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealDeadline", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "getCurrentActivator", + "outputs": [ + { + "internalType": "address", + "name": "newActivator", + "type": "address" + }, + { + "internalType": "bool", + "name": "activatorIsIdle", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "slots", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "secondsUntilNextBoundary", + "type": "uint256" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "currentStatus", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "getCurrentLeader", + "outputs": [ + { + "internalType": "address", + "name": "newLeader", + "type": "address" + }, + { + "internalType": "bool", + "name": "leaderIsIdle", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "slots", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "secondsUntilNextBoundary", + "type": "uint256" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "currentStatus", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "getCurrentValidators", + "outputs": [ + { + "internalType": "address[]", + "name": "validators", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "leaderIndex", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "idleIndexes", + "type": "uint256[]" + }, + { + "internalType": "bool", + "name": "leaderIsIdle", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "slots", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "secondsUntilNextBoundary", + "type": "uint256" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "currentStatus", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "getLatestAcceptedTransaction", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "observedAt", + "type": "uint256" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialRotations", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txSlot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "createdTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastVoteTimestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "randomSeed", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "txCalldata", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "eqBlocksOutputs", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "enum IMessages.MessageType", + "name": "messageType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "onAcceptance", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "feeParams", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "declaredBudget", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "allocationSubtree", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "callKey", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "useBalance", + "type": "bool" + } + ], + "internalType": "struct IMessages.SubmittedMessage[]", + "name": "messages", + "type": "tuple[]" + }, + { + "internalType": "enum IQueues.QueueType", + "name": "queueType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "queuePosition", + "type": "uint256" + }, + { + "internalType": "address", + "name": "activator", + "type": "address" + }, + { + "internalType": "address", + "name": "lastLeader", + "type": "address" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "activationBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "processingBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "proposalBlock", + "type": "uint256" + } + ], + "internalType": "struct ITransactions.ReadStateBlockRange", + "name": "readStateBlockRange", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "numOfRounds", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "round", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "leaderIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesCommitted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesRevealed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealBond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rotationsLeft", + "type": "uint256" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "address[]", + "name": "roundValidators", + "type": "address[]" + }, + { + "internalType": "enum ITransactions.VoteType[]", + "name": "validatorVotes", + "type": "uint8[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorVotesHash", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorResultHash", + "type": "bytes32[]" + } + ], + "internalType": "struct ITransactions.RoundData", + "name": "lastRound", + "type": "tuple" + }, + { + "internalType": "address[]", + "name": "consumedValidators", + "type": "address[]" + } + ], + "internalType": "struct ConsensusData.TransactionData", + "name": "inputData", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" }, { "internalType": "uint256", - "name": "", + "name": "startIndex", "type": "uint256" }, { "internalType": "uint256", - "name": "", + "name": "pageSize", "type": "uint256" } ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - } - ], - "name": "getLatestAcceptedTransaction", + "name": "getLatestAcceptedTransactions", "outputs": [ { "components": [ { "internalType": "uint256", - "name": "currentTimestamp", + "name": "observedAt", "type": "uint256" }, { @@ -1762,14 +3545,39 @@ const CONSENSUS_DATA_CONTRACT = { "type": "bytes" }, { - "internalType": "bool", - "name": "onAcceptance", - "type": "bool" + "internalType": "bool", + "name": "onAcceptance", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "feeParams", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "declaredBudget", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "allocationSubtree", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "callKey", + "type": "bytes32" }, { - "internalType": "uint256", - "name": "saltNonce", - "type": "uint256" + "internalType": "bool", + "name": "useBalance", + "type": "bool" } ], "internalType": "struct IMessages.SubmittedMessage[]", @@ -1901,9 +3709,9 @@ const CONSENSUS_DATA_CONTRACT = { "type": "address[]" } ], - "internalType": "struct ConsensusData.TransactionData", - "name": "inputData", - "type": "tuple" + "internalType": "struct ConsensusData.TransactionData[]", + "name": "", + "type": "tuple[]" } ], "stateMutability": "view", @@ -1915,25 +3723,34 @@ const CONSENSUS_DATA_CONTRACT = { "internalType": "address", "name": "recipient", "type": "address" - }, + } + ], + "name": "getLatestAcceptedTxCount", + "outputs": [ { "internalType": "uint256", - "name": "startIndex", + "name": "", "type": "uint256" - }, + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ { - "internalType": "uint256", - "name": "pageSize", - "type": "uint256" + "internalType": "address", + "name": "recipient", + "type": "address" } ], - "name": "getLatestAcceptedTransactions", + "name": "getLatestFinalizedTransaction", "outputs": [ { "components": [ { "internalType": "uint256", - "name": "currentTimestamp", + "name": "observedAt", "type": "uint256" }, { @@ -2022,6 +3839,31 @@ const CONSENSUS_DATA_CONTRACT = { "internalType": "uint256", "name": "saltNonce", "type": "uint256" + }, + { + "internalType": "bytes", + "name": "feeParams", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "declaredBudget", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "allocationSubtree", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "callKey", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "useBalance", + "type": "bool" } ], "internalType": "struct IMessages.SubmittedMessage[]", @@ -2153,9 +3995,9 @@ const CONSENSUS_DATA_CONTRACT = { "type": "address[]" } ], - "internalType": "struct ConsensusData.TransactionData[]", - "name": "", - "type": "tuple[]" + "internalType": "struct ConsensusData.TransactionData", + "name": "inputData", + "type": "tuple" } ], "stateMutability": "view", @@ -2167,34 +4009,25 @@ const CONSENSUS_DATA_CONTRACT = { "internalType": "address", "name": "recipient", "type": "address" - } - ], - "name": "getLatestAcceptedTxCount", - "outputs": [ + }, { "internalType": "uint256", - "name": "", + "name": "startIndex", "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ + }, { - "internalType": "address", - "name": "recipient", - "type": "address" + "internalType": "uint256", + "name": "pageSize", + "type": "uint256" } ], - "name": "getLatestFinalizedTransaction", + "name": "getLatestFinalizedTransactions", "outputs": [ { "components": [ { "internalType": "uint256", - "name": "currentTimestamp", + "name": "observedAt", "type": "uint256" }, { @@ -2283,6 +4116,31 @@ const CONSENSUS_DATA_CONTRACT = { "internalType": "uint256", "name": "saltNonce", "type": "uint256" + }, + { + "internalType": "bytes", + "name": "feeParams", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "declaredBudget", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "allocationSubtree", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "callKey", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "useBalance", + "type": "bool" } ], "internalType": "struct IMessages.SubmittedMessage[]", @@ -2414,9 +4272,9 @@ const CONSENSUS_DATA_CONTRACT = { "type": "address[]" } ], - "internalType": "struct ConsensusData.TransactionData", - "name": "inputData", - "type": "tuple" + "internalType": "struct ConsensusData.TransactionData[]", + "name": "", + "type": "tuple[]" } ], "stateMutability": "view", @@ -2428,25 +4286,53 @@ const CONSENSUS_DATA_CONTRACT = { "internalType": "address", "name": "recipient", "type": "address" - }, + } + ], + "name": "getLatestFinalizedTxCount", + "outputs": [ { "internalType": "uint256", - "name": "startIndex", + "name": "", "type": "uint256" - }, + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ { - "internalType": "uint256", - "name": "pageSize", - "type": "uint256" + "internalType": "bytes32", + "name": "role", + "type": "bytes32" } ], - "name": "getLatestFinalizedTransactions", + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "getStoredTransactionData", "outputs": [ { "components": [ { "internalType": "uint256", - "name": "currentTimestamp", + "name": "observedAt", "type": "uint256" }, { @@ -2535,6 +4421,31 @@ const CONSENSUS_DATA_CONTRACT = { "internalType": "uint256", "name": "saltNonce", "type": "uint256" + }, + { + "internalType": "bytes", + "name": "feeParams", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "declaredBudget", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "allocationSubtree", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "callKey", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "useBalance", + "type": "bool" } ], "internalType": "struct IMessages.SubmittedMessage[]", @@ -2666,28 +4577,9 @@ const CONSENSUS_DATA_CONTRACT = { "type": "address[]" } ], - "internalType": "struct ConsensusData.TransactionData[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - } - ], - "name": "getLatestFinalizedTxCount", - "outputs": [ - { - "internalType": "uint256", + "internalType": "struct ConsensusData.TransactionData", "name": "", - "type": "uint256" + "type": "tuple" } ], "stateMutability": "view", @@ -2697,16 +4589,16 @@ const CONSENSUS_DATA_CONTRACT = { "inputs": [ { "internalType": "bytes32", - "name": "role", + "name": "_txId", "type": "bytes32" } ], - "name": "getRoleAdmin", + "name": "getStoredTransactionStatus", "outputs": [ { - "internalType": "bytes32", + "internalType": "enum ITransactions.TransactionStatus", "name": "", - "type": "bytes32" + "type": "uint8" } ], "stateMutability": "view", @@ -2734,11 +4626,6 @@ const CONSENSUS_DATA_CONTRACT = { "name": "txExecutionResult", "type": "uint8" }, - { - "internalType": "enum ITransactions.TransactionStatus", - "name": "previousStatus", - "type": "uint8" - }, { "internalType": "enum ITransactions.TransactionStatus", "name": "status", @@ -2855,6 +4742,21 @@ const CONSENSUS_DATA_CONTRACT = { "internalType": "uint256", "name": "storageFeeUsed", "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lockedReceiptGasPrice", + "type": "uint256" + }, + { + "internalType": "address", + "name": "txSigner", + "type": "address" + }, + { + "internalType": "enum ITransactions.QueueContext", + "name": "queueContext", + "type": "uint8" } ], "internalType": "struct ITransactions.Transaction", @@ -2938,196 +4840,214 @@ const CONSENSUS_DATA_CONTRACT = { "internalType": "uint256", "name": "_timestamp", "type": "uint256" - } - ], - "name": "getTransactionData", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "currentTimestamp", - "type": "uint256" - }, - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "initialRotations", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "txSlot", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "createdTimestamp", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "lastVoteTimestamp", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "randomSeed", - "type": "bytes32" - }, + } + ], + "name": "getTransactionLifecycle", + "outputs": [ + { + "components": [ { - "internalType": "enum ITransactions.ResultType", - "name": "result", + "internalType": "enum ITransactions.TransactionStatus", + "name": "storedStatus", "type": "uint8" }, - { - "internalType": "bytes32", - "name": "txExecutionHash", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "txCalldata", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "eqBlocksOutputs", - "type": "bytes" - }, { "components": [ { - "internalType": "enum IMessages.MessageType", - "name": "messageType", + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "storedStatus", "type": "uint8" }, { - "internalType": "address", - "name": "recipient", - "type": "address" + "internalType": "enum ITransactions.TransactionStatus", + "name": "projectedStatus", + "type": "uint8" + }, + { + "internalType": "enum IIdlenessPhase.ResolutionAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "internalType": "enum ITransactionManager.ResolutionSource", + "name": "source", + "type": "uint8" }, { "internalType": "uint256", - "name": "value", + "name": "sourceRound", "type": "uint256" }, { - "internalType": "bytes", - "name": "data", - "type": "bytes" + "internalType": "uint256", + "name": "sourceGeneration", + "type": "uint256" }, { - "internalType": "bool", - "name": "onAcceptance", - "type": "bool" + "internalType": "bytes32", + "name": "sourceRoundContextHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "roundPlanHash", + "type": "bytes32" }, { "internalType": "uint256", - "name": "saltNonce", + "name": "resultRound", "type": "uint256" - } - ], - "internalType": "struct IMessages.SubmittedMessage[]", - "name": "messages", - "type": "tuple[]" - }, - { - "internalType": "enum IQueues.QueueType", - "name": "queueType", - "type": "uint8" - }, - { - "internalType": "uint256", - "name": "queuePosition", - "type": "uint256" - }, - { - "internalType": "address", - "name": "activator", - "type": "address" - }, - { - "internalType": "address", - "name": "lastLeader", - "type": "address" - }, - { - "internalType": "enum ITransactions.TransactionStatus", - "name": "status", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "txId", - "type": "bytes32" - }, - { - "components": [ + }, { "internalType": "uint256", - "name": "activationBlock", + "name": "resultGeneration", "type": "uint256" }, { "internalType": "uint256", - "name": "processingBlock", + "name": "basisDecisionId", "type": "uint256" }, + { + "internalType": "enum ITransactionManager.ResolutionContext", + "name": "context", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "attemptId", + "type": "bytes32" + }, { "internalType": "uint256", - "name": "proposalBlock", + "name": "boundaryAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "evaluatedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "snapshotBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "decisionWindow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealDeadline", "type": "uint256" + }, + { + "internalType": "bool", + "name": "materializesDecision", + "type": "bool" + }, + { + "internalType": "bool", + "name": "actionOutcomeDeterministic", + "type": "bool" + }, + { + "internalType": "bool", + "name": "nonCurrentEvaluation", + "type": "bool" } ], - "internalType": "struct ITransactions.ReadStateBlockRange", - "name": "readStateBlockRange", + "internalType": "struct IIdlenessPhase.ResolutionPlan", + "name": "resolution", "type": "tuple" }, - { - "internalType": "uint256", - "name": "numOfRounds", - "type": "uint256" - }, { "components": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, { "internalType": "uint256", - "name": "round", + "name": "decisionId", "type": "uint256" }, { "internalType": "uint256", - "name": "leaderIndex", + "name": "basisDecisionId", "type": "uint256" }, + { + "internalType": "enum ITransactionManager.ResolutionContext", + "name": "context", + "type": "uint8" + }, + { + "internalType": "enum ITransactionManager.ResolutionSource", + "name": "source", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "sourceAttemptId", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "sourceStatus", + "type": "uint8" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "status", + "type": "uint8" + }, { "internalType": "uint256", - "name": "votesCommitted", + "name": "sourceRound", "type": "uint256" }, { "internalType": "uint256", - "name": "votesRevealed", + "name": "sourceGeneration", "type": "uint256" }, + { + "internalType": "bytes32", + "name": "sourceRoundContextHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "roundPlanHash", + "type": "bytes32" + }, { "internalType": "uint256", - "name": "appealBond", + "name": "resultRound", "type": "uint256" }, { "internalType": "uint256", - "name": "rotationsLeft", + "name": "resultGeneration", "type": "uint256" }, { @@ -3136,68 +5056,49 @@ const CONSENSUS_DATA_CONTRACT = { "type": "uint8" }, { - "internalType": "address[]", - "name": "roundValidators", - "type": "address[]" + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" }, { - "internalType": "enum ITransactions.VoteType[]", - "name": "validatorVotes", - "type": "uint8[]" + "internalType": "uint256", + "name": "effectiveAt", + "type": "uint256" }, { - "internalType": "bytes32[]", - "name": "validatorVotesHash", - "type": "bytes32[]" + "internalType": "uint256", + "name": "materializedAt", + "type": "uint256" }, { - "internalType": "bytes32[]", - "name": "validatorResultHash", - "type": "bytes32[]" + "internalType": "uint256", + "name": "appealDeadline", + "type": "uint256" } ], - "internalType": "struct ITransactions.RoundData", - "name": "lastRound", + "internalType": "struct ITransactionManager.DecisionRecord", + "name": "latestDecision", "type": "tuple" }, { - "internalType": "address[]", - "name": "consumedValidators", - "type": "address[]" + "internalType": "bool", + "name": "decisionActive", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "executionGeneration", + "type": "uint256" } ], - "internalType": "struct ConsensusData.TransactionData", - "name": "", + "internalType": "struct ConsensusData.TransactionLifecycle", + "name": "lifecycle", "type": "tuple" } ], "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_txId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "getTransactionStatus", - "outputs": [ - { - "internalType": "enum ITransactions.TransactionStatus", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -3272,6 +5173,35 @@ const CONSENSUS_DATA_CONTRACT = { "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "round", + "type": "uint256" + }, + { + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "isRoundValidator", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "owner", @@ -3298,6 +5228,19 @@ const CONSENSUS_DATA_CONTRACT = { "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "protocolComponentId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, { "inputs": [], "name": "renounceOwnership", diff --git a/src/client/client.ts b/src/client/client.ts index 5e46852..54d3c17 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -69,6 +69,11 @@ const assertChainMatch = async ( } }; +// Public chain RPCs rate-limit bursts with HTTP 429. Reads are retried with +// backoff; writes never are, so a transaction cannot be broadcast twice (#110). +const RATE_LIMIT_RETRIES = 3; +const RETRYABLE_READS = /^(eth_call|eth_get\w+|eth_chainId|eth_blockNumber|eth_gasPrice|eth_estimateGas|net_version)$/; + const getCustomTransportConfig = (config: ClientConfig, chainConfig: GenLayerChain) => { const isAddress = typeof config.account !== "object"; @@ -90,18 +95,26 @@ const getCustomTransportConfig = (config: ClientConfig, chainConfig: GenLayerCha } try { - const response = await fetch(chainConfig.rpcUrls.default.http[0], { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - jsonrpc: "2.0", - id: Date.now(), - method, - params, - }), - }); + let response: Response; + for (let attempt = 0; ; attempt++) { + response = await fetch(chainConfig.rpcUrls.default.http[0], { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + jsonrpc: "2.0", + id: Date.now(), + method, + params, + }), + }); + if (response.status !== 429 || attempt >= RATE_LIMIT_RETRIES || !RETRYABLE_READS.test(method)) break; + const retryAfter = Number(response.headers.get("retry-after")); + await new Promise(resolve => + setTimeout(resolve, retryAfter > 0 ? Math.min(retryAfter * 1000, 10_000) : 1000 * 2 ** attempt), + ); + } const data = await response.json(); @@ -129,10 +142,11 @@ const getCustomTransportConfig = (config: ClientConfig, chainConfig: GenLayerCha * @returns Configured client with contract, transaction, and staking methods */ export const createClient = (config: ClientConfig = {chain: localnet}): GenLayerClient => { - const chainConfig = config.chain || localnet; - if (config.endpoint) { - chainConfig.rpcUrls.default.http = [config.endpoint]; - } + const baseChain = config.chain || localnet; + // Copy instead of mutating: exported chain presets are shared by every client. + const chainConfig = config.endpoint + ? {...baseChain, rpcUrls: {...baseChain.rpcUrls, default: {...baseChain.rpcUrls.default, http: [config.endpoint]}}} + : baseChain; const customTransport = custom(getCustomTransportConfig(config, chainConfig as GenLayerChain), {retryCount: 0, retryDelay: 0}); const publicClient = createPublicClient(chainConfig as GenLayerChain, customTransport).extend( diff --git a/tests/chains-config.test.ts b/tests/chains-config.test.ts index a8e8028..fae2e05 100644 --- a/tests/chains-config.test.ts +++ b/tests/chains-config.test.ts @@ -1,5 +1,5 @@ import {describe, expect, it} from "vitest"; -import {studioDevnet, studionet} from "../src/chains"; +import {studioDevnet, studionet, testnetBradbury} from "../src/chains"; describe("Studio chain presets", () => { it("exports the dedicated Studio preview deployment", () => { @@ -30,3 +30,20 @@ describe("Studio chain presets", () => { ]); }); }); + +describe("Bradbury chain preset", () => { + it("targets the Bradbury Phase 2 deployment", () => { + expect(testnetBradbury).toMatchObject({ + id: 4221, + isStudio: false, + rpcUrls: {default: {http: ["https://rpc.testnet-chain.genlayer.com"]}}, + blockExplorers: {default: {url: "https://scan.testnet-chain.genlayer.com"}}, + }); + expect(testnetBradbury.consensusMainContract?.address).toBe("0x2E2766cbc3E5e61Ce93bBcdCBb3eAcB82082A019"); + expect(testnetBradbury.consensusDataContract?.address).toBe("0xc5FA6f82BEe53598825d6edf7E3e24613082c75B"); + expect(testnetBradbury.stakingContract?.address).toBe("0xD8fBa96C0dBB0257028dBc0107060b958e5c7113"); + expect(testnetBradbury.feeManagerContract?.address).toBe("0x7678587A847712f2A96082AC07883A88D0fc7245"); + expect(testnetBradbury.roundsStorageContract?.address).toBe("0x4038d4F72C7aAbA5a442cC0dA946012B9E3f4B8a"); + expect(testnetBradbury.appealsContract?.address).toBe("0xdc953c3bCf8837987853ca05a78D52fFC3E18651"); + }); +}); diff --git a/tests/client.test.ts b/tests/client.test.ts index c050038..6147770 100644 --- a/tests/client.test.ts +++ b/tests/client.test.ts @@ -20,6 +20,15 @@ describe("Client Creation", () => { expect(client).toBeDefined(); expect(client.chain).toBe(localnet); }); + + it("should not change the shared chain preset when overriding the endpoint", () => { + const defaultRpc = localnet.rpcUrls.default.http; + const first = createClient({chain: localnet, endpoint: "https://first.example"}); + const second = createClient({chain: localnet, endpoint: "https://second.example"}); + expect(first.chain.rpcUrls.default.http).toEqual(["https://first.example"]); + expect(second.chain.rpcUrls.default.http).toEqual(["https://second.example"]); + expect(localnet.rpcUrls.default.http).toEqual(defaultRpc); + }); }); describe("Client Overrides", () => { @@ -184,3 +193,34 @@ describe("Client Overrides", () => { ]); }); }); + +describe("RPC rate limiting", () => { + beforeEach(() => mockFetch.mockReset()); + + it("retries a rate-limited read", async () => { + vi.useFakeTimers(); + try { + mockFetch + .mockResolvedValueOnce(new Response("", {status: 429})) + .mockResolvedValueOnce(new Response(JSON.stringify({jsonrpc: "2.0", id: 1, result: "0x107d"}))); + const client = createClient({chain: localnet}); + const result = client.request({method: "eth_chainId"}); + await vi.runAllTimersAsync(); + await expect(result).resolves.toBe("0x107d"); + expect(mockFetch).toHaveBeenCalledTimes(2); + } finally { + vi.useRealTimers(); + } + }); + + it("never retries a rate-limited broadcast", async () => { + mockFetch.mockResolvedValue( + new Response(JSON.stringify({jsonrpc: "2.0", id: 1, error: {code: 429, message: "Rate Limit Exceeded"}}), { + status: 429, + }), + ); + const client = createClient({chain: localnet}); + await expect(client.request({method: "eth_sendRawTransaction", params: ["0x01"]})).rejects.toBeDefined(); + expect(mockFetch).toHaveBeenCalledTimes(1); + }); +});