Skip to content

Commit

Permalink
Removed more references to OmniLedger from the docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff R. Allen committed Sep 13, 2018
1 parent 6819bcc commit e735438
Show file tree
Hide file tree
Showing 21 changed files with 163 additions and 164 deletions.
2 changes: 1 addition & 1 deletion eventlog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The EventLog (EL) service is for logging events into
Contrary to ordinary event logging services, we offer better security and
auditability. Below are some of the main features that sets us apart.

- Collective witness - a collection of nodes, or conodes, indepdently observe
- Collective witness - a collection of nodes, or conodes, independently observe
the logging of an event. The event will only be accepted if a 2/3-majority
think it is valid, e.g., the timestamp is reasonable, the client is
authorised and so on.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;

/**
* Argument is used in an Instruction. It will end up as the input argument of the OmniLedger smart contract.
* Argument is used in an Instruction. It will end up as the input argument of the smart contract.
*/
public class Argument {
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import java.util.List;

/**
* OmniBlock represents the data stored in a skipblock that is relevant to OmniLedger. This data is split in
* OmniBlock represents the data stored in a skipblock that is relevant to ByzCoin. This data is split in
* two parts:
* - header, which contains hashes of the current state and which is hashed in the block
* - body, which contains the actual data (currently ClientTransactions) and which is not directly hashed in the block
* - body, which contains the actual transactions and which is not directly hashed in the block
*/
public class OmniBlock {
public class Block {
private ByzCoinProto.DataHeader dataHeader;
private DataBody dataBody;

Expand All @@ -25,7 +25,7 @@ public class OmniBlock {
* @param sb skipblock holding data for an OmniBLock.
* @throws CothorityCryptoException
*/
public OmniBlock(SkipBlock sb) throws CothorityCryptoException {
public Block(SkipBlock sb) throws CothorityCryptoException {
try {
// TODO: check that it is actually an OmniBlock by looking at the verifiers
dataHeader = ByzCoinProto.DataHeader.parseFrom(sb.getData());
Expand All @@ -40,7 +40,7 @@ public OmniBlock(SkipBlock sb) throws CothorityCryptoException {
* @param p
* @throws CothorityCryptoException
*/
public OmniBlock(Proof p) throws CothorityCryptoException {
public Block(Proof p) throws CothorityCryptoException {
// TODO: How do we know that the block in the proof legitimately links back to the
// skipchain we think it does?
SkipBlock sb = p.getLatest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ public ByzCoinRPC(Roster r, Darc d, Duration blockInterval) throws CothorityExce
throw new CothorityCommunicationException(e);
}
latest = genesis;
logger.info("Created new OmniLedger: {}", genesis.getId().toString());
logger.info("Created new ByzCoin ledger with ID: {}", genesis.getId().toString());
skipchain = new SkipchainRPC(r, genesis.getId());
config = new Config(blockInterval);
roster = r;
genesisDarc = d;
}

/**
* Constructs an OmniLedgerRPC from known configuration. The constructor will communicate with the service to
* Constructs an ByzCoinRPC from a known configuration. The constructor will communicate with the service to
* populate other fields and perform verification.
*
* @param roster the roster to talk to
Expand Down Expand Up @@ -229,47 +229,44 @@ public Darc getGenesisDarc() {
}

/**
* @return the genesis block of OmniLedger.
* @return the genesis block of the ledger.
*/
public SkipBlock getGenesis() {
return genesis;
}

/**
* @return the roster responsible for OmniLedger.
* @return the roster responsible for the ledger
*/
public Roster getRoster() {
return roster;
}

/**
* Fetches a given block from the skipchain and returns the corresponding OmniBlock that allows direct
* access to all relevant fields for OmniLedger.
* Fetches a given block from the skipchain and returns the corresponding Block.
*
* @param id hash of the skipblock to fetch
* @return an OmniBlock representation of the skipblock
* @return a Block representation of the skipblock
* @throws CothorityCommunicationException if it couldn't contact the nodes
* @throws CothorityCryptoException if the omniblock is invalid
*/
public OmniBlock getOmniBlock(SkipblockId id) throws CothorityCommunicationException, CothorityCryptoException{
public Block getBlock(SkipblockId id) throws CothorityCommunicationException, CothorityCryptoException{
SkipBlock sb = skipchain.getSkipblock(id);
return new OmniBlock(sb);
return new Block(sb);
}

/**
* Fetches the latest block from the Skipchain and returns the corresponding OmniBlock that allows direct
* access to all relevant fields for OmniLedger.
* Fetches the latest block from the Skipchain and returns the corresponding Block.
*
* @return an OmniBlock representation of the skipblock
* @return an Block representation of the skipblock
* @throws CothorityCommunicationException if it couldn't contact the nodes
* @throws CothorityCryptoException if the omniblock is invalid
*/
public OmniBlock getLatestOmniBlock() throws CothorityCommunicationException, CothorityException{
public Block getLatestBlock() throws CothorityCommunicationException, CothorityException{
this.update();
return new OmniBlock(latest);
return new Block(latest);
}


/**
* This should be used with caution. Every time you use this, please open an issue in github and tell us
* why you think you need this. We'll try to fix it then!
Expand All @@ -282,7 +279,7 @@ public SkipchainRPC getSkipchain() {
}

/**
* Static method to request a proof from OmniLedger. This is used in the instantiation method.
* Static method to request a proof from ByzCoin. This is used in the instantiation method.
*
* @param roster where to contact the cothority
* @param skipchainId the id of the underlying skipchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.List;

/**
* ClientTransaction is a set of instructions are will be executed atomically by OmniLedger.
* ClientTransaction is a set of instructions are will be executed atomically by ByzCoin.
*/
public class ClientTransaction {
private List<Instruction> instructions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ByteString toByteString(){
}

/**
* Creates an instance ID of all zeros, which is the place where the OmniLedger
* Creates an instance ID of all zeros, which is the place where the ByzCoin
* config is stored.
*
* @return the zero instance ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.List;

/**
* An instruction is sent and executed by OmniLedger.
* An instruction is sent and executed by ByzCoin.
*/
public class Instruction {
private InstanceId instId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.List;

/**
* DarcInstance represents an instance of a darc on Omniledger. It is self-
* DarcInstance represents an instance of a darc on ByzCoin. It is self-
* sufficient, meaning it has a link to the byzcoin instance it runs on.
* If you evolve the DarcInstance, it will update its internal darc.
*/
Expand All @@ -25,7 +25,7 @@ public class DarcInstance {

private Instance instance;
private Darc darc;
private ByzCoinRPC ol;
private ByzCoinRPC bc;

private final static Logger logger = LoggerFactory.getLogger(DarcInstance.class);

Expand All @@ -35,13 +35,13 @@ public class DarcInstance {
* the current darcInstance. If the instance is not found, or is not of
* contractId "darc", an exception will be thrown.
*
* @param ol is a link to an byzcoin instance that is running
* @param bc is a link to an byzcoin instance that is running
* @param id of the darc-instance to connect to
* @throws CothorityException
*/
public DarcInstance(ByzCoinRPC ol, InstanceId id) throws CothorityException {
this.ol = ol;
Proof p = ol.getProof(id);
public DarcInstance(ByzCoinRPC bc, InstanceId id) throws CothorityException {
this.bc = bc;
Proof p = bc.getProof(id);
instance = new Instance(p);
if (!instance.getContractId().equals(ContractId)) {
logger.error("wrong instance: {}", instance.getContractId());
Expand All @@ -54,12 +54,12 @@ public DarcInstance(ByzCoinRPC ol, InstanceId id) throws CothorityException {
}
}

public DarcInstance(ByzCoinRPC ol, Darc d) throws CothorityException {
this(ol, new InstanceId(d.getBaseId().getId()));
public DarcInstance(ByzCoinRPC bc, Darc d) throws CothorityException {
this(bc, new InstanceId(d.getBaseId().getId()));
}

public void update() throws CothorityException {
instance = new Instance(ol.getProof(instance.getId()));
instance = new Instance(bc.getProof(instance.getId()));
try {
darc = new Darc(instance.getData());
} catch (InvalidProtocolBufferException e) {
Expand Down Expand Up @@ -106,7 +106,7 @@ public Instruction evolveDarcInstruction(Darc newDarc, Signer owner, int pos, in
public void evolveDarc(Darc newDarc, Signer owner) throws CothorityException {
Instruction inst = evolveDarcInstruction(newDarc, owner, 0, 1);
ClientTransaction ct = new ClientTransaction(Arrays.asList(inst));
ol.sendTransaction(ct);
bc.sendTransaction(ct);
}

/**
Expand All @@ -121,14 +121,14 @@ public void evolveDarc(Darc newDarc, Signer owner) throws CothorityException {
public void evolveDarcAndWait(Darc newDarc, Signer owner) throws CothorityException {
evolveDarc(newDarc, owner);
for (int i = 0; i < 10; i++) {
Proof p = ol.getProof(instance.getId());
Proof p = bc.getProof(instance.getId());
Instance inst = new Instance(p);
try {
darc = new Darc(inst.getData());
if (darc.getVersion() == newDarc.getVersion()) {
return;
}
Thread.sleep(ol.getConfig().getBlockInterval().toMillis());
Thread.sleep(bc.getConfig().getBlockInterval().toMillis());
} catch (InvalidProtocolBufferException e) {
continue;
} catch (InterruptedException e) {
Expand Down Expand Up @@ -179,7 +179,7 @@ public Instruction spawnContractInstruction(String contractID, Signer s, List<Ar
public ClientTransactionId spawnContract(String contractID, Signer s, List<Argument> args) throws CothorityException {
Instruction inst = spawnContractInstruction(contractID, s, args, 0, 1);
ClientTransaction ct = new ClientTransaction(Arrays.asList(inst));
return ol.sendTransaction(ct);
return bc.sendTransaction(ct);
}

/**
Expand All @@ -193,7 +193,7 @@ public ClientTransactionId spawnContract(String contractID, Signer s, List<Argum
public Proof spawnContractAndWait(String contractID, Signer s, List<Argument> args, int wait) throws CothorityException {
Instruction inst = spawnContractInstruction(contractID, s, args, 0, 1);
ClientTransaction ct = new ClientTransaction(Arrays.asList(inst));
ol.sendTransactionAndWait(ct, wait);
bc.sendTransactionAndWait(ct, wait);
InstanceId iid = inst.deriveId("");
if (contractID.equals(ContractId)) {
// Special case for a darc, then the resulting instanceId is based
Expand All @@ -206,7 +206,7 @@ public Proof spawnContractAndWait(String contractID, Signer s, List<Argument> ar
}
}
logger.info("waiting on iid {}", iid);
return ol.getProof(iid);
return bc.getProof(iid);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import java.util.List;

/**
* EventLogInstance is for interacting with the eventlog contract on OmniLedger.
* EventLogInstance is for interacting with the eventlog contract on ByzCoin.
* <p>
* Contrary to ordinary event logging services, we offer better security and auditability. Below are some of the main
* features that sets us apart.
* <p>
* <ul>
* <li>
* Collective witness - a collection of nodes, or conodes, indepdently observe the logging of an event. The event
* Collective witness - a collection of nodes, or conodes, independently observe the logging of an event. The event
* will only be accepted if a 2/3-majority think it is valid, e.g., the timestamp is reasonable, the client is
* authorised and so on.
* </li>
Expand All @@ -47,28 +47,27 @@
* </ul>
*/
public class EventLogInstance {
// ContractId is how this contract is represented in OmniLedger;
public static String ContractId = "eventlog";
private Instance instance;
private ByzCoinRPC ol;
private ByzCoinRPC bc;

private final static Logger logger = LoggerFactory.getLogger(EventLogInstance.class);

/**
* Constructor for when do you not know the eventlog instance, use this constructor when constructing for the first
* time. This constructor expects the byzcoin RPC to be initialised with a darc that contains "spawn:eventlog".
* @param ol the byzcoin RPC
* @param bc the byzcoin RPC
* @param signers a list of signers that has the "spawn:eventlog" permission
* @param darcId the darc ID that has the "spawn:eventlog" permission
* @throws CothorityException
*/
public EventLogInstance(ByzCoinRPC ol, List<Signer> signers, DarcId darcId) throws CothorityException {
this.ol = ol;
public EventLogInstance(ByzCoinRPC bc, List<Signer> signers, DarcId darcId) throws CothorityException {
this.bc = bc;
InstanceId id = this.initEventlogInstance(darcId, signers);

// wait for byzcoin to commit the transaction in block
try {
Thread.sleep(5 * ol.getConfig().getBlockInterval().toMillis());
Thread.sleep(5 * bc.getConfig().getBlockInterval().toMillis());
} catch (InterruptedException e) {
throw new CothorityException(e);
}
Expand All @@ -77,12 +76,12 @@ public EventLogInstance(ByzCoinRPC ol, List<Signer> signers, DarcId darcId) thro

/**
* Constructor for when the caller already knows the eventlog instance.
* @param ol the byzcoin RPC
* @param bc the byzcoin RPC
* @param id the instance ID, it must be already initialised and stored on byzcoin
* @throws CothorityException
*/
public EventLogInstance(ByzCoinRPC ol, InstanceId id) throws CothorityException {
this.ol = ol;
public EventLogInstance(ByzCoinRPC bc, InstanceId id) throws CothorityException {
this.bc = bc;
this.setInstance(id);
}

Expand All @@ -97,7 +96,7 @@ public EventLogInstance(ByzCoinRPC ol, InstanceId id) throws CothorityException
*/
public List<InstanceId> log(List<Event> events, DarcId darcId, List<Signer> signers) throws CothorityException {
Pair<ClientTransaction, List<InstanceId>> txAndKeys = makeTx(events, darcId, signers);
ol.sendTransaction(txAndKeys._1);
bc.sendTransaction(txAndKeys._1);
return txAndKeys._2;
}

Expand All @@ -121,7 +120,7 @@ public InstanceId log(Event event, DarcId darcId, List<Signer> signers) throws C
* @throws CothorityException
*/
public Event get(InstanceId key) throws CothorityException {
Proof p = ol.getProof(key);
Proof p = bc.getProof(key);
if (!p.matches()) {
throw new CothorityCryptoException("key does not exist");
}
Expand Down Expand Up @@ -151,15 +150,15 @@ public Event get(InstanceId key) throws CothorityException {
*/
public SearchResponse search(String topic, long from, long to) throws CothorityException {
// Note: this method is a bit different from the others, we directly use the raw sendMessage instead of via
// OmniLedgerRPC.
// ByzCoinRPC.
EventLogProto.SearchRequest.Builder b = EventLogProto.SearchRequest.newBuilder();
b.setInstance(ByteString.copyFrom(this.instance.getId().getId()));
b.setId(this.ol.getGenesis().getId().toProto());
b.setId(this.bc.getGenesis().getId().toProto());
b.setTopic(topic);
b.setFrom(from);
b.setTo(to);

ByteString msg = this.ol.getRoster().sendMessage("EventLog/SearchRequest", b.build());
ByteString msg = this.bc.getRoster().sendMessage("EventLog/SearchRequest", b.build());

try {
EventLogProto.SearchResponse resp = EventLogProto.SearchResponse.parseFrom(msg);
Expand All @@ -186,14 +185,14 @@ private InstanceId initEventlogInstance( DarcId darcId, List<Signer> signers) th
instr.signBy(darcId, signers);

ClientTransaction tx = new ClientTransaction(Arrays.asList(instr));
ol.sendTransaction(tx);
bc.sendTransaction(tx);

return instr.deriveId("");
}


private void setInstance(InstanceId id) throws CothorityException {
Proof p = ol.getProof(id);
Proof p = bc.getProof(id);
Instance inst = new Instance(p);
if (!inst.getContractId().equals(ContractId)) {
logger.error("wrong instance: {}", inst.getContractId());
Expand Down

0 comments on commit e735438

Please sign in to comment.