Remove useless proofs from set function in contract

This commit is contained in:
nolash 2021-11-15 14:46:56 +01:00
parent 732466de27
commit be175dc8d3
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
4 changed files with 79 additions and 45 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,9 @@
confini~=0.5.1
confini~=0.5.2
funga-eth~=0.5.1
chainlib-eth~=0.0.10
chainlib-eth~=0.0.12
eth_erc20~=0.1.2
eth-address-index~=0.2.4
eth-accounts-index~=0.1.2
eth-token-index~=0.2.4
eth-contract-registry~=0.6.3
eth-contract-registry~=0.7.1a2
cic-contracts~=0.0.5

View File

@ -49,7 +49,7 @@ class TestContractRegistry(TestAddressDeclaratorBase):
bogus_hash_two = bytearray(32)
bogus_hash_two[0] = 0x01
bogus_hash_two_hex = add_0x(bogus_hash_two.hex())
(tx_hash_hex, o) = c.set(self.registry_address, self.accounts[0], 'FOO', self.registry_address, str(self.chain_spec), bogus_hash_two_hex)
(tx_hash_hex, o) = c.set(self.registry_address, self.accounts[0], 'FOO', self.registry_address)
r = self.rpc.do(o)
o = receipt(r)
rcpt = self.rpc.do(o)
@ -75,18 +75,18 @@ class TestContractRegistry(TestAddressDeclaratorBase):
h = hashlib.sha256()
h.update(str(self.chain_spec).encode('utf-8'))
chain_description_hash = h.digest()
h = hashlib.sha256()
h.update(z)
h.update(chain_description_hash)
z = h.digest()
self.assertEqual(z.hex(), proofs[1])
h = hashlib.sha256()
h.update(z)
h.update(bogus_hash_two)
z = h.digest()
self.assertEqual(z.hex(), proofs[2])
#
# h = hashlib.sha256()
# h.update(z)
# h.update(chain_description_hash)
# z = h.digest()
# self.assertEqual(z.hex(), proofs[1])
#
# h = hashlib.sha256()
# h.update(z)
# h.update(bogus_hash_two)
# z = h.digest()
# self.assertEqual(z.hex(), proofs[2])

View File

@ -24,7 +24,7 @@ contract ContractRegistryAddressDeclarator {
addressDeclarator = _addressDeclarator;
}
function set(bytes32 _identifier, address _address, bytes32 _chainDescriptor, bytes32 _chainConfig) public returns (bool) {
function set(bytes32 _identifier, address _address) public returns (bool) { //, bytes32 _chainDescriptor, bytes32 _chainConfig) public returns (bool) {
require(msg.sender == owner);
require(entries[_identifier] == address(0));
@ -51,38 +51,72 @@ contract ContractRegistryAddressDeclarator {
require(ok);
require(r[31] == 0x01);
buf = new bytes(64);
for (i = 0; i < 32; i++) {
buf[i] = identifierHash[i];
}
for (i = 0; i < 32; i++) {
buf[i+32] = _chainDescriptor[i];
}
identifierHash = sha256(buf);
(ok, r) = addressDeclarator.call(abi.encodeWithSignature("addDeclaration(address,bytes32)", _address, identifierHash));
require(ok);
require(r[31] == 0x01);
for (i = 0; i < 32; i++) {
buf[i] = identifierHash[i];
}
for (i = 0; i < 32; i++) {
buf[i+32] = _chainConfig[i];
}
identifierHash = sha256(buf);
(ok, r) = addressDeclarator.call(abi.encodeWithSignature("addDeclaration(address,bytes32)", _address, identifierHash));
require(ok);
require(r[31] == 0x01);
entries[_identifier] = _address;
chainIdentifiers[_identifier] = _chainDescriptor;
chainConfigs[_chainDescriptor] = _chainConfig;
///chainIdentifiers[_identifier] = _chainDescriptor;
//chainConfigs[_chainDescriptor] = _chainConfig;
return true;
}
// function set(bytes32 _identifier, address _address, bytes32 _chainDescriptor, bytes32 _chainConfig) public returns (bool) {
// require(msg.sender == owner);
// require(entries[_identifier] == address(0));
//
// bool ok;
// bytes memory r;
// bool found = false;
// bytes32 identifierHash;
// bytes memory buf;
// uint8 i;
//
// for (i = 0; i < identifiers.length; i++) {
// if (identifiers[i] == _identifier) {
// found = true;
// }
// }
// require(found, 'ERR_IDENTIFIER');
//
// buf = new bytes(32);
// for (i = 0; i < 32; i++) {
// buf[i] = _identifier[i];
// }
// identifierHash = sha256(buf);
// (ok, r) = addressDeclarator.call(abi.encodeWithSignature("addDeclaration(address,bytes32)", _address, identifierHash));
// require(ok);
// require(r[31] == 0x01);
//
// buf = new bytes(64);
// for (i = 0; i < 32; i++) {
// buf[i] = identifierHash[i];
// }
// for (i = 0; i < 32; i++) {
// buf[i+32] = _chainDescriptor[i];
// }
//
// identifierHash = sha256(buf);
// (ok, r) = addressDeclarator.call(abi.encodeWithSignature("addDeclaration(address,bytes32)", _address, identifierHash));
// require(ok);
// require(r[31] == 0x01);
//
//
// for (i = 0; i < 32; i++) {
// buf[i] = identifierHash[i];
// }
// for (i = 0; i < 32; i++) {
// buf[i+32] = _chainConfig[i];
// }
// identifierHash = sha256(buf);
// (ok, r) = addressDeclarator.call(abi.encodeWithSignature("addDeclaration(address,bytes32)", _address, identifierHash));
// require(ok);
// require(r[31] == 0x01);
//
// entries[_identifier] = _address;
// chainIdentifiers[_identifier] = _chainDescriptor;
// chainConfigs[_chainDescriptor] = _chainConfig;
//
// return true;
// }
//
// Implements EIP 173
function transferOwnership(address _newOwner) public returns (bool) {
require(msg.sender == owner);