From bf7f8dbd5a549c5506a8bf00df7d23c1d5280219 Mon Sep 17 00:00:00 2001 From: frrist Date: Fri, 27 Jan 2023 12:10:37 -0800 Subject: [PATCH] fix: match builtin-actor DelegateCallParams struct - brings types inline with those present in builtin-actors#dev/20230117-pre-rc.4 --- builtin/v10/evm/cbor_gen.go | 54 ++++++++++++++++++++++++++++++++++-- builtin/v10/evm/evm_types.go | 12 ++++++-- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/builtin/v10/evm/cbor_gen.go b/builtin/v10/evm/cbor_gen.go index d65af93f..16d80627 100644 --- a/builtin/v10/evm/cbor_gen.go +++ b/builtin/v10/evm/cbor_gen.go @@ -420,7 +420,7 @@ func (t *GetStorageAtParams) UnmarshalCBOR(r io.Reader) error { return nil } -var lengthBufDelegateCallParams = []byte{130} +var lengthBufDelegateCallParams = []byte{132} func (t *DelegateCallParams) MarshalCBOR(w io.Writer) error { if t == nil { @@ -451,6 +451,24 @@ func (t *DelegateCallParams) MarshalCBOR(w io.Writer) error { if _, err := w.Write(t.Input[:]); err != nil { return err } + + // t.Caller ([20]uint8) (array) + if len(t.Caller) > cbg.ByteArrayMaxLen { + return xerrors.Errorf("Byte array in field t.Caller was too long") + } + + if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.Caller))); err != nil { + return err + } + + if _, err := w.Write(t.Caller[:]); err != nil { + return err + } + + // t.Value (big.Int) (struct) + if err := t.Value.MarshalCBOR(w); err != nil { + return err + } return nil } @@ -468,7 +486,7 @@ func (t *DelegateCallParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input should be of type array") } - if extra != 2 { + if extra != 4 { return fmt.Errorf("cbor input had wrong number of fields") } @@ -505,5 +523,37 @@ func (t *DelegateCallParams) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Input[:]); err != nil { return err } + // t.Caller ([20]uint8) (array) + + maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) + if err != nil { + return err + } + + if extra > cbg.ByteArrayMaxLen { + return fmt.Errorf("t.Caller: byte array too large (%d)", extra) + } + if maj != cbg.MajByteString { + return fmt.Errorf("expected byte array") + } + + if extra != 20 { + return fmt.Errorf("expected array to have 20 elements") + } + + t.Caller = [20]uint8{} + + if _, err := io.ReadFull(br, t.Caller[:]); err != nil { + return err + } + // t.Value (big.Int) (struct) + + { + + if err := t.Value.UnmarshalCBOR(br); err != nil { + return xerrors.Errorf("unmarshaling t.Value: %w", err) + } + + } return nil } diff --git a/builtin/v10/evm/evm_types.go b/builtin/v10/evm/evm_types.go index 088a56ad..fd6859d8 100644 --- a/builtin/v10/evm/evm_types.go +++ b/builtin/v10/evm/evm_types.go @@ -1,6 +1,10 @@ package evm -import "github.com/ipfs/go-cid" +import ( + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-state-types/abi" +) type ConstructorParams struct { Creator []byte @@ -14,6 +18,8 @@ type GetStorageAtParams struct { } type DelegateCallParams struct { - Code cid.Cid - Input []byte + Code cid.Cid + Input []byte + Caller [20]byte + Value abi.TokenAmount }