Skip to content

Commit

Permalink
Merge pull request #157 from kaleido-io/137-updates
Browse files Browse the repository at this point in the history
Tweaks from review on #137
  • Loading branch information
peterbroadhurst authored Sep 13, 2024
2 parents 05becc7 + c40cd48 commit 431efac
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 51 deletions.
2 changes: 1 addition & 1 deletion core/go/internal/domainmgr/event_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/go/internal/domainmgr/event_indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestEventIndexingWithDB(t *testing.T) {
Data: tktypes.RawJSON(`{
"txId": "` + tktypes.Bytes32UUIDFirst16(deployTX).String() + `",
"instance": "` + contractAddr.String() + `",
"data": "0xfeedbeef"
"config": "0xfeedbeef"
}`),
},
},
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestEventIndexingBadEvent(t *testing.T) {
{
SoliditySignature: eventSolSig_PaladinRegisterSmartContract_V0,
Data: tktypes.RawJSON(`{
"data": "cannot parse this"
"config": "cannot parse this"
}`),
},
},
Expand Down
2 changes: 1 addition & 1 deletion core/go/internal/domainmgr/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 3 additions & 8 deletions core/go/pkg/testbed/ut_simdomain_notarized_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
19 changes: 13 additions & 6 deletions solidity/contracts/domains/interfaces/IPaladinContractRegistry.sol
Original file line number Diff line number Diff line change
@@ -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
);

}
4 changes: 1 addition & 3 deletions solidity/contracts/domains/noto/Noto.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/domains/noto/NotoFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions solidity/contracts/domains/noto/NotoSelfSubmit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 9 additions & 2 deletions solidity/contracts/domains/noto/NotoSelfSubmitFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
4 changes: 1 addition & 3 deletions solidity/test/domains/noto/Noto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 };
Expand Down
4 changes: 1 addition & 3 deletions solidity/test/domains/noto/NotoSelfSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 };
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/domains/pente/PentePrivacyGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion solidity/test/domains/testbed_sim/SIMDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions solidity/test/shared/atom/Atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 431efac

Please sign in to comment.