Skip to content

Commit

Permalink
Merge pull request #366 from OffchainLabs/bug-fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
hkalodner authored Jun 9, 2020
2 parents c2b9b13 + b9dc24b commit a9724a6
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 47 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"docker:build:geth": "yarn workspace arb-bridge-eth docker:build:geth",
"docker:parity": "yarn workspace arb-bridge-eth docker:parity",
"docker:ganache": "yarn workspace arb-bridge-eth docker:ganache",
"docker:geth": "yarn workspace arb-bridge-eth docker:geth"
"docker:geth": "yarn workspace arb-bridge-eth docker:geth",
"prepare": "yarn workspace arb-provider-ethers prepare"
},
"engines": {
"node": ">= 8.0.0 < 13.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-avm-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ project (arb-avm-cpp)

set(AVM_VERSION_MAJOR 0)
set(AVM_VERSION_MINOR 6)
set(AVM_VERSION_PATCH 0)
set(AVM_VERSION_PATCH 4)

set(AVM_VERSION_STRING ${AVM_VERSION_MAJOR}.${AVM_VERSION_MINOR}.${AVM_VERSION_PATCH})

Expand Down
2 changes: 1 addition & 1 deletion packages/arb-avm-cpp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module github.com/offchainlabs/arbitrum/packages/arb-avm-cpp

go 1.12

require github.com/offchainlabs/arbitrum/packages/arb-util v0.6.0
require github.com/offchainlabs/arbitrum/packages/arb-util v0.6.4

replace github.com/offchainlabs/arbitrum/packages/arb-util => ../arb-util
2 changes: 1 addition & 1 deletion packages/arb-avm-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.12
require (
github.com/dgraph-io/badger v1.6.1
github.com/ethereum/go-ethereum v1.9.13
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.4
)

replace github.com/offchainlabs/arbitrum/packages/arb-util => ../arb-util
4 changes: 2 additions & 2 deletions packages/arb-bridge-eth/geth.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

FROM ethereum/client-go:stable

RUN apk add --no-cache nodejs npm && \
RUN apk add --no-cache nodejs npm git && \
addgroup -g 1000 -S user && \
adduser -u 1000 -S user -G user -s /bin/ash -h /home/user
USER user
Expand All @@ -17,7 +17,7 @@ RUN mkdir -p /home/user/.npm-global && \
npm config set prefix "/home/user/.npm-global" && \
npm install -g [email protected] [email protected]
COPY package.json ./
RUN yarn --production --frozen-lockfile --non-interactive
RUN yarn --frozen-lockfile --non-interactive
COPY contracts ./contracts
COPY migrations ./migrations
COPY test ./test
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-bridge-eth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arb-bridge-eth",
"private": true,
"version": "0.6.0",
"version": "0.6.4",
"description": "",
"author": "Offchain Labs, Inc.",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-compiler-evm/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="arb-compiler-evm",
version="0.5.0",
version="0.6.4",
description="Compiler from solidity to AVM bytecode",
url="https://offchainlabs.com",
author="Offchain Labs, Inc.",
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-provider-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arb-provider-ethers",
"version": "0.6.2",
"version": "0.6.4",
"description": "Arbitrum provider for ethers",
"author": "Offchain Labs, Inc.",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-provider-ethers/src/lib/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class ArbProvider extends ethers.providers.BaseProvider {
const txHashCheck = evmVal.message.txHash

// Check txHashCheck matches txHash
if (txHash !== txHashCheck) {
if (arbTxHash !== txHashCheck) {
throw Error(
'txHash did not match its queried transaction ' +
arbTxHash +
Expand Down
4 changes: 2 additions & 2 deletions packages/arb-provider-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.12
require (
github.com/ethereum/go-ethereum v1.9.13
github.com/gorilla/rpc v1.2.0
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-validator-core v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.4
github.com/offchainlabs/arbitrum/packages/arb-validator-core v0.6.4
)

replace github.com/offchainlabs/arbitrum/packages/arb-validator-core => ../arb-validator-core
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-provider-truffle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arb-provider-truffle",
"version": "0.6.0",
"version": "0.6.4",
"description": "Arbitrum provider for truffle",
"author": "Offchain Labs, Inc.",
"license": "Apache-2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/arb-provider-web3/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arb-provider-web3",
"version": "0.6.3",
"version": "0.6.4",
"description": "Arbitrum provider for web3",
"author": "Offchain Labs, Inc.",
"license": "Apache-2.0",
Expand All @@ -20,7 +20,7 @@
},
"homepage": "https://offchainlabs.com",
"dependencies": {
"arb-provider-ethers": "0.6.2",
"arb-provider-ethers": "0.6.4",
"ethers": "^4.0.44",
"ethers-providers": "^2.1.19",
"ethers-utils": "^2.1.11"
Expand Down
4 changes: 2 additions & 2 deletions packages/arb-tx-aggregator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require (
github.com/golang/protobuf v1.4.2
github.com/gorilla/rpc v1.2.0
github.com/kr/pretty v0.2.0 // indirect
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-validator-core v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.4
github.com/offchainlabs/arbitrum/packages/arb-validator-core v0.6.4
github.com/pkg/errors v0.9.1
google.golang.org/protobuf v1.24.0
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
Expand Down
3 changes: 2 additions & 1 deletion packages/arb-validator-core/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ require (
github.com/golang/protobuf v1.4.2
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.4
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.4
github.com/pkg/errors v0.9.1
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4
golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4
google.golang.org/protobuf v1.24.0
)
Expand Down
51 changes: 33 additions & 18 deletions packages/arb-validator-core/message/transactionBatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/offchainlabs/arbitrum/packages/arb-util/value"
"log"
"math/big"
Expand Down Expand Up @@ -64,10 +65,18 @@ type BatchTx struct {
Sig [65]byte
}

func (b BatchTx) Equals(o BatchTx) bool {
return b.To == o.To &&
b.SeqNum.Cmp(o.SeqNum) == 0 &&
b.Value.Cmp(o.Value) == 0 &&
bytes.Equal(b.Data, o.Data) &&
b.Sig == o.Sig
}

func NewBatchTxFromData(data []byte, offset int) (BatchTx, error) {
dataLength := int(binary.BigEndian.Uint16(data[offset : offset+2]))
if offset+DataOffset+dataLength < len(data) {
return BatchTx{}, errors.New("not enough data remaining")
if offset+DataOffset+dataLength > len(data) {
return BatchTx{}, fmt.Errorf("not enough data remaining (offset: %v, DataOffset: %v, dataLength: %v, totalLength: %v)", offset, DataOffset, dataLength, len(data))
}
offset += 2
toRaw := data[offset : offset+20]
Expand Down Expand Up @@ -121,26 +130,34 @@ func (b BatchTx) ToBytes() []byte {

var DataOffset = 151

func (m TransactionBatch) getTransactions() []Transaction {
txes := make([]Transaction, 0)
func (m TransactionBatch) getBatchTransactions() []BatchTx {
txes := make([]BatchTx, 0)
offset := 0

data := m.TxData
for offset+DataOffset < len(data) {
batch, err := NewBatchTxFromData(data, offset)
if err != nil {
log.Println("Transaction batch", hexutil.Encode(data), "at offset", offset, "included invalid tx", err)
break
}
txes = append(txes, batch)
offset += batch.encodedLength()
}
return txes
}

func (m TransactionBatch) getTransactions() []Transaction {
txes := make([]Transaction, 0)
for _, tx := range m.getBatchTransactions() {
batchTxHash := BatchTxHash(
m.Chain,
batch.To,
batch.SeqNum,
batch.Value,
batch.Data,
tx.To,
tx.SeqNum,
tx.Value,
tx.Data,
)
messageHash := hashing.SoliditySHA3WithPrefix(batchTxHash[:])
pubkey, err := crypto.SigToPub(messageHash.Bytes(), batch.Sig[:])
pubkey, err := crypto.SigToPub(messageHash.Bytes(), tx.Sig[:])
if err != nil {
// TODO: Is this possible? If so we need to handle it
// What are the possible failure conditions and how do they relate
Expand All @@ -149,17 +166,15 @@ func (m TransactionBatch) getTransactions() []Transaction {
}

from := common.NewAddressFromEth(crypto.PubkeyToAddress(*pubkey))
tx := Transaction{
fullTx := Transaction{
Chain: m.Chain,
To: batch.To,
To: tx.To,
From: from,
SequenceNum: batch.SeqNum,
Value: batch.Value,
Data: batch.Data,
SequenceNum: tx.SeqNum,
Value: tx.Value,
Data: tx.Data,
}

txes = append(txes, tx)
offset += batch.encodedLength()
txes = append(txes, fullTx)
}
return txes
}
Expand Down
51 changes: 49 additions & 2 deletions packages/arb-validator-core/message/transactionBatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/offchainlabs/arbitrum/packages/arb-util/common"
)

func generateTestBatch() TransactionBatch {
func generateBatchTx() BatchTx {
addr1 := common.Address{}
addr1[0] = 76
addr1[19] = 93
Expand All @@ -32,20 +32,41 @@ func generateTestBatch() TransactionBatch {
addr2[0] = 43
addr2[19] = 12

tx := BatchTx{
return BatchTx{
To: addr2,
SeqNum: big.NewInt(2),
Value: big.NewInt(43423),
Data: []byte{54, 87, 23},
Sig: [65]byte{87, 42, 56, 98},
}

}

func generateTestBatch() TransactionBatch {
addr1 := common.Address{}
addr1[0] = 76
addr1[19] = 93

tx := generateBatchTx()
return TransactionBatch{
Chain: addr1,
TxData: tx.ToBytes(),
}
}

func TestMarshalBatch(t *testing.T) {
tx := generateBatchTx()
data := tx.ToBytes()
tx2, err := NewBatchTxFromData(data, 0)
if err != nil {
t.Error(err)
}

if !tx.Equals(tx2) {
t.Error("unmarshaled tx not equal")
}
}

func TestCheckpointBatch(t *testing.T) {
msg := generateTestBatch()

Expand All @@ -58,3 +79,29 @@ func TestCheckpointBatch(t *testing.T) {
t.Error("Unmarshalling didn't reverse marshalling", msg, msg2)
}
}

func TestGetTransactions(t *testing.T) {
addr1 := common.Address{}
addr1[0] = 76
addr1[19] = 93

tx1 := generateBatchTx()
tx2 := generateBatchTx()
batch := TransactionBatch{
Chain: addr1,
TxData: append(tx1.ToBytes(), tx2.ToBytes()...),
}

txes := batch.getBatchTransactions()
if len(txes) != 2 {
t.Fatal("didn't get back 2 txes")
}

if !txes[0].Equals(tx1) {
t.Error("unmarshaled tx not equal")
}

if !txes[1].Equals(tx2) {
t.Error("unmarshaled tx not equal")
}
}
2 changes: 1 addition & 1 deletion packages/arb-validator.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ COPY --chown=user arb-validator-core/go.* /home/user/arb-validator-core/
RUN go mod download
# Copy source code
COPY --from=arb-avm-cpp /home/user/go.mod /home/user/go.sum /home/user/arb-avm-cpp/
COPY --from=arb-avm-cpp /home/user/cavm/cmachine.h /home/user/cavm/ccheckpointstorage.h /home/user/arb-avm-cpp/cavm/
COPY --from=arb-avm-cpp /home/user/cavm/*.h /home/user/arb-avm-cpp/cavm/
COPY --from=arb-avm-cpp /home/user/cmachine /home/user/arb-avm-cpp/cmachine/
COPY --chown=user arb-avm-go/ /home/user/arb-avm-go/
COPY --chown=user arb-util/ /home/user/arb-util/
Expand Down
8 changes: 4 additions & 4 deletions packages/arb-validator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ require (
github.com/golang/protobuf v1.4.2
github.com/gorilla/rpc v1.2.0
github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad
github.com/offchainlabs/arbitrum/packages/arb-avm-cpp v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-avm-go v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-validator-core v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-avm-cpp v0.6.4
github.com/offchainlabs/arbitrum/packages/arb-avm-go v0.6.4
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.4
github.com/offchainlabs/arbitrum/packages/arb-validator-core v0.6.4
github.com/pkg/errors v0.9.1
google.golang.org/protobuf v1.24.0
)
Expand Down
8 changes: 4 additions & 4 deletions tests/fibgo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ go 1.13
require (
github.com/ethereum/go-ethereum v1.9.13
github.com/gorilla/rpc v1.2.0
github.com/offchainlabs/arbitrum/packages/arb-provider-go v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-validator v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-validator-core v0.6.0
github.com/offchainlabs/arbitrum/packages/arb-provider-go v0.6.4
github.com/offchainlabs/arbitrum/packages/arb-util v0.6.4
github.com/offchainlabs/arbitrum/packages/arb-validator v0.6.4
github.com/offchainlabs/arbitrum/packages/arb-validator-core v0.6.4
)

replace github.com/offchainlabs/arbitrum/packages/arb-provider-go => ../../packages/arb-provider-go
Expand Down

0 comments on commit a9724a6

Please sign in to comment.