Skip to content

Commit

Permalink
Merge branch 'develop' into feature/v3-parity
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Nov 21, 2022
2 parents edf9d96 + f80b615 commit 2968d5f
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 7 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Expand Up @@ -37,3 +37,34 @@ jobs:
name: polygon-edge
path: polygon-edge.tar.gz
retention-days: 3

go_build_reproducibility:
name: Verify Build Reproducibility
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go environment
uses: actions/setup-go@v3.3.0
with:
go-version: 1.18.x

- name: 'Reproduce builds'
continue-on-error: true
run: |
go build -o ./edge-1 -trimpath -buildvcs=false
go build -o ./edge-2 -trimpath -buildvcs=false
buildsha1=$(shasum -a256 ./edge-1 | awk '{print $1}')
buildsha2=$(shasum -a256 ./edge-2 | awk '{print $1}')
echo "Build 1 SHA: $buildsha1"
echo "Build 2 SHA: $buildsha2"
if [ "$buildsha1" != "$buildsha2" ]; then
echo "Build artifact does not match original"
exit 1
else
echo "Build artifact matches original"
fi
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -3,8 +3,6 @@ name: Pull Request CI
on: # yamllint disable-line rule:truthy
workflow_dispatch: {}
pull_request:
paths:
- '**.go'

jobs:
build:
Expand Down
39 changes: 39 additions & 0 deletions jsonrpc/testsuite/block-with-txn-bodies.json
@@ -0,0 +1,39 @@
{
"parentHash": "0x0100000000000000000000000000000000000000000000000000000000000000",
"sha3Uncles": "0x0200000000000000000000000000000000000000000000000000000000000000",
"miner": "0x0100000000000000000000000000000000000000",
"stateRoot": "0x0400000000000000000000000000000000000000000000000000000000000000",
"transactionsRoot": "0x0500000000000000000000000000000000000000000000000000000000000000",
"receiptsRoot": "0x0600000000000000000000000000000000000000000000000000000000000000",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0xa",
"totalDifficulty": "0x0",
"size": "0x0",
"number": "0xb",
"gasLimit": "0xc",
"gasUsed": "0xd",
"timestamp": "0xe",
"extraData": "0x616263646566",
"mixHash": "0x0700000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0a00000000000000",
"hash": "0x0800000000000000000000000000000000000000000000000000000000000000",
"transactions": [
{
"nonce": "0x1",
"gasPrice": "0xa",
"gas": "0x64",
"to": "0x0000000000000000000000000000000000000000",
"value": "0x3e8",
"input": "0x0102",
"v": "0x1",
"r": "0x2",
"s": "0x3",
"hash": "0x0200000000000000000000000000000000000000000000000000000000000000",
"from": "0x0300000000000000000000000000000000000000",
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"blockNumber": "0x1",
"transactionIndex": "0x2"
}
],
"uncles": null
}
16 changes: 16 additions & 0 deletions jsonrpc/testsuite/transaction-pending.json
@@ -0,0 +1,16 @@
{
"nonce": "0x1",
"gasPrice": "0xa",
"gas": "0x64",
"to": "0x0000000000000000000000000000000000000000",
"value": "0x3e8",
"input": "0x0102",
"v": "0x1",
"r": "0x2",
"s": "0x3",
"hash": "0x0200000000000000000000000000000000000000000000000000000000000000",
"from": "0x0300000000000000000000000000000000000000",
"blockHash": null,
"blockNumber": null,
"transactionIndex": null
}
16 changes: 16 additions & 0 deletions jsonrpc/testsuite/transaction-sealed.json
@@ -0,0 +1,16 @@
{
"nonce": "0x1",
"gasPrice": "0xa",
"gas": "0x64",
"to": "0x0000000000000000000000000000000000000000",
"value": "0x3e8",
"input": "0x0102",
"v": "0x1",
"r": "0x2",
"s": "0x3",
"hash": "0x0200000000000000000000000000000000000000000000000000000000000000",
"from": "0x0300000000000000000000000000000000000000",
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"blockNumber": "0x1",
"transactionIndex": "0x2"
}
60 changes: 56 additions & 4 deletions jsonrpc/types_test.go
Expand Up @@ -177,16 +177,18 @@ func TestBlock_Encoding(t *testing.T) {
testBlock("testsuite/block-empty.json")
})

t.Run("block with transactions", func(t *testing.T) {
t.Run("block with transaction hashes", func(t *testing.T) {
b.Transactions = []transactionOrHash{
transactionHash{0x8},
}
testBlock("testsuite/block-with-txn-hashes.json")
})

t.Run("block with transactions", func(t *testing.T) {
// TODO: do the same tests for the transaction object and enable this test
t.Skip("TODO")
t.Run("block with transaction bodies", func(t *testing.T) {
b.Transactions = []transactionOrHash{
mockTxn(),
}
testBlock("testsuite/block-with-txn-bodies.json")
})
}

Expand All @@ -198,3 +200,53 @@ func removeWhiteSpace(d []byte) []byte {

return []byte(s)
}

func mockTxn() *transaction {
to := types.Address{}

tt := &transaction{
Nonce: 1,
GasPrice: argBig(*big.NewInt(10)),
Gas: 100,
To: &to,
Value: argBig(*big.NewInt(1000)),
Input: []byte{0x1, 0x2},
V: argBig(*big.NewInt(1)),
R: argBig(*big.NewInt(2)),
S: argBig(*big.NewInt(3)),
Hash: types.Hash{0x2},
From: types.Address{0x3},
BlockHash: &types.ZeroHash,
BlockNumber: argUintPtr(1),
TxIndex: argUintPtr(2),
}

return tt
}

func TestTransaction_Encoding(t *testing.T) {
tt := mockTxn()

testTransaction := func(name string) {
res, err := json.Marshal(tt)
require.NoError(t, err)

data, err := testsuite.ReadFile(name)
require.NoError(t, err)

data = removeWhiteSpace(data)
require.Equal(t, res, data)
}

t.Run("sealed", func(t *testing.T) {
testTransaction("testsuite/transaction-sealed.json")
})

t.Run("pending", func(t *testing.T) {
tt.BlockHash = nil
tt.BlockNumber = nil
tt.TxIndex = nil

testTransaction("testsuite/transaction-pending.json")
})
}
3 changes: 2 additions & 1 deletion server/system_service.go
Expand Up @@ -224,7 +224,8 @@ func (s *systemService) Export(req *proto.ExportRequest, stream proto.System_Exp

const (
defaultMaxGRPCPayloadSize uint64 = 512 * 1024 // 4MB
maxHeaderInfoSize int = 3 * 8 //Number of header fields * bytes per field (From, To, Latest all them uint64)
// number of header fields * bytes per field (From, To, Latest all them uint64)
maxHeaderInfoSize int = 3 * 8
)

type blockStreamWriter struct {
Expand Down

0 comments on commit 2968d5f

Please sign in to comment.