Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
fix: various build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
atanmarko committed Sep 7, 2023
1 parent e32f415 commit 575033a
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 46 deletions.
4 changes: 2 additions & 2 deletions consensus/ibft/signer/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func Test_wrapCommitHash(t *testing.T) {
assert.Equal(t, expectedOutput, output)
}

//nolint
// nolint

Check failure on line 76 in consensus/ibft/signer/helper_test.go

View workflow job for this annotation

GitHub Actions / golangci_lint

directive `// nolint` should be written without leading space as `//nolint` (nolintlint)
func Test_getOrCreateECDSAKey(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -184,7 +184,7 @@ func Test_getOrCreateECDSAKey(t *testing.T) {
}
}

//nolint
// nolint

Check failure on line 187 in consensus/ibft/signer/helper_test.go

View workflow job for this annotation

GitHub Actions / golangci_lint

directive `// nolint` should be written without leading space as `//nolint` (nolintlint)
func Test_getOrCreateBLSKey(t *testing.T) {
t.Parallel()

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ require (
github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.6.0 // indirect
github.com/topos-protocol/go-topos-sequencer-client v0.0.0-20230719150134-37636f549da4 // indirect
go.uber.org/dig v1.16.1 // indirect
go.uber.org/fx v1.19.2 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw=
github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw=
github.com/topos-protocol/go-topos-sequencer-client v0.0.0-20230719150134-37636f549da4 h1:Nj+BFLcjdabxDNG94kRdDes97TVZ3NnmSoxBTY2eN3w=
github.com/topos-protocol/go-topos-sequencer-client v0.0.0-20230719150134-37636f549da4/go.mod h1:Dt4YfK6HlJg3sdqRpvzk/zab7V+CDS/cQaZLYjmkcfE=
github.com/trailofbits/go-fuzz-utils v0.0.0-20210901195358-9657fcfd256c h1:4WU+p200eLYtBsx3M5CKXvkjVdf5SC3W9nMg37y0TFI=
github.com/trailofbits/go-fuzz-utils v0.0.0-20210901195358-9657fcfd256c/go.mod h1:f3jBhpWvuZmue0HZK52GzRHJOYHYSILs/c8+K2S/J+o=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
Expand Down
16 changes: 8 additions & 8 deletions jsonrpc/eth_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/0xPolygon/polygon-edge/chain"
"github.com/0xPolygon/polygon-edge/crypto"
"github.com/0xPolygon/polygon-edge/gasprice"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/helper/hex"
"github.com/0xPolygon/polygon-edge/helper/progress"
"github.com/0xPolygon/polygon-edge/prover"
"github.com/0xPolygon/polygon-edge/state"
Expand Down Expand Up @@ -109,7 +109,7 @@ var (
//Empty code hash is 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
EmptyCodeHashBytes = []byte{197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125,
178, 220, 199, 3, 192, 229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112}
EmptyCodeHash = hex.EncodeToHex(EmptyCodeHashBytes)
EmptyCodeHash = "0x" + hex.EncodeToString(EmptyCodeHashBytes)
)

// ChainId returns the chain id of the client
Expand Down Expand Up @@ -932,7 +932,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {
Nonce: acc.Nonce,
Balance: acc.Balance,
Root: acc.Root.String(),
CodeHash: hex.EncodeToHex(acc.CodeHash),
CodeHash: "0x" + hex.EncodeToString(acc.CodeHash),
}
}

Expand Down Expand Up @@ -960,7 +960,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {

ss := make([]string, len(storageMerkleProof))
for i, s := range storageMerkleProof {
ss[i] = hex.EncodeToHex(s)
ss[i] = "0x" + hex.EncodeToString(s)
}

storageAccesses = append(storageAccesses, prover.StorageAccess{
Expand All @@ -981,7 +981,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {

transactions := make([]string, 0)
for _, transaction := range fullBlock.Transactions {
transactions = append(transactions, hex.EncodeToHex(transaction.MarshalRLP()))
transactions = append(transactions, "0x"+hex.EncodeToString(transaction.MarshalRLP()))
}

// Receipts from this block
Expand All @@ -1001,7 +1001,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {
}

codeHash := crypto.Keccak256(contractCode)
contractCodes[hex.EncodeToHex(codeHash)] = hex.EncodeToHex(contractCode)
contractCodes["0x"+hex.EncodeToString(codeHash)] = "0x" + hex.EncodeToString(contractCode)
} else {
// Add empty code hash
contractCodes[EmptyCodeHash] = "0x"
Expand All @@ -1019,7 +1019,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {

aa := make([]string, 0)
for _, proof := range accountProof {
aa = append(aa, hex.EncodeToHex(proof))
aa = append(aa, "0x"+hex.EncodeToString(proof))
}

state = append(state, prover.ProverAccountProof{
Expand All @@ -1038,7 +1038,7 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {

zeroAccountProofArray := make([]string, 0)
for _, proof := range zeroAccountProof {
zeroAccountProofArray = append(zeroAccountProofArray, hex.EncodeToHex(proof))
zeroAccountProofArray = append(zeroAccountProofArray, "0x"+hex.EncodeToString(proof))
}

state = append(state, prover.ProverAccountProof{
Expand Down
22 changes: 11 additions & 11 deletions state/runtime/tracer/structtracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ type StructTracer struct {
output []byte
err error

storage []map[types.Address]map[types.Hash]types.Hash
currentMemory []([]byte)
currentStack []([]*big.Int)
storage []map[types.Address]map[types.Hash]types.Hash
currentMemory []([]byte)
currentStack []([]*big.Int)
contractAddress types.Address
storageAccess []map[StorageAccess]bool
accountStorageUpdates map[types.Address]map[StorageAccess]bool
Expand Down Expand Up @@ -364,10 +364,10 @@ func (t *StructTracer) ExecuteState(
}

type StructTraceResult struct {
Failed bool `json:"failed"`
Gas uint64 `json:"gas"`
ReturnValue string `json:"returnValue"`
StructLogs []StructLogRes `json:"structLogs"`
Failed bool `json:"failed"`
Gas uint64 `json:"gas"`
ReturnValue string `json:"returnValue"`
StructLogs []StructLogRes `json:"structLogs"`
Account string `json:"account"`
StorageUpdates map[types.Address]map[StorageAccess]bool `json:"storageUpdates"`
}
Expand Down Expand Up @@ -402,10 +402,10 @@ func (t *StructTracer) GetResult() (interface{}, error) {
storageUpdates := t.accountStorageUpdates

return &StructTraceResult{
Failed: t.err != nil,
Gas: t.consumedGas,
ReturnValue: returnValue,
StructLogs: formatStructLogs(t.logs),
Failed: t.err != nil,
Gas: t.consumedGas,
ReturnValue: returnValue,
StructLogs: formatStructLogs(t.logs),
Account: t.contractAddress.String(),
StorageUpdates: storageUpdates,
}, nil
Expand Down
86 changes: 61 additions & 25 deletions state/runtime/tracer/structtracer/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ func TestStructTracerTxStart(t *testing.T) {
storage: []map[types.Address]map[types.Hash]types.Hash{
make(map[types.Address]map[types.Hash]types.Hash),
},
gasLimit: gasLimit,
currentMemory: make([]([]byte), 1),
currentStack: make([]([]*big.Int), 1),
storageUpdates: make([][]StorageUpdate, 1),
gasLimit: gasLimit,
currentMemory: make([]([]byte), 1),
currentStack: make([]([]*big.Int), 1),
storageAccess: []map[StorageAccess]bool{
make(map[StorageAccess]bool),
},
accountStorageUpdates: make(map[types.Address]map[StorageAccess]bool),
},
tracer,
Expand All @@ -221,11 +223,13 @@ func TestStructTracerTxEnd(t *testing.T) {
storage: []map[types.Address]map[types.Hash]types.Hash{
make(map[types.Address]map[types.Hash]types.Hash),
},
gasLimit: gasLimit,
consumedGas: gasLimit - gasLeft,
currentMemory: make([]([]byte), 1),
currentStack: make([]([]*big.Int), 1),
storageUpdates: make([][]StorageUpdate, 1),
gasLimit: gasLimit,
consumedGas: gasLimit - gasLeft,
currentMemory: make([]([]byte), 1),
currentStack: make([]([]*big.Int), 1),
storageAccess: []map[StorageAccess]bool{
make(map[StorageAccess]bool),
},
accountStorageUpdates: make(map[types.Address]map[StorageAccess]bool),
},
tracer,
Expand Down Expand Up @@ -280,11 +284,13 @@ func TestStructTracerCallEnd(t *testing.T) {
storage: []map[types.Address]map[types.Hash]types.Hash{
make(map[types.Address]map[types.Hash]types.Hash),
},
output: output,
err: err,
currentMemory: make([]([]byte), 1),
currentStack: make([]([]*big.Int), 1),
storageUpdates: make([][]StorageUpdate, 1),
output: output,
err: err,
currentMemory: make([]([]byte), 1),
currentStack: make([]([]*big.Int), 1),
storageAccess: []map[StorageAccess]bool{
make(map[StorageAccess]bool),
},
accountStorageUpdates: make(map[types.Address]map[StorageAccess]bool),
},
},
Expand All @@ -298,9 +304,11 @@ func TestStructTracerCallEnd(t *testing.T) {
storage: []map[types.Address]map[types.Hash]types.Hash{
make(map[types.Address]map[types.Hash]types.Hash),
},
currentMemory: make([]([]byte), 1),
currentStack: make([]([]*big.Int), 1),
storageUpdates: make([][]StorageUpdate, 1),
currentMemory: make([]([]byte), 1),
currentStack: make([]([]*big.Int), 1),
storageAccess: []map[StorageAccess]bool{
make(map[StorageAccess]bool),
},
accountStorageUpdates: make(map[types.Address]map[StorageAccess]bool),
},
},
Expand Down Expand Up @@ -416,6 +424,9 @@ func TestStructTracerCaptureState(t *testing.T) {
storage: []map[types.Address]map[types.Hash]types.Hash{
make(map[types.Address]map[types.Hash]types.Hash),
},
storageAccess: []map[StorageAccess]bool{
make(map[StorageAccess]bool),
},
},
memory: memory,
stack: stack,
Expand Down Expand Up @@ -444,6 +455,11 @@ func TestStructTracerCaptureState(t *testing.T) {
},
},
},
storageAccess: []map[StorageAccess]bool{
{
{types.BytesToHash(big.NewInt(2).Bytes())}: true,
},
},
},
expectedVMState: &mockState{},
},
Expand All @@ -456,7 +472,9 @@ func TestStructTracerCaptureState(t *testing.T) {
storage: []map[types.Address]map[types.Hash]types.Hash{
make(map[types.Address]map[types.Hash]types.Hash),
},
storageUpdates: make([][]StorageUpdate, 1),
storageAccess: []map[StorageAccess]bool{
make(map[StorageAccess]bool),
},
accountStorageUpdates: make(map[types.Address]map[StorageAccess]bool),
},
memory: memory,
Expand All @@ -479,9 +497,9 @@ func TestStructTracerCaptureState(t *testing.T) {
},
},
},
storageUpdates: [][]StorageUpdate{
storageAccess: []map[StorageAccess]bool{
{
StorageUpdate{types.BytesToHash(big.NewInt(2).Bytes()), types.BytesToHash(big.NewInt(1).Bytes())},
{types.BytesToHash(big.NewInt(2).Bytes())}: true,
},
},
accountStorageUpdates: make(map[types.Address]map[StorageAccess]bool),
Expand Down Expand Up @@ -936,11 +954,19 @@ func TestStructTracerGetResult(t *testing.T) {
logs: logs,
consumedGas: consumedGas,
output: returnData,
storageAccess: []map[StorageAccess]bool{
make(map[StorageAccess]bool),
},
accountStorageUpdates: make(map[types.Address]map[StorageAccess]bool),
},
expected: &StructTraceResult{
Account: "0x0000000000000000000000000000000000000000",
Failed: false,
Gas: consumedGas,
ReturnValue: hex.EncodeToString(returnData),
StorageUpdates: map[types.Address]map[StorageAccess]bool{
{}: make(map[StorageAccess]bool),
},
StructLogs: []StructLogRes{
{
Pc: ip,
Expand Down Expand Up @@ -974,16 +1000,22 @@ func TestStructTracerGetResult(t *testing.T) {
{
name: "should return empty ReturnValue if error is marked",
tracer: &StructTracer{
Config: testEmptyConfig,
logs: logs,
consumedGas: consumedGas,
output: returnData,
err: err,
Config: testEmptyConfig,
logs: logs,
consumedGas: consumedGas,
output: returnData,
err: err,
storageAccess: make([]map[StorageAccess]bool, 1),
accountStorageUpdates: make(map[types.Address]map[StorageAccess]bool),
},
expected: &StructTraceResult{
Failed: true,
Gas: consumedGas,
ReturnValue: "",
Account: "0x0000000000000000000000000000000000000000",
StorageUpdates: map[types.Address]map[StorageAccess]bool{
{}: nil,
},
StructLogs: []StructLogRes{
{
Pc: ip,
Expand Down Expand Up @@ -1020,6 +1052,10 @@ func TestStructTracerGetResult(t *testing.T) {
Config: testEmptyConfig,
reason: reason,
logs: logs,
storageAccess: []map[StorageAccess]bool{
make(map[StorageAccess]bool),
},
accountStorageUpdates: make(map[types.Address]map[StorageAccess]bool),
},
expected: nil,
err: reason,
Expand Down

0 comments on commit 575033a

Please sign in to comment.