diff --git a/core/go/internal/domainmgr/event_indexer.go b/core/go/internal/domainmgr/event_indexer.go index c0d82089f..c4262790f 100644 --- a/core/go/internal/domainmgr/event_indexer.go +++ b/core/go/internal/domainmgr/event_indexer.go @@ -47,7 +47,7 @@ func (dm *domainManager) eventIndexer(ctx context.Context, tx *gorm.DB, batch *b DeployTX: parsedEvent.TXId.UUIDFirst16(), RegistryAddress: ev.Address, Address: parsedEvent.Instance, - ConfigBytes: parsedEvent.Data, + ConfigBytes: parsedEvent.Config, }) } } diff --git a/core/go/internal/domainmgr/event_indexer_test.go b/core/go/internal/domainmgr/event_indexer_test.go index 05e37c89c..d7fba898c 100644 --- a/core/go/internal/domainmgr/event_indexer_test.go +++ b/core/go/internal/domainmgr/event_indexer_test.go @@ -35,7 +35,7 @@ func TestSolidityEventSignatures(t *testing.T) { // We don't store it as a constant because we're reliant on us and blockindexer calculating it identically (we use the same lib). // // The standard solidity signature is insufficient, as it doesn't include variable names, or the indexed-ness of fields - assert.Equal(t, "event PaladinRegisterSmartContract_V0(bytes32 indexed txId, address indexed instance, bytes data)", eventSolSig_PaladinRegisterSmartContract_V0) + assert.Equal(t, "event PaladinRegisterSmartContract_V0(bytes32 indexed txId, address indexed instance, bytes config)", eventSolSig_PaladinRegisterSmartContract_V0) } func TestEventIndexingWithDB(t *testing.T) { @@ -75,7 +75,7 @@ func TestEventIndexingWithDB(t *testing.T) { Data: tktypes.RawJSON(`{ "txId": "` + tktypes.Bytes32UUIDFirst16(deployTX).String() + `", "instance": "` + contractAddr.String() + `", - "data": "0xfeedbeef" + "config": "0xfeedbeef" }`), }, }, @@ -126,7 +126,7 @@ func TestEventIndexingBadEvent(t *testing.T) { { SoliditySignature: eventSolSig_PaladinRegisterSmartContract_V0, Data: tktypes.RawJSON(`{ - "data": "cannot parse this" + "config": "cannot parse this" }`), }, }, diff --git a/core/go/internal/domainmgr/manager.go b/core/go/internal/domainmgr/manager.go index 5a8a3a380..49452f50a 100644 --- a/core/go/internal/domainmgr/manager.go +++ b/core/go/internal/domainmgr/manager.go @@ -88,7 +88,7 @@ type event_PaladinRegisterSmartContract_V0 struct { TXId tktypes.Bytes32 `json:"txId"` Domain tktypes.EthAddress `json:"domain"` Instance tktypes.EthAddress `json:"instance"` - Data tktypes.HexBytes `json:"data"` + Config tktypes.HexBytes `json:"config"` } func (dm *domainManager) PreInit(pic components.PreInitComponents) (*components.ManagerInitResult, error) { diff --git a/core/go/pkg/testbed/ut_simdomain_notarized_token_test.go b/core/go/pkg/testbed/ut_simdomain_notarized_token_test.go index cd39bfd26..ba092adfb 100644 --- a/core/go/pkg/testbed/ut_simdomain_notarized_token_test.go +++ b/core/go/pkg/testbed/ut_simdomain_notarized_token_test.go @@ -607,19 +607,14 @@ func deploySmartContract(t *testing.T, confFile string) *tktypes.EthAddress { tb := NewTestBed() - getComponents := make(chan AllComponents, 1) - _, done, err := tb.StartForTest(confFile, nil, &UTInitFunction{PreManagerStart: func(c AllComponents) error { - getComponents <- c - return nil - }}) + _, done, err := tb.StartForTest(confFile, nil) require.NoError(t, err) defer done() - c := <-getComponents - bi := c.BlockIndexer() + bi := tb.Components().BlockIndexer() // In this test we deploy the factory in-line - ec, err := c.EthClientFactory().HTTPClient().ABI(ctx, simDomainABI) + ec, err := tb.Components().EthClientFactory().HTTPClient().ABI(ctx, simDomainABI) require.NoError(t, err) cc, err := ec.Constructor(ctx, mustParseBuildBytecode(simDomainBuild)) diff --git a/domains/pente/src/main/java/io/kaleido/paladin/pente/domain/PenteConfiguration.java b/domains/pente/src/main/java/io/kaleido/paladin/pente/domain/PenteConfiguration.java index f52188c9c..4029636ef 100644 --- a/domains/pente/src/main/java/io/kaleido/paladin/pente/domain/PenteConfiguration.java +++ b/domains/pente/src/main/java/io/kaleido/paladin/pente/domain/PenteConfiguration.java @@ -144,12 +144,6 @@ record NewPrivacyGroupFactoryParams( JsonHex.Bytes data ) {} - @JsonIgnoreProperties(ignoreUnknown = true) - private record PenteYAMLConfig( - @JsonProperty - String address - ) {} - public static byte[] intToBytes4(int val) { return ByteBuffer.allocate(4).putInt(val).array(); } diff --git a/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/PenteDomainTests.java b/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/PenteDomainTests.java index 0e6499f9f..8a5261633 100644 --- a/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/PenteDomainTests.java +++ b/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/PenteDomainTests.java @@ -15,15 +15,11 @@ package io.kaleido.paladin.pente.domain; -import io.kaleido.paladin.pente.domain.PenteConfiguration; -import io.kaleido.paladin.pente.domain.PenteDomainFactory; import io.kaleido.paladin.pente.evmrunner.EVMRunner; import io.kaleido.paladin.toolkit.*; import org.hyperledger.besu.datatypes.Address; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import java.util.Collections; import java.util.HashMap; import java.util.Map; diff --git a/solidity/contracts/domains/interfaces/IPaladinContractRegistry.sol b/solidity/contracts/domains/interfaces/IPaladinContractRegistry.sol index 3ee544418..ce0090ec1 100644 --- a/solidity/contracts/domains/interfaces/IPaladinContractRegistry.sol +++ b/solidity/contracts/domains/interfaces/IPaladinContractRegistry.sol @@ -1,15 +1,22 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; -// This is kept separate from the IPaladinContract_V0 interface to allow -// for separate event streams attached to specific trusted factory addresses. -// The IPaladinContract_V0 events can be indexed from the whole ledger -// because the contract address is parsed from the protocol-generated data -// which can be trusted to be correct. +/// A contract registry is a trusted smart contract that announces the existence of +/// new smart contracts instances of that are part of a single domain. +/// @author https://github.com/kaleido-io/paladin +/// @title Paladin contract registry interface IPaladinContractRegistry_V0 { + + /// The event emitted when a new smart contract is deployed, provides the public + /// configuration information that is needed to configure the off-chain components + /// of the domain to correctly function against the new instance. + /// @param txId the submitter-determined transaction id is used to correlate the event to the submitting business transaction + /// @param instance the address of the instance smart contract that has been deployed + /// @param config encoded parameters that all nodes functioning against this smart contact instance need to know event PaladinRegisterSmartContract_V0( bytes32 indexed txId, address indexed instance, - bytes data + bytes config ); + } diff --git a/solidity/contracts/domains/noto/Noto.sol b/solidity/contracts/domains/noto/Noto.sol index dbdb7d704..41ada7fc0 100644 --- a/solidity/contracts/domains/noto/Noto.sol +++ b/solidity/contracts/domains/noto/Noto.sol @@ -52,9 +52,7 @@ contract Noto is EIP712, INoto { } constructor( - bytes32 transactionId, - address notary, - bytes memory data + address notary ) EIP712("noto", "0.0.1") { _notary = notary; } diff --git a/solidity/contracts/domains/noto/NotoFactory.sol b/solidity/contracts/domains/noto/NotoFactory.sol index 43a82db39..b0c3f9639 100644 --- a/solidity/contracts/domains/noto/NotoFactory.sol +++ b/solidity/contracts/domains/noto/NotoFactory.sol @@ -10,7 +10,7 @@ contract NotoFactory is IPaladinContractRegistry_V0 { address notary, bytes memory data ) external { - Noto instance = new Noto(transactionId, notary, data); + Noto instance = new Noto(notary); emit PaladinRegisterSmartContract_V0( transactionId, diff --git a/solidity/contracts/domains/noto/NotoSelfSubmit.sol b/solidity/contracts/domains/noto/NotoSelfSubmit.sol index 9eb6db014..81b565ed1 100644 --- a/solidity/contracts/domains/noto/NotoSelfSubmit.sol +++ b/solidity/contracts/domains/noto/NotoSelfSubmit.sol @@ -11,10 +11,8 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; */ contract NotoSelfSubmit is Noto { constructor( - bytes32 transactionId, - address notary, - bytes memory data - ) Noto(transactionId, notary, data) {} + address notary + ) Noto(notary) {} function transfer( bytes32[] memory inputs, diff --git a/solidity/contracts/domains/noto/NotoSelfSubmitFactory.sol b/solidity/contracts/domains/noto/NotoSelfSubmitFactory.sol index 23fcd3294..750c2f593 100644 --- a/solidity/contracts/domains/noto/NotoSelfSubmitFactory.sol +++ b/solidity/contracts/domains/noto/NotoSelfSubmitFactory.sol @@ -2,13 +2,20 @@ pragma solidity ^0.8.20; import {NotoSelfSubmit} from "./NotoSelfSubmit.sol"; +import {IPaladinContractRegistry_V0} from "../interfaces/IPaladinContractRegistry.sol"; -contract NotoSelfSubmitFactory { +contract NotoSelfSubmitFactory is IPaladinContractRegistry_V0 { function deploy( bytes32 transactionId, address notary, bytes memory data ) external { - new NotoSelfSubmit(transactionId, notary, data); + NotoSelfSubmit instance = new NotoSelfSubmit(notary); + + emit PaladinRegisterSmartContract_V0( + transactionId, + address(instance), + data + ); } } diff --git a/solidity/test/domains/noto/Noto.ts b/solidity/test/domains/noto/Noto.ts index 0454c1fa7..6f4bcb6d8 100644 --- a/solidity/test/domains/noto/Noto.ts +++ b/solidity/test/domains/noto/Noto.ts @@ -3,7 +3,7 @@ import { expect } from "chai"; import { randomBytes } from "crypto"; import { ContractTransactionReceipt, Signer, TypedDataEncoder } from "ethers"; import hre, { ethers } from "hardhat"; -import { Noto } from "../../typechain-types"; +import { Noto } from "../../../typechain-types"; export async function newTransferHash( noto: Noto, @@ -44,9 +44,7 @@ describe("Noto", function () { const Noto = await ethers.getContractFactory("Noto"); const noto = await Noto.deploy( - randomBytes32(), notary.address, - "0x" ); return { noto, notary, other }; diff --git a/solidity/test/domains/noto/NotoSelfSubmit.ts b/solidity/test/domains/noto/NotoSelfSubmit.ts index c45181749..d7d30977b 100644 --- a/solidity/test/domains/noto/NotoSelfSubmit.ts +++ b/solidity/test/domains/noto/NotoSelfSubmit.ts @@ -2,7 +2,7 @@ import { loadFixture } from "@nomicfoundation/hardhat-toolbox/network-helpers"; import { expect } from "chai"; import { ContractTransactionReceipt, Signer } from "ethers"; import hre, { ethers } from "hardhat"; -import { NotoSelfSubmit } from "../../typechain-types"; +import { NotoSelfSubmit } from "../../../typechain-types"; import { fakeTXO, randomBytes32 } from "./Noto"; export async function prepareSignature( @@ -35,9 +35,7 @@ describe("NotoSelfSubmit", function () { const Noto = await ethers.getContractFactory("NotoSelfSubmit"); const noto = await Noto.deploy( - randomBytes32(), notary.address, - "0x" ); return { noto, notary, other }; diff --git a/solidity/test/domains/pente/PentePrivacyGroup.ts b/solidity/test/domains/pente/PentePrivacyGroup.ts index 99264f596..19b65036a 100644 --- a/solidity/test/domains/pente/PentePrivacyGroup.ts +++ b/solidity/test/domains/pente/PentePrivacyGroup.ts @@ -63,7 +63,7 @@ describe("PentePrivacyGroup", function () { expect(factoryTX!.logs[1].address).to.equal(await penteFactory.getAddress()); expect(deployEvent?.name).to.equal('PaladinRegisterSmartContract_V0'); expect(deployEvent?.args.toObject()["txId"]).to.equal(deployTxId); - expect(deployEvent?.args.toObject()["data"]).to.equal(configBytes); + expect(deployEvent?.args.toObject()["config"]).to.equal(configBytes); const privacyGroupAddress = deployEvent?.args.toObject()["instance"]; const privacyGroup = await hre.ethers.getContractAt("PentePrivacyGroup", privacyGroupAddress); diff --git a/solidity/test/domains/testbed_sim/SIMDomain.ts b/solidity/test/domains/testbed_sim/SIMDomain.ts index 10dc1e751..73441baef 100644 --- a/solidity/test/domains/testbed_sim/SIMDomain.ts +++ b/solidity/test/domains/testbed_sim/SIMDomain.ts @@ -33,7 +33,7 @@ describe("SIMDomain", function () { const deployEvent = SIMDomain.interface.parseLog(factoryTX!.logs[0]) expect(deployEvent?.name).to.equal('PaladinRegisterSmartContract_V0'); expect(deployEvent?.args.toObject()["txId"]).to.equal(deployTxId); - expect(deployEvent?.args.toObject()["data"]).to.equal(abiCoder.encode(['string'], ['my/notary'])); + expect(deployEvent?.args.toObject()["config"]).to.equal(abiCoder.encode(['string'], ['my/notary'])); const deployedAddr = deployEvent?.args.toObject()["instance"]; // Now we have the token - create a client for it using the notary address diff --git a/solidity/test/shared/atom/Atom.ts b/solidity/test/shared/atom/Atom.ts index d425a34c7..86ec5ac86 100644 --- a/solidity/test/shared/atom/Atom.ts +++ b/solidity/test/shared/atom/Atom.ts @@ -19,9 +19,7 @@ describe("Atom", function () { // Deploy two contracts const noto = await Noto.connect(notary1).deploy( - randomBytes32(), notary1.address, - "0x" ); const erc20 = await ERC20Simple.connect(notary2).deploy("Token", "TOK"); @@ -107,9 +105,7 @@ describe("Atom", function () { // Deploy noto contract const noto = await Noto.connect(notary1).deploy( - randomBytes32(), notary1.address, - "0x" ); // Fake up a delegation