diff --git a/package.json b/package.json index 9306da6c55..e6e29f43d7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/arb-avm-cpp/CMakeLists.txt b/packages/arb-avm-cpp/CMakeLists.txt index 33a0505a2c..e6226638e0 100644 --- a/packages/arb-avm-cpp/CMakeLists.txt +++ b/packages/arb-avm-cpp/CMakeLists.txt @@ -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}) diff --git a/packages/arb-avm-cpp/go.mod b/packages/arb-avm-cpp/go.mod index 49ae6cdfeb..a1f7d9a6f3 100644 --- a/packages/arb-avm-cpp/go.mod +++ b/packages/arb-avm-cpp/go.mod @@ -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 diff --git a/packages/arb-avm-go/go.mod b/packages/arb-avm-go/go.mod index d8c4dfd89d..b2c34edd31 100644 --- a/packages/arb-avm-go/go.mod +++ b/packages/arb-avm-go/go.mod @@ -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 diff --git a/packages/arb-bridge-eth/geth.Dockerfile b/packages/arb-bridge-eth/geth.Dockerfile index 317e3ae4f0..5487f836cd 100644 --- a/packages/arb-bridge-eth/geth.Dockerfile +++ b/packages/arb-bridge-eth/geth.Dockerfile @@ -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 @@ -17,7 +17,7 @@ RUN mkdir -p /home/user/.npm-global && \ npm config set prefix "/home/user/.npm-global" && \ npm install -g truffle@5.0.30 yarn@1.17.3 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 diff --git a/packages/arb-bridge-eth/package.json b/packages/arb-bridge-eth/package.json index 35a8371ef6..1887ecfd27 100644 --- a/packages/arb-bridge-eth/package.json +++ b/packages/arb-bridge-eth/package.json @@ -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", diff --git a/packages/arb-compiler-evm/setup.py b/packages/arb-compiler-evm/setup.py index b1ca9aaa45..f2be3836ee 100644 --- a/packages/arb-compiler-evm/setup.py +++ b/packages/arb-compiler-evm/setup.py @@ -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.", diff --git a/packages/arb-provider-ethers/package.json b/packages/arb-provider-ethers/package.json index 9bb5b11eab..5d9fd50608 100644 --- a/packages/arb-provider-ethers/package.json +++ b/packages/arb-provider-ethers/package.json @@ -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", diff --git a/packages/arb-provider-ethers/src/lib/provider.ts b/packages/arb-provider-ethers/src/lib/provider.ts index e586497418..85f892dcdb 100644 --- a/packages/arb-provider-ethers/src/lib/provider.ts +++ b/packages/arb-provider-ethers/src/lib/provider.ts @@ -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 + diff --git a/packages/arb-provider-go/go.mod b/packages/arb-provider-go/go.mod index ab81593034..7ed1d7867d 100644 --- a/packages/arb-provider-go/go.mod +++ b/packages/arb-provider-go/go.mod @@ -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 diff --git a/packages/arb-provider-truffle/package.json b/packages/arb-provider-truffle/package.json index 081c2e7d98..5813a14877 100644 --- a/packages/arb-provider-truffle/package.json +++ b/packages/arb-provider-truffle/package.json @@ -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", diff --git a/packages/arb-provider-web3/package.json b/packages/arb-provider-web3/package.json index 80b0f88a48..0d40ccda10 100644 --- a/packages/arb-provider-web3/package.json +++ b/packages/arb-provider-web3/package.json @@ -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", @@ -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" diff --git a/packages/arb-tx-aggregator/go.mod b/packages/arb-tx-aggregator/go.mod index 505fd185ef..742d3beb64 100644 --- a/packages/arb-tx-aggregator/go.mod +++ b/packages/arb-tx-aggregator/go.mod @@ -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 diff --git a/packages/arb-validator-core/go.mod b/packages/arb-validator-core/go.mod index 49dad0b94c..528aa458fa 100644 --- a/packages/arb-validator-core/go.mod +++ b/packages/arb-validator-core/go.mod @@ -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 ) diff --git a/packages/arb-validator-core/message/transactionBatch.go b/packages/arb-validator-core/message/transactionBatch.go index 60b13f0128..c85e6d4077 100644 --- a/packages/arb-validator-core/message/transactionBatch.go +++ b/packages/arb-validator-core/message/transactionBatch.go @@ -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" @@ -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] @@ -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 @@ -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 } diff --git a/packages/arb-validator-core/message/transactionBatch_test.go b/packages/arb-validator-core/message/transactionBatch_test.go index 4dbb6c68be..5aeca2ac66 100644 --- a/packages/arb-validator-core/message/transactionBatch_test.go +++ b/packages/arb-validator-core/message/transactionBatch_test.go @@ -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 @@ -32,7 +32,7 @@ func generateTestBatch() TransactionBatch { addr2[0] = 43 addr2[19] = 12 - tx := BatchTx{ + return BatchTx{ To: addr2, SeqNum: big.NewInt(2), Value: big.NewInt(43423), @@ -40,12 +40,33 @@ func generateTestBatch() TransactionBatch { 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() @@ -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") + } +} diff --git a/packages/arb-validator.Dockerfile b/packages/arb-validator.Dockerfile index 98368afe9f..f82fa2e08a 100644 --- a/packages/arb-validator.Dockerfile +++ b/packages/arb-validator.Dockerfile @@ -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/ diff --git a/packages/arb-validator/go.mod b/packages/arb-validator/go.mod index 44d85ce232..8a7ce8d91c 100644 --- a/packages/arb-validator/go.mod +++ b/packages/arb-validator/go.mod @@ -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 ) diff --git a/tests/fibgo/go.mod b/tests/fibgo/go.mod index f8e8832860..79c1e432f2 100644 --- a/tests/fibgo/go.mod +++ b/tests/fibgo/go.mod @@ -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