Skip to content

Commit

Permalink
Merge branch 'master' into dataposter-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Jul 28, 2023
2 parents 14cb1da + 22af898 commit 0df4e76
Show file tree
Hide file tree
Showing 17 changed files with 218 additions and 78 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/arbitrator-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-8
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v3
with:
submodules: recursive

Expand All @@ -36,12 +36,12 @@ jobs:
sudo ln -s /usr/bin/wasm-ld-14 /usr/local/bin/wasm-ld
- name: Install go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.20.x

- name: Setup nodejs
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:

- name: Setup emsdk
if: steps.cache-cbrotli.outputs.cache-hit != 'true'
uses: mymindstorm/setup-emsdk@v11
uses: mymindstorm/setup-emsdk@v12
with:
# Make sure to set a version number!
version: 3.1.6
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- name: Install dependencies
run: sudo apt update && sudo apt install -y wabt gotestsum

- name: Setup nodejs
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.20.x

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ jobs:
config-file: ./.github/codeql/codeql-config.yml

- name: Setup nodejs
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.20.x

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: recursive

Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
# We work around this by piping a tarball through stdout
docker run --rm --entrypoint tar localhost:5000/nitro-node-dev:latest -cf - target/machines/latest | tar xf -
module_root="$(cat "target/machines/latest/module-root.txt")"
echo "::set-output name=module-root::$module_root"
echo "name=module-root=$module_root" >> $GITHUB_STATE
echo -e "\x1b[1;34mWAVM module root:\x1b[0m $module_root"
- name: Upload WAVM machine as artifact
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# have to update an existing file. So - for docker, convert all dependencies
# to order-only dependencies (timestamps ignored).
# WARNING: when using this trick, you cannot use the $< automatic variable

ifeq ($(origin NITRO_BUILD_IGNORE_TIMESTAMPS),undefined)
DEP_PREDICATE:=
ORDER_ONLY_PREDICATE:=|
Expand Down
6 changes: 3 additions & 3 deletions arbitrator/jit/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ pub fn wasm_write(mut env: WasmEnvMut, sp: u32) {
}

pub fn nanotime1(mut env: WasmEnvMut, sp: u32) {
let (sp, mut env) = GoStack::new(sp, &mut env);
let (sp, env) = GoStack::new(sp, &mut env);
env.go_state.time += env.go_state.time_interval;
sp.write_u64(0, env.go_state.time);
}

pub fn walltime(mut env: WasmEnvMut, sp: u32) {
let (sp, mut env) = GoStack::new(sp, &mut env);
let (sp, env) = GoStack::new(sp, &mut env);
env.go_state.time += env.go_state.time_interval;
sp.write_u64(0, env.go_state.time / 1_000_000_000);
sp.write_u32(1, (env.go_state.time % 1_000_000_000) as u32);
}

pub fn walltime1(mut env: WasmEnvMut, sp: u32) {
let (sp, mut env) = GoStack::new(sp, &mut env);
let (sp, env) = GoStack::new(sp, &mut env);
env.go_state.time += env.go_state.time_interval;
sp.write_u64(0, env.go_state.time / 1_000_000_000);
sp.write_u64(1, env.go_state.time % 1_000_000_000);
Expand Down
5 changes: 4 additions & 1 deletion arbitrator/wasm-libraries/go-stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,10 @@ pub unsafe extern "C" fn wavm__go_after_run() {
while let Some(info) = state.times.pop() {
while state.pending_ids.contains(&info.id) {
TIME = std::cmp::max(TIME, info.time);
drop(state);
// Important: the current reference to state shouldn't be used after this resume call,
// as it might during the resume call the reference might be invalidated.
// That's why immediately after this resume call, we replace the reference
// with a new reference to TIMEOUT_STATE.
wavm_guest_call__resume();
state = TIMEOUT_STATE.get_or_insert_with(Default::default);
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/chaininfo/arbitrum_chain_info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[
{
"chain-id": 42161,
"chain-name": "arb1",
"parent-chain-id": 1,
"sequencer-url": "https://arb1-sequencer.arbitrum.io/rpc",
Expand Down Expand Up @@ -50,7 +49,6 @@
}
},
{
"chain-id": 42170,
"chain-name": "nova",
"parent-chain-id": 1,
"sequencer-url": "https://nova.arbitrum.io/rpc",
Expand Down Expand Up @@ -100,7 +98,6 @@
}
},
{
"chain-id": 421613,
"chain-name": "goerli-rollup",
"parent-chain-id": 5,
"sequencer-url": "https://goerli-rollup.arbitrum.io/rpc",
Expand Down Expand Up @@ -149,7 +146,6 @@
}
},
{
"chain-id": 412346,
"chain-name": "arb-dev-test",
"chain-config":
{
Expand Down Expand Up @@ -185,7 +181,6 @@
}
},
{
"chain-id": 412347,
"chain-name": "anytrust-dev-test",
"chain-config":
{
Expand Down
3 changes: 1 addition & 2 deletions cmd/chaininfo/chain_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
var DefaultChainInfo []byte

type ChainInfo struct {
ChainId uint64 `json:"chain-id"`
ChainName string `json:"chain-name"`
ParentChainId uint64 `json:"parent-chain-id"`
// This is the forwarding target to submit transactions to, called the sequencer URL for clarity
Expand Down Expand Up @@ -94,7 +93,7 @@ func findChainInfo(chainId uint64, chainName string, chainsInfoBytes []byte) (*C
return nil, err
}
for _, chainInfo := range chainsInfo {
if (chainId == 0 || chainInfo.ChainId == chainId) && (chainName == "" || chainInfo.ChainName == chainName) {
if (chainId == 0 || chainInfo.ChainConfig.ChainID.Uint64() == chainId) && (chainName == "" || chainInfo.ChainName == chainName) {
return &chainInfo, nil
}
}
Expand Down
70 changes: 69 additions & 1 deletion cmd/datool/datool.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"strings"
"time"

koanfjson "github.com/knadh/koanf/parsers/json"
flag "github.com/spf13/pflag"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -34,7 +35,7 @@ import (
func main() {
args := os.Args
if len(args) < 2 {
panic("Usage: datool [client|keygen|generatehash] ...")
panic("Usage: datool [client|keygen|generatehash|dumpkeyset] ...")
}

var err error
Expand All @@ -45,6 +46,8 @@ func main() {
err = startKeyGen(args[2:])
case "generatehash":
err = generateHash(args[2])
case "dumpkeyset":
err = dumpKeyset(args[2:])
default:
panic(fmt.Sprintf("Unknown tool '%s' specified, valid tools are 'client', 'keygen', 'generatehash'", args[1]))
}
Expand Down Expand Up @@ -313,3 +316,68 @@ func generateHash(message string) error {
fmt.Printf("Hex Encoded Data Hash: %s\n", hexutil.Encode(dastree.HashBytes([]byte(message))))
return nil
}

func parseDumpKeyset(args []string) (*DumpKeysetConfig, error) {
f := flag.NewFlagSet("dump keyset", flag.ContinueOnError)

das.AggregatorConfigAddOptions("keyset", f)
genericconf.ConfConfigAddOptions("conf", f)

k, err := confighelpers.BeginCommonParse(f, args)
if err != nil {
return nil, err
}

var config DumpKeysetConfig
if err := confighelpers.EndCommonParse(k, &config); err != nil {
return nil, err
}

if config.ConfConfig.Dump {
c, err := k.Marshal(koanfjson.Parser())
if err != nil {
return nil, fmt.Errorf("unable to marshal config file to JSON: %w", err)
}

fmt.Println(string(c))
os.Exit(0)
}

if config.KeysetConfig.AssumedHonest == 0 {
return nil, errors.New("--keyset.assumed-honest must be set")
}
if config.KeysetConfig.Backends == "" {
return nil, errors.New("--keyset.backends must be set")
}

return &config, nil
}

// das keygen

type DumpKeysetConfig struct {
KeysetConfig das.AggregatorConfig `koanf:"keyset"`
ConfConfig genericconf.ConfConfig `koanf:"conf"`
}

func dumpKeyset(args []string) error {
config, err := parseDumpKeyset(args)
if err != nil {
return err
}

services, err := das.ParseServices(config.KeysetConfig)
if err != nil {
return err
}

keysetHash, keysetBytes, err := das.KeysetHashFromServices(services, uint64(config.KeysetConfig.AssumedHonest))
if err != nil {
return err
}

fmt.Printf("Keyset: %s\n", hexutil.Encode(keysetBytes))
fmt.Printf("KeysetHash: %s\n", hexutil.Encode(keysetHash[:]))

return err
}
1 change: 0 additions & 1 deletion cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ func main() {
}
chainsInfo := []chaininfo.ChainInfo{
{
ChainId: chainConfig.ChainID.Uint64(),
ChainName: *l2ChainName,
ParentChainId: l1ChainId.Uint64(),
ChainConfig: &chainConfig,
Expand Down
19 changes: 13 additions & 6 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,20 +374,26 @@ func mainImpl() int {
return 1
}

var deferFuncs []func()
defer func() {
for i := range deferFuncs {
deferFuncs[i]()
}
}()

chainDb, l2BlockChain, err := openInitializeChainDb(ctx, stack, nodeConfig, new(big.Int).SetUint64(nodeConfig.L2.ChainID), execution.DefaultCacheConfigFor(stack, &nodeConfig.Node.Caching), l1Client, rollupAddrs)
defer closeDb(chainDb, "chainDb")
if l2BlockChain != nil {
// Calling Stop on the blockchain multiple times does nothing
defer l2BlockChain.Stop()
deferFuncs = append(deferFuncs, func() { l2BlockChain.Stop() })
}
deferFuncs = append(deferFuncs, func() { closeDb(chainDb, "chainDb") })
if err != nil {
flag.Usage()
log.Error("error initializing database", "err", err)
return 1
}

arbDb, err := stack.OpenDatabase("arbitrumdata", 0, 0, "", false)
defer closeDb(arbDb, "arbDb")
deferFuncs = append(deferFuncs, func() { closeDb(arbDb, "arbDb") })
if err != nil {
log.Error("failed to open database", "err", err)
return 1
Expand Down Expand Up @@ -479,7 +485,8 @@ func mainImpl() int {
if err != nil {
fatalErrChan <- fmt.Errorf("error starting node: %w", err)
}
defer currentNode.StopAndWait()
// remove previous deferFuncs, StopAndWait closes database and blockchain.
deferFuncs = []func(){func() { currentNode.StopAndWait() }}
}

sigint := make(chan os.Signal, 1)
Expand Down Expand Up @@ -731,7 +738,7 @@ func applyChainParameters(ctx context.Context, k *koanf.Koanf, chainId uint64, c
}
chainDefaults := map[string]interface{}{
"persistent.chain": chainInfo.ChainName,
"chain.id": chainInfo.ChainId,
"chain.id": chainInfo.ChainConfig.ChainID.Uint64(),
"parent-chain.id": chainInfo.ParentChainId,
}
if chainInfo.SequencerUrl != "" {
Expand Down
Loading

0 comments on commit 0df4e76

Please sign in to comment.