v1.27.0-a #10

Closed
jonathanface wants to merge 473 commits from v1.27.0-a into master
4 changed files with 64 additions and 8 deletions
Showing only changes of commit 3d1cc159b0 - Show all commits

View File

@ -229,13 +229,25 @@ type EthCall struct {
} }
func (c *EthCall) UnmarshalJSON(b []byte) error { func (c *EthCall) UnmarshalJSON(b []byte) error {
type TempEthCall EthCall type EthCallRaw EthCall // Avoid a recursive call.
var params TempEthCall type EthCallDecode struct {
// The field should be "input" by spec, but many clients use "data" so we support
// both, but prefer "input".
Input *EthBytes `json:"input"`
EthCallRaw
}
var params EthCallDecode
if err := json.Unmarshal(b, &params); err != nil { if err := json.Unmarshal(b, &params); err != nil {
return err return err
} }
*c = EthCall(params)
// If input is specified, prefer it.
if params.Input != nil {
params.Data = *params.Input
}
*c = EthCall(params.EthCallRaw)
return nil return nil
} }

View File

@ -194,11 +194,40 @@ func TestMaskedIDInF4(t *testing.T) {
} }
func TestUnmarshalEthCall(t *testing.T) { func TestUnmarshalEthCall(t *testing.T) {
data := `{"from":"0x4D6D86b31a112a05A473c4aE84afaF873f632325","to":"0xFe01CC39f5Ae8553D6914DBb9dC27D219fa22D7f","gas":"0x5","gasPrice":"0x6","value":"0x123","data":""}` data := `{"from":"0x4D6D86b31a112a05A473c4aE84afaF873f632325","to":"0xFe01CC39f5Ae8553D6914DBb9dC27D219fa22D7f","gas":"0x5","gasPrice":"0x6","value":"0x123","data":"0xFF"}`
var c EthCall var c EthCall
err := c.UnmarshalJSON([]byte(data)) err := c.UnmarshalJSON([]byte(data))
require.Nil(t, err) require.Nil(t, err)
require.EqualValues(t, []byte{0xff}, c.Data)
}
func TestUnmarshalEthCallInput(t *testing.T) {
data := `{"from":"0x4D6D86b31a112a05A473c4aE84afaF873f632325","to":"0xFe01CC39f5Ae8553D6914DBb9dC27D219fa22D7f","gas":"0x5","gasPrice":"0x6","value":"0x123","input":"0xFF"}`
var c EthCall
err := c.UnmarshalJSON([]byte(data))
require.Nil(t, err)
require.EqualValues(t, []byte{0xff}, c.Data)
}
func TestUnmarshalEthCallInputAndData(t *testing.T) {
data := `{"from":"0x4D6D86b31a112a05A473c4aE84afaF873f632325","to":"0xFe01CC39f5Ae8553D6914DBb9dC27D219fa22D7f","gas":"0x5","gasPrice":"0x6","value":"0x123","data":"0xFE","input":"0xFF"}`
var c EthCall
err := c.UnmarshalJSON([]byte(data))
require.Nil(t, err)
require.EqualValues(t, []byte{0xff}, c.Data)
}
func TestUnmarshalEthCallInputAndDataEmpty(t *testing.T) {
// Even if the input is empty, it should be used when specified.
data := `{"from":"0x4D6D86b31a112a05A473c4aE84afaF873f632325","to":"0xFe01CC39f5Ae8553D6914DBb9dC27D219fa22D7f","gas":"0x5","gasPrice":"0x6","value":"0x123","data":"0xFE","input":""}`
var c EthCall
err := c.UnmarshalJSON([]byte(data))
require.Nil(t, err)
require.EqualValues(t, []byte{}, c.Data)
} }
func TestUnmarshalEthBytes(t *testing.T) { func TestUnmarshalEthBytes(t *testing.T) {

View File

@ -167,7 +167,7 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
return false, xerrors.Errorf("persist no win: no rows updated") return false, xerrors.Errorf("persist no win: no rows updated")
} }
return false, nil return true, nil
} }
// ensure we have a beacon entry for the epoch we're mining on // ensure we have a beacon entry for the epoch we're mining on

View File

@ -664,7 +664,7 @@ func (l *LocalWorker) GenerateWindowPoStAdv(ctx context.Context, ppt abi.Registe
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(len(sectors)) wg.Add(len(sectors))
vproofs := make([][]byte, 0, len(sectors)) vproofs := make([][]byte, len(sectors))
for i, s := range sectors { for i, s := range sectors {
if l.challengeThrottle != nil { if l.challengeThrottle != nil {
@ -702,8 +702,7 @@ func (l *LocalWorker) GenerateWindowPoStAdv(ctx context.Context, ppt abi.Registe
return return
} }
//vproofs[i] = vanilla // todo substitutes?? vproofs[i] = vanilla
vproofs = append(vproofs, vanilla)
}(i, s) }(i, s)
} }
wg.Wait() wg.Wait()
@ -717,6 +716,22 @@ func (l *LocalWorker) GenerateWindowPoStAdv(ctx context.Context, ppt abi.Registe
return storiface.WindowPoStResult{Skipped: skipped}, nil return storiface.WindowPoStResult{Skipped: skipped}, nil
} }
// compact skipped sectors
var skippedSoFar int
for i := range vproofs {
if len(vproofs[i]) == 0 {
skippedSoFar++
continue
}
if skippedSoFar > 0 {
vproofs[i-skippedSoFar] = vproofs[i]
}
}
vproofs = vproofs[:len(vproofs)-skippedSoFar]
// compute the PoSt!
res, err := sb.GenerateWindowPoStWithVanilla(ctx, ppt, mid, randomness, vproofs, partitionIdx) res, err := sb.GenerateWindowPoStWithVanilla(ctx, ppt, mid, randomness, vproofs, partitionIdx)
r := storiface.WindowPoStResult{ r := storiface.WindowPoStResult{
PoStProofs: res, PoStProofs: res,