-
Notifications
You must be signed in to change notification settings - Fork 19.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e94f76
commit 3f18431
Showing
79 changed files
with
2,713 additions
and
808 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
# Building Quorum | ||
|
||
Clone the repository and build the source: | ||
|
||
``` | ||
git clone https://github.com/jpmorganchase/quorum.git | ||
cd quorum | ||
make all | ||
make test | ||
``` | ||
|
||
Binaries are placed within `./build/bin`, most notably `geth` and `bootnode`. Either add this directory to your `$PATH` or copy those two bins into your PATH: | ||
|
||
```sh | ||
# assumes that /usr/local/bin is in your PATH | ||
cp ./build/bin/geth ./build/bin/bootnode /usr/local/bin/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Hacking on Quorum / various notes | ||
|
||
## Testing with Constellation | ||
|
||
### `tm.conf` | ||
|
||
Replace with appropriate absolute paths: | ||
|
||
TODO(joel): figure out how to use relative paths | ||
|
||
``` | ||
url = "http://127.0.0.1:9000/" | ||
port = 9000 | ||
socket = "/Users/joel/go/src/github.com/ethereum/go-ethereum/qdata/tm.ipc" | ||
othernodes = [] | ||
storage = "/Users/joel/go/src/github.com/ethereum/go-ethereum/qdata/constellation" | ||
publickeys = ["/Users/joel/go/src/github.com/ethereum/go-ethereum/qdata/test.pub"] | ||
privatekeys = ["/Users/joel/go/src/github.com/ethereum/go-ethereum/qdata/test.key"] | ||
``` | ||
|
||
Run constellation: | ||
|
||
``` | ||
> mkdir qdata | ||
> constellation-node tm.conf | ||
``` | ||
|
||
Now you should be able to run the private state tests as well: `env PRIVATE_CONFIG=(pwd)/tm.conf go test ./...`. | ||
|
||
## How does private state work? | ||
|
||
Let's look at the EVM structure: | ||
|
||
```go | ||
type EVM struct { | ||
... | ||
// StateDB gives access to the underlying state | ||
StateDB StateDB | ||
// Depth is the current call stack | ||
depth int | ||
... | ||
|
||
publicState PublicState | ||
privateState PrivateState | ||
states [1027]*state.StateDB | ||
currentStateDepth uint | ||
readOnly bool | ||
readOnlyDepth uint | ||
} | ||
``` | ||
|
||
The vanilla EVM has a call depth limit of 1024. Our `states` parallel the EVM call stack, recording as contracts in the public and private state call back and forth to each other. Note it doesn't have to be a "public -> private -> public -> private" back-and-forth chain. It can be any sequence of { public, private }. | ||
|
||
The interface for calling is this `Push` / `Pop` sequence: | ||
|
||
```go | ||
evm.Push(getDualState(evm, addr)) | ||
defer func() { evm.Pop() }() | ||
// ... do work in the pushed state | ||
``` | ||
|
||
The definitions of `Push` and `Pop` are simple and important enough to duplicate here: | ||
|
||
```go | ||
func (env *EVM) Push(statedb StateDB) { | ||
if env.privateState != statedb { | ||
env.readOnly = true | ||
env.readOnlyDepth = env.currentStateDepth | ||
} | ||
|
||
if castedStateDb, ok := statedb.(*state.StateDB); ok { | ||
env.states[env.currentStateDepth] = castedStateDb | ||
env.currentStateDepth++ | ||
} | ||
|
||
env.StateDB = statedb | ||
} | ||
func (env *EVM) Pop() { | ||
env.currentStateDepth-- | ||
if env.readOnly && env.currentStateDepth == env.readOnlyDepth { | ||
env.readOnly = false | ||
} | ||
env.StateDB = env.states[env.currentStateDepth-1] | ||
} | ||
``` | ||
|
||
Note the invariant that `StateDB` always points to the current state db. | ||
|
||
The other interesting note is read only mode. Any time we call from the private state into the public state (`env.privateState != statedb`), we require anything deeper to be *read only*. Private state transactions can't affect public state, so we throw an EVM exception on any mutating operation (`SELFDESTRUCT, CREATE, SSTORE, LOG0, LOG1, LOG2, LOG3, LOG4`). Question: have any more mutating operations been added? Question: could we not mutate deeper private state? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.