diff --git a/contracts/interfaces/IToposCore.sol b/contracts/interfaces/IToposCore.sol index f5dbc4d..80e73f2 100644 --- a/contracts/interfaces/IToposCore.sol +++ b/contracts/interfaces/IToposCore.sol @@ -9,6 +9,7 @@ interface IToposCore { CertificateId prevId; SubnetId sourceSubnetId; bytes32 stateRoot; + bytes32 txRoot; bytes32 receiptRoot; SubnetId[] targetSubnets; uint32 verifier; diff --git a/contracts/topos-core/ToposCore.sol b/contracts/topos-core/ToposCore.sol index 7fd25e0..795d14d 100644 --- a/contracts/topos-core/ToposCore.sol +++ b/contracts/topos-core/ToposCore.sol @@ -62,6 +62,7 @@ contract ToposCore is IToposCore, AdminMultisigBase, Initializable { CertificateId prevId, SubnetId sourceSubnetId, bytes32 stateRoot, + bytes32 txRoot, bytes32 receiptRoot, SubnetId[] memory targetSubnets, uint32 verifier, @@ -70,7 +71,7 @@ contract ToposCore is IToposCore, AdminMultisigBase, Initializable { bytes memory signature ) = abi.decode( certBytes, - (CertificateId, SubnetId, bytes32, bytes32, SubnetId[], uint32, CertificateId, bytes, bytes) + (CertificateId, SubnetId, bytes32, bytes32, bytes32, SubnetId[], uint32, CertificateId, bytes, bytes) ); certificateSet.insert(CertificateId.unwrap(certId)); // add certificate ID to the CRUD storage set @@ -78,6 +79,7 @@ contract ToposCore is IToposCore, AdminMultisigBase, Initializable { newCert.prevId = prevId; newCert.sourceSubnetId = sourceSubnetId; newCert.stateRoot = stateRoot; + newCert.txRoot = txRoot; newCert.receiptRoot = receiptRoot; newCert.targetSubnets = targetSubnets; newCert.verifier = verifier; diff --git a/test/topos-core/ToposCore.test.ts b/test/topos-core/ToposCore.test.ts index bb9ef85..2d25b2b 100644 --- a/test/topos-core/ToposCore.test.ts +++ b/test/topos-core/ToposCore.test.ts @@ -11,6 +11,7 @@ describe('ToposCore', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, cc.RECEIPT_ROOT_MAX, [cc.TARGET_SUBNET_ID_4, cc.TARGET_SUBNET_ID_5], cc.VERIFIER, @@ -141,6 +142,7 @@ describe('ToposCore', () => { cc.PREV_CERT_ID_0, checkpoint[2].toString(), cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, cc.RECEIPT_ROOT_MAX, [cc.TARGET_SUBNET_ID_4], cc.VERIFIER, @@ -175,6 +177,7 @@ describe('ToposCore', () => { cc.PREV_CERT_ID_0, checkpoint[2].toString(), cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, cc.RECEIPT_ROOT_MAX, [cc.TARGET_SUBNET_ID_4], cc.VERIFIER, @@ -201,6 +204,7 @@ describe('ToposCore', () => { cc.PREV_CERT_ID_0, updatedTestCheckpoint[2].toString(), cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, cc.RECEIPT_ROOT_MAX, [cc.TARGET_SUBNET_ID_4], cc.VERIFIER, diff --git a/test/topos-core/ToposMessaging.test.ts b/test/topos-core/ToposMessaging.test.ts index d64f13c..9eac988 100644 --- a/test/topos-core/ToposMessaging.test.ts +++ b/test/topos-core/ToposMessaging.test.ts @@ -30,6 +30,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, cc.RECEIPT_ROOT_MAX, [cc.TARGET_SUBNET_ID_4, cc.TARGET_SUBNET_ID_5], cc.VERIFIER, @@ -261,6 +262,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, receiptsRoot, [cc.SOURCE_SUBNET_ID_2], cc.VERIFIER, @@ -333,6 +335,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, receiptsRoot, [cc.SOURCE_SUBNET_ID_2], cc.VERIFIER, @@ -373,6 +376,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, receiptsRoot, [cc.SOURCE_SUBNET_ID_2], cc.VERIFIER, @@ -403,6 +407,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, txc.INVALID_STATUS_TRANSACTION.receiptRoot, [cc.SOURCE_SUBNET_ID_2], cc.VERIFIER, @@ -446,6 +451,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, receiptsRoot, [cc.SOURCE_SUBNET_ID_2], cc.VERIFIER, @@ -481,6 +487,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, receiptsRoot, [cc.SOURCE_SUBNET_ID_2], cc.VERIFIER, @@ -503,6 +510,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, txc.UNKNOWN_TOKEN_TRANSACTION.receiptRoot, [cc.SOURCE_SUBNET_ID_2], cc.VERIFIER, @@ -530,6 +538,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, txc.MINT_EXCEED_TRANSACTION.receiptRoot, [cc.SOURCE_SUBNET_ID_2], cc.VERIFIER, @@ -557,6 +566,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, txc.ZERO_ADDRESS_TRANSACTION.receiptRoot, [cc.SOURCE_SUBNET_ID_2], cc.VERIFIER, @@ -595,6 +605,7 @@ describe('ToposMessaging', () => { cc.PREV_CERT_ID_0, cc.SOURCE_SUBNET_ID_1, cc.STATE_ROOT_MAX, + cc.TX_ROOT_MAX, receiptsRoot, [cc.SOURCE_SUBNET_ID_2], cc.VERIFIER, diff --git a/test/topos-core/shared/constants/certificates.ts b/test/topos-core/shared/constants/certificates.ts index 9c9ce7d..bb41fad 100644 --- a/test/topos-core/shared/constants/certificates.ts +++ b/test/topos-core/shared/constants/certificates.ts @@ -16,6 +16,8 @@ export const DUMMY_STARK_PROOF = ethers.utils.formatBytes32String('starkProof') export const DUMMY_SIGNATURE = ethers.utils.formatBytes32String('signature') export const PREV_CERT_ID_0 = '0x0000000000000000000000000000000000000000000000000000000000000000' +export const RECEIPT_ROOT_MAX = + '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' export const SOURCE_SUBNET_ID_1 = '0x0000000000000000000000000000000000000000000000000000000000000001' export const SOURCE_SUBNET_ID_2 = @@ -30,6 +32,6 @@ export const TARGET_SUBNET_ID_5 = '0x0000000000000000000000000000000000000000000000000000000000000005' export const TARGET_SUBNET_ID_6 = '0x0000000000000000000000000000000000000000000000000000000000000006' -export const RECEIPT_ROOT_MAX = +export const TX_ROOT_MAX = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' export const VERIFIER = 1 diff --git a/test/topos-core/shared/utils/common.ts b/test/topos-core/shared/utils/common.ts index 7dd37c6..9b16922 100644 --- a/test/topos-core/shared/utils/common.ts +++ b/test/topos-core/shared/utils/common.ts @@ -4,6 +4,7 @@ function encodeCertParam( prevId: string, sourceSubnetId: string, stateRoot: string, + txRoot: string, receiptRoot: string, targetSubnets: string[], verifier: number, @@ -17,6 +18,7 @@ function encodeCertParam( 'bytes32', 'bytes32', 'bytes32', + 'bytes32', 'bytes32[]', 'uint32', 'bytes32', @@ -27,6 +29,7 @@ function encodeCertParam( prevId, sourceSubnetId, stateRoot, + txRoot, receiptRoot, targetSubnets, verifier,